# nikita-filonov/ai-review architecture

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

- Interactive diagram: https://gitdiagram.com/nikita-filonov/ai-review
- Repository: https://github.com/nikita-filonov/ai-review

## Overview

AI Review is a client-side AI code-review tool. A developer or CI job selects a CLI mode; the review service coordinates repository and diff context, policy and prompts, an LLM (optionally using repository-exploration agent mode), then review-specific runners and gateways post comments or replies through a configured VCS integration. The README documents inline, context, summary, and reply modes, multiple VCS/LLM providers, and configurable prompts. Edges are limited to relationships shown in excerpts, the SOURCE INDEX, or README; unsampled mode and provider internals are represented by their subsystem paths.

Main entry points: [`ai_review/services/review/service.py`](https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/review/service.py) (Review coordinator), [`ai_review/cli/main.py`](https://github.com/nikita-filonov/ai-review/blob/main/ai_review/cli/main.py) (Review CLI), [`ai_review/services/vcs`](https://github.com/nikita-filonov/ai-review/tree/main/ai_review/services/vcs) (VCS adapters), [`ai_review/services/agent/loop/service.py`](https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/agent/loop/service.py) (Agent loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and configuration"]
  node_cli["Review CLI<br/>[main.py]"]
  node_settings["Resolved settings<br/>[config.py]"]
end

subgraph group_review["Review workflow"]
  node_review_service["Review coordinator<br/>[service.py]"]
  node_review_modes["Review modes"]
  node_review_types["Mode analysis"]
  node_agent["Agent loop<br/>[service.py]"]
  node_agent_tools["Repository tools<br/>[service.py]"]
  node_prompt["Prompt rendering<br/>[service.py]"]
  node_policy["Review policy<br/>[service.py]"]
end

subgraph group_context["Review context"]
  node_git["Repository state<br/>[service.py]"]
  node_diff["Diff processing<br/>[service.py]"]
end

subgraph group_providers["Provider integrations"]
  node_llm_factory["LLM selection<br/>[factory.py]"]
  node_llm_providers["LLM providers"]
end

subgraph group_delivery["Review delivery"]
  node_vcs_factory["VCS selection<br/>[factory.py]"]
  node_vcs_adapters["VCS adapters"]
  node_vcs_clients["Provider API clients"]
  node_comment_gateway["Comment gateways"]
  node_artifacts["Review artifacts<br/>[service.py]"]
  node_cost["Usage accounting<br/>[service.py]"]
end

node_developer(("Developer / CI"))
node_vcs_service(("Pull request platform"))
node_llm_service(("LLM service"))

node_developer -->|"selects mode"| node_cli
node_cli -->|"starts review"| node_review_service
node_cli -->|"shows config"| node_settings
node_review_service -->|"reads settings"| node_settings
node_review_service -->|"constructs runners"| node_review_modes
node_review_service -->|"constructs services"| node_review_types
node_review_service -->|"configures agent"| node_agent
node_review_service -->|"configures tools"| node_agent_tools
node_review_service -->|"configures prompts"| node_prompt
node_review_service -->|"configures policy"| node_policy
node_review_service -->|"configures context"| node_git
node_review_service -->|"configures diff"| node_diff
node_review_service -->|"selects LLM"| node_llm_factory
node_review_service -->|"selects VCS"| node_vcs_factory
node_review_service -->|"configures posting"| node_comment_gateway
node_review_service -->|"configures artifacts"| node_artifacts
node_review_service -->|"configures accounting"| node_cost
node_agent -->|"uses tools"| node_agent_tools
node_llm_factory -.->|"selects provider"| node_llm_providers
node_llm_providers -.->|"sends requests"| node_llm_service
node_vcs_factory -.->|"selects adapter"| node_vcs_adapters
node_vcs_adapters -->|"uses API clients"| node_vcs_clients
node_vcs_clients -.->|"reads and posts"| node_vcs_service
node_comment_gateway -.->|"posts feedback"| node_vcs_adapters

click node_cli "https://github.com/nikita-filonov/ai-review/blob/main/ai_review/cli/main.py"
click node_settings "https://github.com/nikita-filonov/ai-review/blob/main/ai_review/config.py"
click node_review_service "https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/review/service.py"
click node_review_modes "https://github.com/nikita-filonov/ai-review/tree/main/ai_review/services/review/runner"
click node_review_types "https://github.com/nikita-filonov/ai-review/tree/main/ai_review/services/review/internal"
click node_agent "https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/agent/loop/service.py"
click node_agent_tools "https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/agent/tool/service.py"
click node_prompt "https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/prompt/service.py"
click node_policy "https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/policy/service.py"
click node_git "https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/git/service.py"
click node_diff "https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/diff/service.py"
click node_llm_factory "https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/llm/factory.py"
click node_llm_providers "https://github.com/nikita-filonov/ai-review/tree/main/ai_review/services/llm"
click node_vcs_factory "https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/vcs/factory.py"
click node_vcs_adapters "https://github.com/nikita-filonov/ai-review/tree/main/ai_review/services/vcs"
click node_vcs_clients "https://github.com/nikita-filonov/ai-review/tree/main/ai_review/clients"
click node_comment_gateway "https://github.com/nikita-filonov/ai-review/tree/main/ai_review/services/review/gateway"
click node_artifacts "https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/artifacts/service.py"
click node_cost "https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/cost/service.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_cli,node_settings toneBlue
class node_review_service,node_review_modes,node_review_types,node_agent,node_agent_tools,node_prompt,node_policy toneAmber
class node_git,node_diff,node_vcs_service toneMint
class node_llm_factory,node_llm_providers toneRose
class node_vcs_factory,node_vcs_adapters,node_vcs_clients,node_comment_gateway,node_artifacts,node_cost,node_developer,node_llm_service toneIndigo
```

## Components

### CLI and configuration

- [Review CLI](https://github.com/nikita-filonov/ai-review/blob/main/ai_review/cli/main.py): `ai_review/cli/main.py`
- [Resolved settings](https://github.com/nikita-filonov/ai-review/blob/main/ai_review/config.py): `ai_review/config.py`

### Review workflow

- [Review coordinator](https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/review/service.py): `ai_review/services/review/service.py`
- [Review modes](https://github.com/nikita-filonov/ai-review/tree/main/ai_review/services/review/runner): `ai_review/services/review/runner`
- [Mode analysis](https://github.com/nikita-filonov/ai-review/tree/main/ai_review/services/review/internal): `ai_review/services/review/internal`
- [Agent loop](https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/agent/loop/service.py): `ai_review/services/agent/loop/service.py`
- [Repository tools](https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/agent/tool/service.py): `ai_review/services/agent/tool/service.py`
- [Prompt rendering](https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/prompt/service.py): `ai_review/services/prompt/service.py`
- [Review policy](https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/policy/service.py): `ai_review/services/policy/service.py`

### Review context

- [Repository state](https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/git/service.py): `ai_review/services/git/service.py`
- [Diff processing](https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/diff/service.py): `ai_review/services/diff/service.py`

### Provider integrations

- [LLM selection](https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/llm/factory.py): `ai_review/services/llm/factory.py`
- [LLM providers](https://github.com/nikita-filonov/ai-review/tree/main/ai_review/services/llm): `ai_review/services/llm`

### Review delivery

- [VCS selection](https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/vcs/factory.py): `ai_review/services/vcs/factory.py`
- [VCS adapters](https://github.com/nikita-filonov/ai-review/tree/main/ai_review/services/vcs): `ai_review/services/vcs`
- [Provider API clients](https://github.com/nikita-filonov/ai-review/tree/main/ai_review/clients): `ai_review/clients`
- [Comment gateways](https://github.com/nikita-filonov/ai-review/tree/main/ai_review/services/review/gateway): `ai_review/services/review/gateway`
- [Review artifacts](https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/artifacts/service.py): `ai_review/services/artifacts/service.py`
- [Usage accounting](https://github.com/nikita-filonov/ai-review/blob/main/ai_review/services/cost/service.py): `ai_review/services/cost/service.py`

### Other components

- **Developer / CI**
- **Pull request platform**
- **LLM service**

## Connections

- Developer / CI → Review CLI: selects mode
- Review CLI → Review coordinator: starts review
- Review CLI → Resolved settings: shows config (evidence: `ai_review/cli/main.py`)
- Review coordinator → Resolved settings: reads settings (evidence: `ai_review/services/review/service.py`)
- Review coordinator → Review modes: constructs runners (evidence: `ai_review/services/review/service.py`)
- Review coordinator → Mode analysis: constructs services (evidence: `ai_review/services/review/service.py`)
- Review coordinator → Agent loop: configures agent (evidence: `ai_review/services/review/service.py`)
- Review coordinator → Repository tools: configures tools (evidence: `ai_review/services/review/service.py`)
- Review coordinator → Prompt rendering: configures prompts (evidence: `ai_review/services/review/service.py`)
- Review coordinator → Review policy: configures policy (evidence: `ai_review/services/review/service.py`)
- Review coordinator → Repository state: configures context (evidence: `ai_review/services/review/service.py`)
- Review coordinator → Diff processing: configures diff (evidence: `ai_review/services/review/service.py`)
- Review coordinator → LLM selection: selects LLM (evidence: `ai_review/services/review/service.py`)
- Review coordinator → VCS selection: selects VCS (evidence: `ai_review/services/review/service.py`)
- Review coordinator → Comment gateways: configures posting (evidence: `ai_review/services/review/service.py`)
- Review coordinator → Review artifacts: configures artifacts (evidence: `ai_review/services/review/service.py`)
- Review coordinator → Usage accounting: configures accounting (evidence: `ai_review/services/review/service.py`)
- Agent loop → Repository tools: uses tools (evidence: `ai_review/services/agent/loop/service.py`)
- LLM selection → LLM providers: selects provider
- LLM providers → LLM service: sends requests
- VCS selection → VCS adapters: selects adapter
- VCS adapters → Provider API clients: uses API clients (evidence: `ai_review/services/vcs/gitlab/client.py`)
- Provider API clients → Pull request platform: reads and posts
- Comment gateways → VCS adapters: posts feedback
