ai-code-review-agent / docs /architecture.md
Padmanav's picture
feat(worker): add named Celery queues (high/low priority) with task routing by repo size
ba4292e
|
Raw
History Blame Contribute Delete
3.3 kB

A newer version of the Gradio SDK is available: 6.20.0

Upgrade

Architecture

System Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Gradio UI  │────▢│   FastAPI   │────▢│   Agent Layer    β”‚
β”‚  Port 7860  β”‚     β”‚  Port 8000  β”‚     β”‚                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
                                        β”‚  β”‚ Repo Agent β”‚  β”‚
                                        β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”‚
                                        β”‚  β”‚ Bug Agent  β”‚  β”‚
                                        β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”‚
                                        β”‚  β”‚ Test Agent β”‚  β”‚
                                        β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”‚
                                        β”‚  β”‚ Review     β”‚  β”‚
                                        β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”‚
                                        β”‚  β”‚ Report     β”‚  β”‚
                                        β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Agent Flow

  1. User submits GitHub URL via Gradio
  2. Gradio sends POST request to FastAPI
  3. FastAPI clones repository locally (shallow clone, depth=1)
  4. repo_analysis_agent runs first to build repository metadata
  5. bug_detection_agent, test_generation_agent, code_review_agent run in parallel via asyncio.gather
  6. report_generator_agent aggregates all outputs into a final report
  7. Cloned repository is deleted from disk
  8. Results displayed in Gradio tabs

Data Flow

RepositoryRequest
      β”‚
      β–Ό
clone_repository()
      β”‚
      β–Ό
RepositoryMetadata ──▢ IssueReport ──▢ GeneratedTests ──▢ ReviewSuggestions
      β”‚                    β”‚                 β”‚                    β”‚
      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
                            EngineeringReport

LLM Integration

All agents use OpenRouter API with open source models. Default model: meta-llama/llama-3.3-70b-instruct

Alternative models:

  • mistralai/mistral-7b-instruct
  • deepseek/deepseek-chat
  • google/gemma-3-27b-it

Task queue design

Jobs are routed to one of two Celery queues backed by Redis:

Queue Threshold Expected duration
high repos < 50 MB < 60 s
low repos β‰₯ 50 MB 1–5 min

Workers consume high before low, so a flood of large-repo jobs cannot starve small fast ones. Both queues are durable β€” a Redis restart does not lose in-flight tasks because task_acks_late=True means a task is only acknowledged after it completes, not on receipt.

Retry policy: up to 2 retries with 60 s / 120 s exponential backoff.