# naresh1401/ai-code-review-agent architecture

> Architecture diagram of the GitHub repository naresh1401/ai-code-review-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/naresh1401/ai-code-review-agent
- Repository: https://github.com/naresh1401/ai-code-review-agent

## Overview

AI Code Review Agent reviews pull-request diffs with an LLM, produces line-level findings and a score/verdict, and can publish the review back to GitHub. The principal workflow is GitHub webhook → FastAPI background processing → diff retrieval → review → GitHub comments; a separate manual-review API and Streamlit interface support pasted diffs. The README documents the product capabilities, while source excerpts confirm the orchestration and integrations shown. The reviewer’s internal prompt generation and response parsing are not fully shown, so they are represented within the reviewer component.

Main entry points: [`src/api/main.py`](https://github.com/naresh1401/ai-code-review-agent/blob/main/src/api/main.py) (FastAPI API), [`src/github/github_handler.py`](https://github.com/naresh1401/ai-code-review-agent/blob/main/src/github/github_handler.py) (GitHub Handler), [`src/analyzer/code_reviewer.py`](https://github.com/naresh1401/ai-code-review-agent/blob/main/src/analyzer/code_reviewer.py) (Review Engine), [`ui/app.py`](https://github.com/naresh1401/ai-code-review-agent/blob/main/ui/app.py) (Review UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry Points"]
  node_streamlit_ui["Review UI<br/>[app.py]"]
end

subgraph group_orchestration["Review Orchestration"]
  node_fastapi["FastAPI API<br/>[main.py]"]
end

subgraph group_analysis["Review Analysis"]
  node_review_engine["Review Engine<br/>[code_reviewer.py]"]
  node_review_result["Review Result<br/>[code_reviewer.py]"]
end

subgraph group_integration["GitHub Integration"]
  node_signature["Signature Check<br/>[github_handler.py]"]
  node_github_handler["GitHub Handler<br/>[github_handler.py]"]
end

node_github_actor(("GitHub PR"))
node_manual_user(("Reviewer"))
node_llm_service(("LLM Provider"))

node_manual_user -->|"enters diff"| node_streamlit_ui
node_streamlit_ui -->|"posts review"| node_fastapi
node_manual_user -->|"submits diff"| node_fastapi
node_github_actor -->|"sends webhook"| node_fastapi
node_fastapi -->|"verifies signature"| node_signature
node_fastapi -->|"fetches diffs"| node_github_handler
node_fastapi -->|"requests review"| node_review_engine
node_fastapi -->|"posts review"| node_github_handler
node_review_engine -->|"builds result"| node_review_result
node_github_handler -->|"reads diffs"| node_github_actor
node_github_handler -->|"posts comments"| node_github_actor
node_fastapi -->|"configures provider"| node_llm_service
node_review_engine -.->|"requests analysis"| node_llm_service

click node_streamlit_ui "https://github.com/naresh1401/ai-code-review-agent/blob/main/ui/app.py"
click node_fastapi "https://github.com/naresh1401/ai-code-review-agent/blob/main/src/api/main.py"
click node_signature "https://github.com/naresh1401/ai-code-review-agent/blob/main/src/github/github_handler.py"
click node_github_handler "https://github.com/naresh1401/ai-code-review-agent/blob/main/src/github/github_handler.py"
click node_review_engine "https://github.com/naresh1401/ai-code-review-agent/blob/main/src/analyzer/code_reviewer.py"
click node_review_result "https://github.com/naresh1401/ai-code-review-agent/blob/main/src/analyzer/code_reviewer.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_streamlit_ui,node_manual_user toneBlue
class node_fastapi toneAmber
class node_review_engine,node_review_result toneMint
class node_signature,node_github_handler toneRose
class node_github_actor,node_llm_service toneIndigo
```

## Components

### Entry Points

- [Review UI](https://github.com/naresh1401/ai-code-review-agent/blob/main/ui/app.py): `ui/app.py`

### Review Orchestration

- [FastAPI API](https://github.com/naresh1401/ai-code-review-agent/blob/main/src/api/main.py): `src/api/main.py`

### Review Analysis

- [Review Engine](https://github.com/naresh1401/ai-code-review-agent/blob/main/src/analyzer/code_reviewer.py): `src/analyzer/code_reviewer.py`
- [Review Result](https://github.com/naresh1401/ai-code-review-agent/blob/main/src/analyzer/code_reviewer.py): `src/analyzer/code_reviewer.py`

### GitHub Integration

- [Signature Check](https://github.com/naresh1401/ai-code-review-agent/blob/main/src/github/github_handler.py): `src/github/github_handler.py`
- [GitHub Handler](https://github.com/naresh1401/ai-code-review-agent/blob/main/src/github/github_handler.py): `src/github/github_handler.py`

### Other components

- **GitHub PR**
- **Reviewer**
- **LLM Provider**

## Connections

- Reviewer → Review UI: enters diff (evidence: `ui/app.py`)
- Review UI → FastAPI API: posts review (evidence: `ui/app.py`)
- Reviewer → FastAPI API: submits diff (evidence: `README.md`)
- GitHub PR → FastAPI API: sends webhook (evidence: `README.md`)
- FastAPI API → Signature Check: verifies signature (evidence: `src/api/main.py`)
- FastAPI API → GitHub Handler: fetches diffs (evidence: `src/api/main.py`)
- FastAPI API → Review Engine: requests review (evidence: `src/api/main.py`)
- FastAPI API → GitHub Handler: posts review (evidence: `src/api/main.py`)
- Review Engine → Review Result: builds result (evidence: `README.md`)
- GitHub Handler → GitHub PR: reads diffs (evidence: `src/github/github_handler.py`)
- GitHub Handler → GitHub PR: posts comments (evidence: `src/github/github_handler.py`)
- FastAPI API → LLM Provider: configures provider (evidence: `src/api/main.py`)
- Review Engine → LLM Provider: requests analysis
