# hhari1234/ai-code-reviewer architecture

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

- Interactive diagram: https://gitdiagram.com/hhari1234/ai-code-reviewer
- Repository: https://github.com/hhari1234/ai-code-reviewer

## Overview

PR-Agent accepts pull-request commands, gathers repository and diff context, invokes an AI provider, and publishes review output through a Git hosting provider. The README highlights review, describe, improve, and ask; the tree also contains handlers and tools for labels, questions, documentation, changelogs, and compliance. The graph focuses on runtime components and major documented capabilities. Several tool and server links are based on the SOURCE INDEX or README rather than complete source excerpts, so uncertain wiring is omitted.

Main entry points: [`pr_agent/agent/pr_agent.py`](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/agent/pr_agent.py) (Command router), [`pr_agent/tools/pr_code_suggestions.py`](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/tools/pr_code_suggestions.py) (Code suggestions), [`pr_agent/tools/pr_reviewer.py`](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/tools/pr_reviewer.py) (PR review), [`pr_agent/git_providers/github_provider.py`](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/git_providers/github_provider.py) (GitHub provider)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Request handling"]
  node_agent["Command router<br/>[pr_agent.py]"]
  node_cli["CLI entry<br/>[cli.py]"]
  node_settings["Configuration<br/>[config_loader.py]"]
end

subgraph group_tools["PR capabilities"]
  node_review["PR review<br/>[pr_reviewer.py]"]
  node_description["PR description<br/>[pr_description.py]"]
  node_suggestions["Code suggestions"]
  node_questions["PR questions<br/>[pr_questions.py]"]
  node_other_tools["Other PR tools"]
end

subgraph group_analysis["Review analysis"]
  node_pr_processing["PR processing<br/>[pr_processing.py]"]
  node_repo_context["Repository context<br/>[repo_context.py]"]
  node_diff_processing["Diff processing"]
  node_comment_dedup["Comment deduplication"]
  node_skills["Skills loading<br/>[skills_loader.py]"]
  node_tokens["Token handling<br/>[token_handler.py]"]
end

subgraph group_integrations["Providers and servers"]
  node_ai_base["AI handler interface<br/>[base_ai_handler.py]"]
  node_litellm["LiteLLM handler"]
  node_github["GitHub provider<br/>[github_provider.py]"]
  node_provider_base["Provider interface<br/>[git_provider.py]"]
  node_other_providers["Other providers"]
  node_webhooks["Webhook servers"]
  node_mosaico["MOSAICO A2A<br/>[server.py]"]
end

node_user(("Developer"))
node_llm_service(("LLM service"))
node_hosting(("Git hosting"))

node_user -->|"submits command"| node_cli
node_cli -.->|"routes request"| node_agent
node_agent -->|"dispatches"| node_review
node_agent -->|"dispatches"| node_description
node_agent -->|"dispatches"| node_suggestions
node_agent -->|"dispatches"| node_questions
node_agent -->|"dispatches"| node_other_tools
node_review -->|"uses"| node_pr_processing
node_review -->|"uses"| node_repo_context
node_review -->|"uses"| node_skills
node_review -->|"uses"| node_tokens
node_review -->|"requests inference"| node_litellm
node_review -.->|"publishes review"| node_github
node_suggestions -->|"uses"| node_diff_processing
node_suggestions -->|"uses"| node_pr_processing
node_suggestions -->|"uses"| node_repo_context
node_suggestions -->|"uses"| node_skills
node_suggestions -->|"uses"| node_tokens
node_suggestions -->|"requests inference"| node_litellm
node_suggestions -.->|"publishes suggestions"| node_github
node_litellm -->|"implements"| node_ai_base
node_litellm -->|"requests completion"| node_llm_service
node_github -->|"reads and publishes"| node_hosting
node_github -->|"uses"| node_diff_processing
node_github -->|"uses"| node_comment_dedup
node_github -->|"implements"| node_provider_base
node_other_providers -.->|"integrates"| node_hosting
node_webhooks -->|"forwards requests"| node_agent
node_mosaico -->|"dispatches requests"| node_agent
node_agent -->|"loads settings"| node_settings

click node_agent "https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/agent/pr_agent.py"
click node_cli "https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/cli.py"
click node_review "https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/tools/pr_reviewer.py"
click node_description "https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/tools/pr_description.py"
click node_suggestions "https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/tools/pr_code_suggestions.py"
click node_questions "https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/tools/pr_questions.py"
click node_other_tools "https://github.com/hhari1234/ai-code-reviewer/tree/main/pr_agent/tools"
click node_pr_processing "https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/algo/pr_processing.py"
click node_repo_context "https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/algo/repo_context.py"
click node_diff_processing "https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/algo/git_patch_processing.py"
click node_comment_dedup "https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/algo/inline_comment_dedup.py"
click node_skills "https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/algo/skills_loader.py"
click node_tokens "https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/algo/token_handler.py"
click node_ai_base "https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/algo/ai_handlers/base_ai_handler.py"
click node_litellm "https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/algo/ai_handlers/litellm_ai_handler.py"
click node_github "https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/git_providers/github_provider.py"
click node_provider_base "https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/git_providers/git_provider.py"
click node_other_providers "https://github.com/hhari1234/ai-code-reviewer/tree/main/pr_agent/git_providers"
click node_webhooks "https://github.com/hhari1234/ai-code-reviewer/tree/main/pr_agent/servers"
click node_mosaico "https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/mosaico/server.py"
click node_settings "https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/config_loader.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_agent,node_cli,node_settings toneBlue
class node_review,node_description,node_suggestions,node_questions,node_other_tools toneAmber
class node_pr_processing,node_repo_context,node_diff_processing,node_comment_dedup,node_skills,node_tokens toneMint
class node_ai_base,node_litellm,node_github,node_provider_base,node_other_providers,node_webhooks,node_mosaico toneRose
class node_user,node_llm_service,node_hosting toneIndigo
```

## Components

### Request handling

- [Command router](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/agent/pr_agent.py): `pr_agent/agent/pr_agent.py`
- [CLI entry](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/cli.py): `pr_agent/cli.py`
- [Configuration](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/config_loader.py): `pr_agent/config_loader.py`

### PR capabilities

- [PR review](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/tools/pr_reviewer.py): `pr_agent/tools/pr_reviewer.py`
- [PR description](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/tools/pr_description.py): `pr_agent/tools/pr_description.py`
- [Code suggestions](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/tools/pr_code_suggestions.py): `pr_agent/tools/pr_code_suggestions.py`
- [PR questions](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/tools/pr_questions.py): `pr_agent/tools/pr_questions.py`
- [Other PR tools](https://github.com/hhari1234/ai-code-reviewer/tree/main/pr_agent/tools): `pr_agent/tools`

### Review analysis

- [PR processing](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/algo/pr_processing.py): `pr_agent/algo/pr_processing.py`
- [Repository context](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/algo/repo_context.py): `pr_agent/algo/repo_context.py`
- [Diff processing](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/algo/git_patch_processing.py): `pr_agent/algo/git_patch_processing.py`
- [Comment deduplication](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/algo/inline_comment_dedup.py): `pr_agent/algo/inline_comment_dedup.py`
- [Skills loading](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/algo/skills_loader.py): `pr_agent/algo/skills_loader.py`
- [Token handling](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/algo/token_handler.py): `pr_agent/algo/token_handler.py`

### Providers and servers

- [AI handler interface](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/algo/ai_handlers/base_ai_handler.py): `pr_agent/algo/ai_handlers/base_ai_handler.py`
- [LiteLLM handler](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/algo/ai_handlers/litellm_ai_handler.py): `pr_agent/algo/ai_handlers/litellm_ai_handler.py`
- [GitHub provider](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/git_providers/github_provider.py): `pr_agent/git_providers/github_provider.py`
- [Provider interface](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/git_providers/git_provider.py): `pr_agent/git_providers/git_provider.py`
- [Other providers](https://github.com/hhari1234/ai-code-reviewer/tree/main/pr_agent/git_providers): `pr_agent/git_providers`
- [Webhook servers](https://github.com/hhari1234/ai-code-reviewer/tree/main/pr_agent/servers): `pr_agent/servers`
- [MOSAICO A2A](https://github.com/hhari1234/ai-code-reviewer/blob/main/pr_agent/mosaico/server.py): `pr_agent/mosaico/server.py`

### Other components

- **Developer**
- **LLM service**
- **Git hosting**

## Connections

- Developer → CLI entry: submits command (evidence: `README.md`)
- CLI entry → Command router: routes request
- Command router → PR review: dispatches (evidence: `pr_agent/agent/pr_agent.py`)
- Command router → PR description: dispatches (evidence: `pr_agent/agent/pr_agent.py`)
- Command router → Code suggestions: dispatches (evidence: `pr_agent/agent/pr_agent.py`)
- Command router → PR questions: dispatches (evidence: `pr_agent/agent/pr_agent.py`)
- Command router → Other PR tools: dispatches (evidence: `pr_agent/agent/pr_agent.py`)
- PR review → PR processing: uses (evidence: `pr_agent/tools/pr_reviewer.py`)
- PR review → Repository context: uses (evidence: `pr_agent/tools/pr_reviewer.py`)
- PR review → Skills loading: uses (evidence: `pr_agent/tools/pr_reviewer.py`)
- PR review → Token handling: uses (evidence: `pr_agent/tools/pr_reviewer.py`)
- PR review → LiteLLM handler: requests inference (evidence: `pr_agent/tools/pr_reviewer.py`)
- PR review → GitHub provider: publishes review
- Code suggestions → Diff processing: uses (evidence: `pr_agent/tools/pr_code_suggestions.py`)
- Code suggestions → PR processing: uses (evidence: `pr_agent/tools/pr_code_suggestions.py`)
- Code suggestions → Repository context: uses (evidence: `pr_agent/tools/pr_code_suggestions.py`)
- Code suggestions → Skills loading: uses (evidence: `pr_agent/tools/pr_code_suggestions.py`)
- Code suggestions → Token handling: uses (evidence: `pr_agent/tools/pr_code_suggestions.py`)
- Code suggestions → LiteLLM handler: requests inference (evidence: `pr_agent/tools/pr_code_suggestions.py`)
- Code suggestions → GitHub provider: publishes suggestions
- LiteLLM handler → AI handler interface: implements (evidence: `pr_agent/algo/ai_handlers/litellm_ai_handler.py`)
- LiteLLM handler → LLM service: requests completion (evidence: `README.md`)
- GitHub provider → Git hosting: reads and publishes (evidence: `README.md`)
- GitHub provider → Diff processing: uses (evidence: `pr_agent/git_providers/github_provider.py`)
- GitHub provider → Comment deduplication: uses (evidence: `pr_agent/git_providers/github_provider.py`)
- GitHub provider → Provider interface: implements (evidence: `pr_agent/git_providers/github_provider.py`)
- Other providers → Git hosting: integrates
- Webhook servers → Command router: forwards requests (evidence: `pr_agent/servers/gitlab_webhook.py`)
- MOSAICO A2A → Command router: dispatches requests
- Command router → Configuration: loads settings (evidence: `pr_agent/agent/pr_agent.py`)
