Skip to content

willianpinho/agent-advisor-platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– Agent Advisor Platform

Python FastAPI PostgreSQL Redis Test Coverage License

AI-powered Python code analysis platform using Crew AI with multiple specialized agents.

🎯 Overview

The Agent Advisor Platform is a modern static code analysis platform for Python that uses multiple AI agents (Crew AI) to provide comprehensive analysis of:

  • Code Quality: Detection of code smells, anti-patterns, and PEP8 violations
  • Performance: Identification of bottlenecks and optimization suggestions
  • Security: Analysis of vulnerabilities (OWASP) and insecure practices
  • Documentation: Verification of docstrings, type hints, and comments
  • Complexity: Cyclomatic complexity metrics and maintainability index

✨ Key Features

πŸš€ Real-Time Code Analysis

  • Synchronous Analysis: Immediate response for small snippets (<100 lines)
  • Asynchronous Analysis: Background processing for large files via Celery
  • Multiple Agents: 4 specialized agents working in parallel

πŸ“Š Comprehensive Metrics

  • AST Analysis: Native Python Abstract Syntax Tree analysis
  • Complexity Metrics: Radon for cyclomatic complexity calculation
  • Maintainability Index: Maintainability score (0-100)
  • Security Scanning: Detection of common vulnerabilities (SQL Injection, XSS, etc.)

πŸ”„ Scalability and Performance

  • Multi-Layer Cache: In-memory LRU + Redis + PostgreSQL
  • Horizontal Scaling: Celery workers can be scaled independently
  • Connection Pooling: SQLAlchemy async pool
  • Rate Limiting: Configurable per endpoint

πŸ“ˆ Test Coverage & Metrics

Metric Value Description
Overall Coverage 47.88% 207+ comprehensive tests
Unit Tests 113 Fast, isolated tests
Integration Tests 94 API, database, and cache tests
Lines of Code ~5,000 Well-structured Python 3.11+ codebase
Services Coverage 90%+ AST, Complexity, Code Analyzers
Repositories Coverage 85%+ Database operations with JSONB
API Coverage 85%+ 39 endpoint tests

πŸš€ Quick Start (5 minutes)

Prerequisites

  • Docker 24+ and Docker Compose 2.20+
  • Python 3.11+ (for local development)
  • OpenAI API Key

Installation

# 1. Clone the repository
git clone https://github.com/willianpinho/agent-advisor-platform.git
cd agent-advisor-platform

# 2. Configure environment variables
cp .env.example .env
# Edit .env and add your OPENAI_API_KEY

# 3. Start all services
docker-compose up -d

# 4. Wait for health checks (1-2 minutes)
docker-compose ps

# 5. Test the API
curl http://localhost:8000/health

Access Services

First Analysis

curl -X POST "http://localhost:8000/api/v1/analysis/sync" \
  -H "Content-Type: application/json" \
  -d '{
    "source_code": "def hello():\n    print(\"Hello World\")",
    "filename": "example.py",
    "analysis_type": "full"
  }'

πŸ—οΈ Architecture

The platform follows Clean Architecture principles with Hexagonal Architecture:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         API Layer (FastAPI)                 β”‚
β”‚  /analysis/sync  β”‚  /analysis/async  β”‚ etc β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚        Service Layer                        β”‚
β”‚  CodeAnalyzer β†’ CrewAI Orchestrator         β”‚
β”‚  AST, Complexity, Security Analyzers        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      Repository Layer                       β”‚
β”‚  AnalysisRepository (CRUD + Queries)        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Infrastructure Layer                     β”‚
β”‚  PostgreSQL  β”‚  Redis  β”‚  RabbitMQ          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Technology Stack

Category Technologies
Backend FastAPI 0.109+, Python 3.11+, Uvicorn
Database PostgreSQL 16, SQLAlchemy 2.0 (async)
Cache & Queue Redis 7, Celery 5.3, RabbitMQ 3
AI & Analysis Crew AI 0.11+, OpenAI GPT-4, Radon
Validation Pydantic V2, Type Hints, MyPy
Testing pytest, pytest-asyncio, httpx
Infrastructure Docker, Docker Compose, Poetry

πŸ“š Documentation

Complete documentation is available in VitePress format:

πŸ“– Getting Started

πŸ—οΈ Architecture & Design

πŸ”§ Development

πŸ“– API & Examples

πŸš€ View Documentation Site

# Install dependencies
npm install

# Start documentation server
npm run docs:dev

# Build documentation
npm run docs:build

# Access at http://localhost:5173

πŸ’» Development

Local Development Setup

# Install Poetry
curl -sSL https://install.python-poetry.org | python3 -

# Install dependencies
poetry install

# Start infrastructure
docker-compose up -d postgres redis rabbitmq

# Run migrations
poetry run alembic upgrade head

# Start API server
poetry run uvicorn src.main:app --reload

# Start Celery worker (in another terminal)
poetry run celery -A src.workers.celery_app worker --loglevel=info

Running Tests

# All tests
poetry run pytest

# With coverage
poetry run pytest --cov=src

# Unit tests only
poetry run pytest tests/unit/

# Integration tests only
poetry run pytest tests/integration/

Code Quality

# Linting
poetry run ruff check .

# Formatting
poetry run black .
poetry run isort .

# Type checking
poetry run mypy src/

πŸ“Š Project Structure

agent-advisor-platform/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ api/              # FastAPI routes and dependencies
β”‚   β”œβ”€β”€ core/             # Configuration and settings
β”‚   β”œβ”€β”€ domain/           # Models, schemas, enums
β”‚   β”œβ”€β”€ services/         # Business logic and analyzers
β”‚   β”œβ”€β”€ repositories/     # Data access layer
β”‚   β”œβ”€β”€ infrastructure/   # Database, cache, queue
β”‚   β”œβ”€β”€ workers/          # Celery workers
β”‚   └── main.py           # Application entry point
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ unit/             # Unit tests (113 tests)
β”‚   β”œβ”€β”€ integration/      # Integration tests (94 tests)
β”‚   └── conftest.py       # Shared fixtures
β”œβ”€β”€ docs/                 # VitePress documentation
β”œβ”€β”€ scripts/              # Utility scripts
β”œβ”€β”€ docker-compose.yml    # Docker orchestration
β”œβ”€β”€ pyproject.toml        # Poetry configuration
└── README.md             # This file

🀝 Contributing

We welcome contributions! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ”’ Security

  • Input validation with Pydantic V2
  • SQL injection prevention via SQLAlchemy ORM
  • Environment-based secrets management
  • CORS configuration
  • Rate limiting support

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

Built with modern technologies:

πŸ“ž Support


Developed with ❀️ for the Technical Innovation Challenge

About

The Agent Advisor Platform is a modern static code analysis platform for Python that uses multiple AI agents (Crew AI)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors