# tirth8205/code-review-graph architecture

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

- Interactive diagram: https://gitdiagram.com/tirth8205/code-review-graph
- Repository: https://github.com/tirth8205/code-review-graph

## Overview

code-review-graph builds and incrementally maintains a local code knowledge graph, then serves compact search and review context to AI tools over MCP. The main workflow is repository changes → parsing and graph updates → graph-backed queries and review context → AI assistant. The VS Code extension provides a separate UI over the graph database and Python backend. Major documented capabilities include semantic search, impact analysis, flows, communities, and integration setup. Some subsystem links are based on README or SOURCE INDEX references; unsampled implementation details are not inferred.

Main entry points: [`code_review_graph/main.py`](https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/main.py) (CLI commands), [`code_review_graph/graph.py`](https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/graph.py) (Graph database), [`code-review-graph-vscode/src/extension.ts`](https://github.com/tirth8205/code-review-graph/blob/staging/code-review-graph-vscode/src/extension.ts) (VS Code extension), [`code_review_graph/incremental.py`](https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/incremental.py) (Incremental updater)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_build["Graph construction"]
  node_incremental["Incremental updater<br/>[incremental.py]"]
  node_parser["Code parser<br/>[parser.py]"]
end

subgraph group_storage["Graph and indexing"]
  node_graphstore[("Graph database<br/>[graph.py]")]
  node_migrations["Schema migrations<br/>[migrations.py]"]
  node_search["Hybrid search<br/>[search.py]"]
  node_embeddings["Semantic embeddings<br/>[embeddings.py]"]
  node_flows["Flow analysis<br/>[flows.py]"]
  node_communities["Community analysis<br/>[communities.py]"]
end

subgraph group_context["Context tools"]
  node_review["Change review context<br/>[review.py]"]
  node_query["Graph queries<br/>[query.py]"]
  node_toolcommon["Tool utilities<br/>[_common.py]"]
  node_history["Context history<br/>[context_history.py]"]
end

subgraph group_integrations["Tool integrations"]
  node_cli["CLI commands<br/>[main.py]"]
  node_mcp["MCP server<br/>[main.py]"]
  node_installer["Platform installer<br/>[install_plan.py]"]
end

subgraph group_vscode["VS Code extension"]
  node_vscode["VS Code extension<br/>[extension.ts]"]
  node_vscodebackend["Python backend bridge<br/>[cli.ts]"]
  node_vscdb["Read-only DB access<br/>[sqlite.ts]"]
  node_vscviews["Graph and tree views<br/>[graphWebview.ts]"]
  node_vscsearch["Extension search<br/>[search.ts]"]
  node_vscreview["Extension review<br/>[reviewAssistant.ts]"]
end

node_developer(("Developer"))
node_assistant(("AI coding tool"))
node_repository["Code repository"]

node_developer -->|"runs commands"| node_cli
node_cli -->|"builds or updates"| node_incremental
node_repository -->|"provides source"| node_incremental
node_incremental -->|"parses files"| node_parser
node_incremental -->|"updates graph"| node_graphstore
node_graphstore -->|"uses parsing"| node_parser
node_graphstore -->|"applies schema"| node_migrations
node_search -->|"queries graph"| node_graphstore
node_search -->|"uses vectors"| node_embeddings
node_cli -->|"serves tools"| node_mcp
node_mcp -->|"dispatches queries"| node_query
node_mcp -->|"dispatches review"| node_review
node_query -->|"uses utilities"| node_toolcommon
node_review -->|"uses utilities"| node_toolcommon
node_review -->|"reads impact"| node_graphstore
node_assistant -->|"requests context"| node_mcp
node_developer -->|"configures tools"| node_installer
node_cli -->|"builds flow data"| node_flows
node_cli -->|"builds communities"| node_communities
node_vscode -->|"invokes backend"| node_vscodebackend
node_vscode -->|"opens graph data"| node_vscdb
node_vscode -->|"registers views"| node_vscviews
node_vscviews -->|"reads graph"| node_vscdb
node_vscsearch -->|"queries database"| node_vscdb
node_vscreview -->|"queries database"| node_vscdb
node_vscode -->|"offers onboarding"| node_installer
node_mcp -.->|"records savings"| node_history

click node_cli "https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/main.py"
click node_mcp "https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/main.py"
click node_installer "https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/install_plan.py"
click node_incremental "https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/incremental.py"
click node_parser "https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/parser.py"
click node_graphstore "https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/graph.py"
click node_migrations "https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/migrations.py"
click node_search "https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/search.py"
click node_embeddings "https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/embeddings.py"
click node_flows "https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/flows.py"
click node_communities "https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/communities.py"
click node_review "https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/tools/review.py"
click node_query "https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/tools/query.py"
click node_toolcommon "https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/tools/_common.py"
click node_history "https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/context_history.py"
click node_vscode "https://github.com/tirth8205/code-review-graph/blob/staging/code-review-graph-vscode/src/extension.ts"
click node_vscodebackend "https://github.com/tirth8205/code-review-graph/blob/staging/code-review-graph-vscode/src/backend/cli.ts"
click node_vscdb "https://github.com/tirth8205/code-review-graph/blob/staging/code-review-graph-vscode/src/backend/sqlite.ts"
click node_vscviews "https://github.com/tirth8205/code-review-graph/blob/staging/code-review-graph-vscode/src/views/graphWebview.ts"
click node_vscsearch "https://github.com/tirth8205/code-review-graph/blob/staging/code-review-graph-vscode/src/features/search.ts"
click node_vscreview "https://github.com/tirth8205/code-review-graph/blob/staging/code-review-graph-vscode/src/features/reviewAssistant.ts"

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_incremental,node_parser toneBlue
class node_graphstore,node_migrations,node_search,node_embeddings,node_flows,node_communities toneAmber
class node_review,node_query,node_toolcommon,node_history toneMint
class node_cli,node_mcp,node_installer toneRose
class node_vscode,node_vscodebackend,node_vscdb,node_vscviews,node_vscsearch,node_vscreview,node_developer,node_assistant,node_repository toneIndigo
```

## Components

### Graph construction

- [Incremental updater](https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/incremental.py): `code_review_graph/incremental.py`
- [Code parser](https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/parser.py): `code_review_graph/parser.py`

### Graph and indexing

- [Graph database](https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/graph.py): `code_review_graph/graph.py`
- [Schema migrations](https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/migrations.py): `code_review_graph/migrations.py`
- [Hybrid search](https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/search.py): `code_review_graph/search.py`
- [Semantic embeddings](https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/embeddings.py): `code_review_graph/embeddings.py`
- [Flow analysis](https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/flows.py): `code_review_graph/flows.py`
- [Community analysis](https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/communities.py): `code_review_graph/communities.py`

### Context tools

- [Change review context](https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/tools/review.py): `code_review_graph/tools/review.py`
- [Graph queries](https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/tools/query.py): `code_review_graph/tools/query.py`
- [Tool utilities](https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/tools/_common.py): `code_review_graph/tools/_common.py`
- [Context history](https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/context_history.py): `code_review_graph/context_history.py`

### Tool integrations

- [CLI commands](https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/main.py): `code_review_graph/main.py`
- [MCP server](https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/main.py): `code_review_graph/main.py`
- [Platform installer](https://github.com/tirth8205/code-review-graph/blob/staging/code_review_graph/install_plan.py): `code_review_graph/install_plan.py`

### VS Code extension

- [VS Code extension](https://github.com/tirth8205/code-review-graph/blob/staging/code-review-graph-vscode/src/extension.ts): `code-review-graph-vscode/src/extension.ts`
- [Python backend bridge](https://github.com/tirth8205/code-review-graph/blob/staging/code-review-graph-vscode/src/backend/cli.ts): `code-review-graph-vscode/src/backend/cli.ts`
- [Read-only DB access](https://github.com/tirth8205/code-review-graph/blob/staging/code-review-graph-vscode/src/backend/sqlite.ts): `code-review-graph-vscode/src/backend/sqlite.ts`
- [Graph and tree views](https://github.com/tirth8205/code-review-graph/blob/staging/code-review-graph-vscode/src/views/graphWebview.ts): `code-review-graph-vscode/src/views/graphWebview.ts`
- [Extension search](https://github.com/tirth8205/code-review-graph/blob/staging/code-review-graph-vscode/src/features/search.ts): `code-review-graph-vscode/src/features/search.ts`
- [Extension review](https://github.com/tirth8205/code-review-graph/blob/staging/code-review-graph-vscode/src/features/reviewAssistant.ts): `code-review-graph-vscode/src/features/reviewAssistant.ts`

### Other components

- **Developer**
- **AI coding tool**
- **Code repository**

## Connections

- Developer → CLI commands: runs commands (evidence: `README.md`)
- CLI commands → Incremental updater: builds or updates (evidence: `code_review_graph/main.py`)
- Code repository → Incremental updater: provides source (evidence: `README.md`)
- Incremental updater → Code parser: parses files (evidence: `code_review_graph/incremental.py`)
- Incremental updater → Graph database: updates graph (evidence: `code_review_graph/incremental.py`)
- Graph database → Code parser: uses parsing (evidence: `code_review_graph/graph.py`)
- Graph database → Schema migrations: applies schema (evidence: `code_review_graph/graph.py`)
- Hybrid search → Graph database: queries graph (evidence: `code_review_graph/search.py`)
- Hybrid search → Semantic embeddings: uses vectors (evidence: `code_review_graph/search.py`)
- CLI commands → MCP server: serves tools (evidence: `code_review_graph/main.py`)
- MCP server → Graph queries: dispatches queries (evidence: `code_review_graph/main.py`)
- MCP server → Change review context: dispatches review (evidence: `code_review_graph/main.py`)
- Graph queries → Tool utilities: uses utilities (evidence: `code_review_graph/tools/query.py`)
- Change review context → Tool utilities: uses utilities (evidence: `code_review_graph/tools/review.py`)
- Change review context → Graph database: reads impact (evidence: `code_review_graph/tools/review.py`)
- AI coding tool → MCP server: requests context (evidence: `README.md`)
- Developer → Platform installer: configures tools (evidence: `README.md`)
- CLI commands → Flow analysis: builds flow data
- CLI commands → Community analysis: builds communities
- VS Code extension → Python backend bridge: invokes backend (evidence: `code-review-graph-vscode/src/extension.ts`)
- VS Code extension → Read-only DB access: opens graph data (evidence: `code-review-graph-vscode/src/extension.ts`)
- VS Code extension → Graph and tree views: registers views (evidence: `code-review-graph-vscode/src/extension.ts`)
- Graph and tree views → Read-only DB access: reads graph (evidence: `code-review-graph-vscode/src/views/graphWebview.ts`)
- Extension search → Read-only DB access: queries database (evidence: `code-review-graph-vscode/src/features/search.ts`)
- Extension review → Read-only DB access: queries database (evidence: `code-review-graph-vscode/src/features/reviewAssistant.ts`)
- VS Code extension → Platform installer: offers onboarding (evidence: `code-review-graph-vscode/src/extension.ts`)
- MCP server → Context history: records savings
