# cabbagedo/code-review-agent architecture

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

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

## Overview

Code Review Agent accepts a repository and commit range through either CLI or HTTP, stages the repository in a work area, and runs a ReAct review loop. The loop asks DeepSeek to inspect changes and decide which registered tools to call; those tools retrieve diffs, browse and search code, and run lint checks. The final Markdown report and run metrics are displayed by the CLI or returned by the API. The README documents these capabilities; the graph omits the evaluation harness and deployment machinery. Tool interactions are supported by the excerpts, while unsampled behavior is not expanded.

Main entry points: [`src/agent/react.py`](https://github.com/cabbagedo/code-review-agent/blob/main/src/agent/react.py) (ReAct loop), [`src/cli.py`](https://github.com/cabbagedo/code-review-agent/blob/main/src/cli.py) (CLI review), [`src/api/server.py`](https://github.com/cabbagedo/code-review-agent/blob/main/src/api/server.py) (HTTP review), [`src/tools/registry.py`](https://github.com/cabbagedo/code-review-agent/blob/main/src/tools/registry.py) (Default tool setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_cli["CLI review<br/>[cli.py]"]
  node_http["HTTP review<br/>[server.py]"]
end

subgraph group_agent["Review agent"]
  node_react["ReAct loop<br/>[react.py]"]
  node_prompts["Review prompts<br/>[prompts.py]"]
end

subgraph group_tools["Review tools"]
  node_workspace["Repository workspace<br/>[git_tools.py]"]
  node_registry["Tool registry<br/>[base.py]"]
  node_default_tools["Default tool setup<br/>[registry.py]"]
  node_git_tools["Clone, diff, files<br/>[git_tools.py]"]
  node_code_tools["Read, search, lint<br/>[code_tools.py]"]
end

subgraph group_llm["Language model"]
  node_client["DeepSeek client<br/>[llm.py]"]
end

node_reviewer(("Reviewer"))
node_deepseek["DeepSeek API"]

node_reviewer -->|"runs review"| node_cli
node_reviewer -->|"submits review"| node_http
node_cli -->|"stages repository"| node_workspace
node_http -->|"clones repository"| node_workspace
node_cli -->|"creates client"| node_client
node_cli -->|"builds tools"| node_default_tools
node_cli -->|"runs agent"| node_react
node_http -->|"creates client"| node_client
node_http -->|"builds tools"| node_default_tools
node_http -->|"runs agent"| node_react
node_react -->|"builds prompt"| node_prompts
node_react -->|"requests completion"| node_client
node_client -->|"calls API"| node_deepseek
node_react -->|"dispatches calls"| node_registry
node_default_tools -->|"registers tools"| node_registry
node_default_tools -->|"registers tools"| node_git_tools
node_default_tools -->|"registers tools"| node_code_tools
node_registry -->|"dispatches tools"| node_git_tools
node_registry -->|"dispatches tools"| node_code_tools
node_code_tools -->|"uses path guards"| node_git_tools
node_react -->|"returns report and usage"| node_cli
node_react -->|"returns report and usage"| node_http

click node_cli "https://github.com/cabbagedo/code-review-agent/blob/main/src/cli.py"
click node_http "https://github.com/cabbagedo/code-review-agent/blob/main/src/api/server.py"
click node_workspace "https://github.com/cabbagedo/code-review-agent/blob/main/src/tools/git_tools.py"
click node_react "https://github.com/cabbagedo/code-review-agent/blob/main/src/agent/react.py"
click node_prompts "https://github.com/cabbagedo/code-review-agent/blob/main/src/agent/prompts.py"
click node_client "https://github.com/cabbagedo/code-review-agent/blob/main/src/agent/llm.py"
click node_registry "https://github.com/cabbagedo/code-review-agent/blob/main/src/tools/base.py"
click node_default_tools "https://github.com/cabbagedo/code-review-agent/blob/main/src/tools/registry.py"
click node_git_tools "https://github.com/cabbagedo/code-review-agent/blob/main/src/tools/git_tools.py"
click node_code_tools "https://github.com/cabbagedo/code-review-agent/blob/main/src/tools/code_tools.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_http,node_reviewer toneBlue
class node_react,node_prompts toneAmber
class node_workspace,node_registry,node_default_tools,node_git_tools,node_code_tools,node_deepseek toneMint
class node_client toneRose
```

## Components

### Entry points

- [CLI review](https://github.com/cabbagedo/code-review-agent/blob/main/src/cli.py): `src/cli.py`
- [HTTP review](https://github.com/cabbagedo/code-review-agent/blob/main/src/api/server.py): `src/api/server.py`

### Review agent

- [ReAct loop](https://github.com/cabbagedo/code-review-agent/blob/main/src/agent/react.py): `src/agent/react.py`
- [Review prompts](https://github.com/cabbagedo/code-review-agent/blob/main/src/agent/prompts.py): `src/agent/prompts.py`

### Review tools

- [Repository workspace](https://github.com/cabbagedo/code-review-agent/blob/main/src/tools/git_tools.py): `src/tools/git_tools.py`
- [Tool registry](https://github.com/cabbagedo/code-review-agent/blob/main/src/tools/base.py): `src/tools/base.py`
- [Default tool setup](https://github.com/cabbagedo/code-review-agent/blob/main/src/tools/registry.py): `src/tools/registry.py`
- [Clone, diff, files](https://github.com/cabbagedo/code-review-agent/blob/main/src/tools/git_tools.py): `src/tools/git_tools.py`
- [Read, search, lint](https://github.com/cabbagedo/code-review-agent/blob/main/src/tools/code_tools.py): `src/tools/code_tools.py`

### Language model

- [DeepSeek client](https://github.com/cabbagedo/code-review-agent/blob/main/src/agent/llm.py): `src/agent/llm.py`

### Other components

- **Reviewer**
- **DeepSeek API**

## Connections

- Reviewer → CLI review: runs review (evidence: `src/cli.py`)
- Reviewer → HTTP review: submits review (evidence: `src/api/server.py`)
- CLI review → Repository workspace: stages repository (evidence: `src/cli.py`)
- HTTP review → Repository workspace: clones repository (evidence: `src/api/server.py`)
- CLI review → DeepSeek client: creates client (evidence: `src/cli.py`)
- CLI review → Default tool setup: builds tools (evidence: `src/cli.py`)
- CLI review → ReAct loop: runs agent (evidence: `src/cli.py`)
- HTTP review → DeepSeek client: creates client (evidence: `src/api/server.py`)
- HTTP review → Default tool setup: builds tools (evidence: `src/api/server.py`)
- HTTP review → ReAct loop: runs agent (evidence: `src/api/server.py`)
- ReAct loop → Review prompts: builds prompt (evidence: `src/agent/react.py`)
- ReAct loop → DeepSeek client: requests completion (evidence: `src/agent/react.py`)
- DeepSeek client → DeepSeek API: calls API (evidence: `src/agent/llm.py`)
- ReAct loop → Tool registry: dispatches calls (evidence: `src/agent/react.py`)
- Default tool setup → Tool registry: registers tools (evidence: `src/tools/registry.py`)
- Default tool setup → Clone, diff, files: registers tools (evidence: `src/tools/registry.py`)
- Default tool setup → Read, search, lint: registers tools (evidence: `src/tools/registry.py`)
- Tool registry → Clone, diff, files: dispatches tools (evidence: `src/tools/registry.py`)
- Tool registry → Read, search, lint: dispatches tools (evidence: `src/tools/registry.py`)
- Read, search, lint → Clone, diff, files: uses path guards (evidence: `src/tools/code_tools.py`)
- ReAct loop → CLI review: returns report and usage (evidence: `src/cli.py`)
- ReAct loop → HTTP review: returns report and usage (evidence: `src/api/server.py`)
