# dhanashreernerkar/code-review-agent architecture

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

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

## Overview

code-review-agent reviews local or CI diffs through a LangGraph workflow: ingest and classify changed files, fan out skill-specific LLM reviews, aggregate findings, then publish through configured reporters. The README documents language and optional CI/infra skills, provider selection, and multiple output targets. Sampled source confirms graph routing, ingest, skill loading, prompting, provider construction, and reporter dispatch; unsampled detection, aggregation, and report-node internals are represented only where supported by documented workflow and paths.

Main entry points: [`src/code_review_agent/agent.py`](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/agent.py) (LangGraph agent), [`src/code_review_agent/reporters/registry.py`](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/reporters/registry.py) (Reporter dispatch), [`src/code_review_agent/utils/node_review.py`](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/utils/node_review.py) (Review execution), [`src/code_review_agent/cli.py`](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/cli.py) (CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Invocation"]
  node_cli["CLI<br/>[cli.py]"]
end

subgraph group_review["Review workflow"]
  node_graph["LangGraph agent<br/>[agent.py]"]
  node_ingest["Diff ingestion<br/>[node_ingest.py]"]
  node_diffing["Diff parsing<br/>[diffing.py]"]
  node_detection["File detection<br/>[node_detect.py]"]
  node_state["Review state<br/>[state.py]"]
  node_review_node["Review execution<br/>[node_review.py]"]
  node_prompts["Prompt assembly<br/>[prompts.py]"]
  node_llm_factory["LLM factory<br/>[llm.py]"]
  node_aggregate["Finding aggregation<br/>[node_aggregate.py]"]
end

subgraph group_knowledge["Review knowledge"]
  node_skill_loader["Skill registry<br/>[loader.py]"]
  node_skill_packs["Skill packs"]
end

subgraph group_publishing["Reporting"]
  node_report_node["Report preparation<br/>[node_report.py]"]
  node_registry["Reporter dispatch<br/>[registry.py]"]
  node_terminal["Terminal output<br/>[terminal.py]"]
  node_file["File reports<br/>[file.py]"]
  node_github["GitHub reporter<br/>[github.py]"]
  node_gitlab["GitLab reporter<br/>[gitlab.py]"]
end

node_operator(("Engineer or CI"))
node_diff["Diff source"]
node_llm_services{{"LLM providers"}}
node_github_api{{"GitHub API"}}
node_gitlab_api{{"GitLab API"}}

node_operator -->|"invokes"| node_cli
node_operator -->|"supplies"| node_diff
node_cli -->|"reads diff"| node_diff
node_cli -->|"invokes"| node_graph
node_graph -->|"dispatches"| node_ingest
node_ingest -->|"parses diff"| node_diffing
node_ingest -->|"produces files"| node_state
node_graph -->|"dispatches"| node_detection
node_detection -->|"resolves skill"| node_skill_loader
node_skill_loader -->|"reads"| node_skill_packs
node_graph -->|"fans out"| node_review_node
node_review_node -->|"builds prompts"| node_prompts
node_review_node -->|"loads skill body"| node_skill_loader
node_review_node -->|"requests model"| node_llm_factory
node_llm_factory -->|"constructs client"| node_llm_services
node_graph -->|"dispatches"| node_aggregate
node_graph -->|"dispatches"| node_report_node
node_report_node -->|"selects reporters"| node_registry
node_registry -->|"dispatches"| node_terminal
node_registry -->|"dispatches"| node_file
node_registry -->|"dispatches"| node_github
node_registry -->|"dispatches"| node_gitlab
node_github -->|"publishes comment"| node_github_api
node_gitlab -->|"publishes note"| node_gitlab_api

click node_cli "https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/cli.py"
click node_graph "https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/agent.py"
click node_ingest "https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/utils/node_ingest.py"
click node_diffing "https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/utils/diffing.py"
click node_detection "https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/utils/node_detect.py"
click node_state "https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/utils/state.py"
click node_skill_loader "https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/skills/loader.py"
click node_skill_packs "https://github.com/dhanashreernerkar/code-review-agent/tree/main/skills"
click node_review_node "https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/utils/node_review.py"
click node_prompts "https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/utils/prompts.py"
click node_llm_factory "https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/llm.py"
click node_aggregate "https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/utils/node_aggregate.py"
click node_report_node "https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/utils/node_report.py"
click node_registry "https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/reporters/registry.py"
click node_terminal "https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/reporters/terminal.py"
click node_file "https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/reporters/file.py"
click node_github "https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/reporters/github.py"
click node_gitlab "https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/reporters/gitlab.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 toneBlue
class node_graph,node_ingest,node_diffing,node_detection,node_state,node_review_node,node_prompts,node_llm_factory,node_aggregate toneAmber
class node_skill_loader,node_skill_packs,node_github_api,node_gitlab_api toneMint
class node_report_node,node_registry,node_terminal,node_file,node_github,node_gitlab toneRose
class node_operator,node_diff,node_llm_services toneIndigo
```

## Components

### Invocation

- [CLI](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/cli.py): `src/code_review_agent/cli.py`

### Review workflow

- [LangGraph agent](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/agent.py): `src/code_review_agent/agent.py`
- [Diff ingestion](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/utils/node_ingest.py): `src/code_review_agent/utils/node_ingest.py`
- [Diff parsing](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/utils/diffing.py): `src/code_review_agent/utils/diffing.py`
- [File detection](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/utils/node_detect.py): `src/code_review_agent/utils/node_detect.py`
- [Review state](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/utils/state.py): `src/code_review_agent/utils/state.py`
- [Review execution](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/utils/node_review.py): `src/code_review_agent/utils/node_review.py`
- [Prompt assembly](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/utils/prompts.py): `src/code_review_agent/utils/prompts.py`
- [LLM factory](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/llm.py): `src/code_review_agent/llm.py`
- [Finding aggregation](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/utils/node_aggregate.py): `src/code_review_agent/utils/node_aggregate.py`

### Review knowledge

- [Skill registry](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/skills/loader.py): `src/code_review_agent/skills/loader.py`
- [Skill packs](https://github.com/dhanashreernerkar/code-review-agent/tree/main/skills): `skills`

### Reporting

- [Report preparation](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/utils/node_report.py): `src/code_review_agent/utils/node_report.py`
- [Reporter dispatch](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/reporters/registry.py): `src/code_review_agent/reporters/registry.py`
- [Terminal output](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/reporters/terminal.py): `src/code_review_agent/reporters/terminal.py`
- [File reports](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/reporters/file.py): `src/code_review_agent/reporters/file.py`
- [GitHub reporter](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/reporters/github.py): `src/code_review_agent/reporters/github.py`
- [GitLab reporter](https://github.com/dhanashreernerkar/code-review-agent/blob/main/src/code_review_agent/reporters/gitlab.py): `src/code_review_agent/reporters/gitlab.py`

### Other components

- **Engineer or CI**
- **Diff source**
- **LLM providers**
- **GitHub API**
- **GitLab API**

## Connections

- Engineer or CI → CLI: invokes
- Engineer or CI → Diff source: supplies
- CLI → Diff source: reads diff
- CLI → LangGraph agent: invokes
- LangGraph agent → Diff ingestion: dispatches
- Diff ingestion → Diff parsing: parses diff
- Diff ingestion → Review state: produces files
- LangGraph agent → File detection: dispatches
- File detection → Skill registry: resolves skill
- Skill registry → Skill packs: reads
- LangGraph agent → Review execution: fans out
- Review execution → Prompt assembly: builds prompts
- Review execution → Skill registry: loads skill body
- Review execution → LLM factory: requests model
- LLM factory → LLM providers: constructs client
- LangGraph agent → Finding aggregation: dispatches
- LangGraph agent → Report preparation: dispatches
- Report preparation → Reporter dispatch: selects reporters
- Reporter dispatch → Terminal output: dispatches
- Reporter dispatch → File reports: dispatches
- Reporter dispatch → GitHub reporter: dispatches
- Reporter dispatch → GitLab reporter: dispatches
- GitHub reporter → GitHub API: publishes comment
- GitLab reporter → GitLab API: publishes note
