# shreyas-1403/code-review-agent architecture

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

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

## Overview

Code Review Agent reviews a GitHub pull request against the repository’s numbered conventions, then posts grounded findings as inline comments and a summary. The main workflow parses the PR URL, retrieves metadata, conventions, and diff, converts the diff into structured lines, asks the LLM for validated issues, and publishes the results. The README documents additional safeguards such as retry, anchor validation, dry-run, and idempotency; these are represented within the orchestration and review components. Edges reflect the shown calls and documented relationships; unsampled details are not expanded.

Main entry points: [`main.py`](https://github.com/shreyas-1403/code-review-agent/blob/main/main.py) (Review runner), [`reviewer.py`](https://github.com/shreyas-1403/code-review-agent/blob/main/reviewer.py) (LLM reviewer), [`github_client.py`](https://github.com/shreyas-1403/code-review-agent/blob/main/github_client.py) (PR access), [`diff_parser.py`](https://github.com/shreyas-1403/code-review-agent/blob/main/diff_parser.py) (Diff parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Review orchestration"]
  node_main["Review runner<br/>[main.py]"]
end

subgraph group_inputs["Review inputs"]
  node_conventions["Team conventions"]
  node_diff["PR diff"]
  node_parser["Diff parser<br/>[diff_parser.py]"]
end

subgraph group_engine["Review engine"]
  node_contracts["Review data contracts<br/>[models.py]"]
  node_reviewer["LLM reviewer<br/>[reviewer.py]"]
end

subgraph group_github["GitHub integration"]
  node_github_client["PR access<br/>[github_client.py]"]
  node_inline["Inline comments<br/>[github_client.py]"]
  node_summary["Summary comment<br/>[github_client.py]"]
end

node_user(("Reviewer"))
node_groq["Groq LLM"]
node_github_api["GitHub API"]

node_user -->|"submits PR URL"| node_main
node_main -->|"loads PR"| node_github_client
node_github_client -->|"requests PR data"| node_github_api
node_main -->|"fetches diff"| node_diff
node_main -->|"loads conventions"| node_conventions
node_github_client -->|"fetches conventions"| node_github_api
node_main -->|"parses diff"| node_parser
node_parser -->|"creates diff records"| node_contracts
node_main -->|"requests review"| node_reviewer
node_reviewer -->|"consumes diff records"| node_contracts
node_reviewer -->|"sends prompt"| node_groq
node_main -->|"posts findings"| node_inline
node_inline -->|"creates review"| node_github_api
node_main -->|"posts summary"| node_summary
node_summary -->|"creates issue comment"| node_github_api

click node_main "https://github.com/shreyas-1403/code-review-agent/blob/main/main.py"
click node_parser "https://github.com/shreyas-1403/code-review-agent/blob/main/diff_parser.py"
click node_contracts "https://github.com/shreyas-1403/code-review-agent/blob/main/models.py"
click node_reviewer "https://github.com/shreyas-1403/code-review-agent/blob/main/reviewer.py"
click node_github_client "https://github.com/shreyas-1403/code-review-agent/blob/main/github_client.py"
click node_inline "https://github.com/shreyas-1403/code-review-agent/blob/main/github_client.py"
click node_summary "https://github.com/shreyas-1403/code-review-agent/blob/main/github_client.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_main,node_user toneBlue
class node_conventions,node_diff,node_parser toneAmber
class node_contracts,node_reviewer,node_github_api toneMint
class node_github_client,node_inline,node_summary toneRose
class node_groq toneIndigo
```

## Components

### Review orchestration

- [Review runner](https://github.com/shreyas-1403/code-review-agent/blob/main/main.py): `main.py`

### Review inputs

- **Team conventions**
- **PR diff**
- [Diff parser](https://github.com/shreyas-1403/code-review-agent/blob/main/diff_parser.py): `diff_parser.py`

### Review engine

- [Review data contracts](https://github.com/shreyas-1403/code-review-agent/blob/main/models.py): `models.py`
- [LLM reviewer](https://github.com/shreyas-1403/code-review-agent/blob/main/reviewer.py): `reviewer.py`

### GitHub integration

- [PR access](https://github.com/shreyas-1403/code-review-agent/blob/main/github_client.py): `github_client.py`
- [Inline comments](https://github.com/shreyas-1403/code-review-agent/blob/main/github_client.py): `github_client.py`
- [Summary comment](https://github.com/shreyas-1403/code-review-agent/blob/main/github_client.py): `github_client.py`

### Other components

- **Reviewer**
- **Groq LLM**
- **GitHub API**

## Connections

- Reviewer → Review runner: submits PR URL (evidence: `README.md`)
- Review runner → PR access: loads PR (evidence: `main.py`)
- PR access → GitHub API: requests PR data (evidence: `github_client.py`)
- Review runner → PR diff: fetches diff (evidence: `main.py`)
- Review runner → Team conventions: loads conventions (evidence: `main.py`)
- PR access → GitHub API: fetches conventions (evidence: `github_client.py`)
- Review runner → Diff parser: parses diff (evidence: `main.py`)
- Diff parser → Review data contracts: creates diff records (evidence: `diff_parser.py`)
- Review runner → LLM reviewer: requests review (evidence: `main.py`)
- LLM reviewer → Review data contracts: consumes diff records (evidence: `reviewer.py`)
- LLM reviewer → Groq LLM: sends prompt (evidence: `reviewer.py`)
- Review runner → Inline comments: posts findings (evidence: `main.py`)
- Inline comments → GitHub API: creates review (evidence: `github_client.py`)
- Review runner → Summary comment: posts summary (evidence: `main.py`)
- Summary comment → GitHub API: creates issue comment (evidence: `github_client.py`)
