# pruthvi-y/smart-pr-review-workflow architecture

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

- Interactive diagram: https://gitdiagram.com/pruthvi-y/smart-pr-review-workflow
- Repository: https://github.com/pruthvi-y/smart-pr-review-workflow

## Overview

This is a LangGraph learning POC that turns a mock or GitHub pull request into an evidence-grounded review and can optionally post a comment. Its main workflow loads the PR, classifies and routes it, retrieves policy context, fans out specialist checks, drafts and evaluates the review, revises when needed, then finalizes and optionally posts. The README documents both MCP and direct REST GitHub modes. The graph reflects documented workflow structure and shown module references; some load and routing implementation details were omitted from the excerpts.

Main entry points: [`src/smart_pr_review_workflow/model.py`](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/model.py) (Model adapter), [`src/smart_pr_review_workflow/nodes.py`](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py) (Evaluate draft), [`src/smart_pr_review_workflow/rag.py`](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/rag.py) (RAG index and retrieval), [`src/smart_pr_review_workflow/tools/github.py`](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/tools/github.py) (GitHub REST client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Review workflow"]
  node_entry["CLI runner<br/>[main.py]"]
  node_graph["LangGraph workflow<br/>[workflow.py]"]
  node_load["Load PR<br/>[nodes.py]"]
  node_post["Post review<br/>[nodes.py]"]
  node_state["Review state<br/>[state.py]"]
end

subgraph group_analysis["Review analysis"]
  node_classify["Classify change<br/>[nodes.py]"]
  node_select["Select checks<br/>[nodes.py]"]
  node_fanout["Parallel dispatch<br/>[nodes.py]"]
  node_checks["Specialist checks<br/>[nodes.py]"]
  node_draft["Generate draft<br/>[nodes.py]"]
  node_evaluate["Evaluate draft<br/>[nodes.py]"]
  node_revise["Revise draft<br/>[nodes.py]"]
  node_finalize["Finalize review<br/>[nodes.py]"]
end

subgraph group_integrations["Models and GitHub"]
  node_bedrock["Amazon Bedrock"]
  node_model["Model adapter<br/>[model.py]"]
  node_github["GitHub REST API"]
  node_restclient["GitHub REST client<br/>[github.py]"]
  node_mcpclient["MCP GitHub client<br/>[client.py]"]
  node_mcpserver["MCP server tools<br/>[server.py]"]
end

subgraph group_knowledge["Policy knowledge"]
  node_retrieve["Retrieve policy<br/>[nodes.py]"]
  node_rag["RAG index and retrieval<br/>[rag.py]"]
  node_policies["Policy documents"]
  node_vectorstore[("Local vector store<br/>[rag.py]")]
end

node_reviewer(("Review operator"))

node_reviewer -->|"runs"| node_entry
node_entry -->|"builds and streams"| node_graph
node_entry -->|"builds index"| node_rag
node_graph -->|"starts at"| node_load
node_load -->|"routes to"| node_classify
node_classify -->|"routes to"| node_select
node_select -->|"routes to"| node_retrieve
node_retrieve -->|"dispatches checks"| node_fanout
node_fanout -->|"sends tasks"| node_checks
node_checks -->|"routes results"| node_draft
node_draft -->|"routes draft"| node_evaluate
node_evaluate -->|"routes for revision"| node_revise
node_revise -->|"reevaluates"| node_evaluate
node_evaluate -->|"routes accepted draft"| node_finalize
node_finalize -->|"routes final review"| node_post
node_load -->|"loads PR via MCP"| node_mcpclient
node_mcpclient -->|"calls tools"| node_mcpserver
node_mcpserver -->|"delegates GitHub calls"| node_restclient
node_restclient -->|"requests PR data"| node_github
node_post -->|"posts comment via MCP"| node_mcpclient
node_post -.->|"posts comment via REST"| node_restclient
node_load -.->|"loads PR via REST"| node_restclient
node_retrieve -->|"retrieves context"| node_rag
node_rag -->|"loads documents"| node_policies
node_rag -->|"indexes and searches"| node_vectorstore
node_classify -->|"requests classification"| node_model
node_checks -->|"requests analyses"| node_model
node_draft -->|"requests draft"| node_model
node_evaluate -->|"requests evaluation"| node_model
node_revise -->|"requests revision"| node_model
node_model -->|"invokes model"| node_bedrock

click node_entry "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/main.py"
click node_graph "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/workflow.py"
click node_load "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py"
click node_classify "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py"
click node_select "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py"
click node_retrieve "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py"
click node_fanout "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py"
click node_checks "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py"
click node_draft "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py"
click node_evaluate "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py"
click node_revise "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py"
click node_finalize "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py"
click node_post "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py"
click node_state "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/state.py"
click node_model "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/model.py"
click node_rag "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/rag.py"
click node_policies "https://github.com/pruthvi-y/smart-pr-review-workflow/tree/main/knowledge"
click node_vectorstore "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/rag.py"
click node_restclient "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/tools/github.py"
click node_mcpclient "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/mcp/client.py"
click node_mcpserver "https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/mcp/server.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_entry,node_graph,node_load,node_post,node_state,node_reviewer toneBlue
class node_classify,node_select,node_fanout,node_checks,node_draft,node_evaluate,node_revise,node_finalize toneAmber
class node_bedrock,node_model,node_github,node_restclient,node_mcpclient,node_mcpserver toneMint
class node_retrieve,node_rag,node_policies,node_vectorstore toneRose
```

## Components

### Review workflow

- [CLI runner](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/main.py): `src/smart_pr_review_workflow/main.py`
- [LangGraph workflow](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/workflow.py): `src/smart_pr_review_workflow/workflow.py`
- [Load PR](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py): `src/smart_pr_review_workflow/nodes.py`
- [Post review](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py): `src/smart_pr_review_workflow/nodes.py`
- [Review state](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/state.py): `src/smart_pr_review_workflow/state.py`

### Review analysis

- [Classify change](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py): `src/smart_pr_review_workflow/nodes.py`
- [Select checks](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py): `src/smart_pr_review_workflow/nodes.py`
- [Parallel dispatch](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py): `src/smart_pr_review_workflow/nodes.py`
- [Specialist checks](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py): `src/smart_pr_review_workflow/nodes.py`
- [Generate draft](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py): `src/smart_pr_review_workflow/nodes.py`
- [Evaluate draft](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py): `src/smart_pr_review_workflow/nodes.py`
- [Revise draft](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py): `src/smart_pr_review_workflow/nodes.py`
- [Finalize review](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py): `src/smart_pr_review_workflow/nodes.py`

### Models and GitHub

- **Amazon Bedrock**
- [Model adapter](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/model.py): `src/smart_pr_review_workflow/model.py`
- **GitHub REST API**
- [GitHub REST client](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/tools/github.py): `src/smart_pr_review_workflow/tools/github.py`
- [MCP GitHub client](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/mcp/client.py): `src/smart_pr_review_workflow/mcp/client.py`
- [MCP server tools](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/mcp/server.py): `src/smart_pr_review_workflow/mcp/server.py`

### Policy knowledge

- [Retrieve policy](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/nodes.py): `src/smart_pr_review_workflow/nodes.py`
- [RAG index and retrieval](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/rag.py): `src/smart_pr_review_workflow/rag.py`
- [Policy documents](https://github.com/pruthvi-y/smart-pr-review-workflow/tree/main/knowledge): `knowledge`
- [Local vector store](https://github.com/pruthvi-y/smart-pr-review-workflow/blob/main/src/smart_pr_review_workflow/rag.py): `src/smart_pr_review_workflow/rag.py`

### Other components

- **Review operator**

## Connections

- Review operator → CLI runner: runs (evidence: `README.md`)
- CLI runner → LangGraph workflow: builds and streams (evidence: `src/smart_pr_review_workflow/main.py`)
- CLI runner → RAG index and retrieval: builds index (evidence: `src/smart_pr_review_workflow/main.py`)
- LangGraph workflow → Load PR: starts at (evidence: `src/smart_pr_review_workflow/workflow.py`)
- Load PR → Classify change: routes to (evidence: `src/smart_pr_review_workflow/workflow.py`)
- Classify change → Select checks: routes to (evidence: `src/smart_pr_review_workflow/workflow.py`)
- Select checks → Retrieve policy: routes to (evidence: `src/smart_pr_review_workflow/workflow.py`)
- Retrieve policy → Parallel dispatch: dispatches checks (evidence: `src/smart_pr_review_workflow/workflow.py`)
- Parallel dispatch → Specialist checks: sends tasks (evidence: `src/smart_pr_review_workflow/workflow.py`)
- Specialist checks → Generate draft: routes results (evidence: `src/smart_pr_review_workflow/workflow.py`)
- Generate draft → Evaluate draft: routes draft (evidence: `src/smart_pr_review_workflow/workflow.py`)
- Evaluate draft → Revise draft: routes for revision (evidence: `src/smart_pr_review_workflow/nodes.py`)
- Revise draft → Evaluate draft: reevaluates (evidence: `src/smart_pr_review_workflow/workflow.py`)
- Evaluate draft → Finalize review: routes accepted draft (evidence: `src/smart_pr_review_workflow/nodes.py`)
- Finalize review → Post review: routes final review (evidence: `src/smart_pr_review_workflow/workflow.py`)
- Load PR → MCP GitHub client: loads PR via MCP (evidence: `README.md`)
- MCP GitHub client → MCP server tools: calls tools (evidence: `README.md`)
- MCP server tools → GitHub REST client: delegates GitHub calls (evidence: `src/smart_pr_review_workflow/mcp/server.py`)
- GitHub REST client → GitHub REST API: requests PR data (evidence: `src/smart_pr_review_workflow/tools/github.py`)
- Post review → MCP GitHub client: posts comment via MCP (evidence: `README.md`)
- Post review → GitHub REST client: posts comment via REST (evidence: `README.md`)
- Load PR → GitHub REST client: loads PR via REST (evidence: `README.md`)
- Retrieve policy → RAG index and retrieval: retrieves context (evidence: `src/smart_pr_review_workflow/nodes.py`)
- RAG index and retrieval → Policy documents: loads documents (evidence: `src/smart_pr_review_workflow/rag.py`)
- RAG index and retrieval → Local vector store: indexes and searches (evidence: `src/smart_pr_review_workflow/rag.py`)
- Classify change → Model adapter: requests classification (evidence: `src/smart_pr_review_workflow/nodes.py`)
- Specialist checks → Model adapter: requests analyses (evidence: `src/smart_pr_review_workflow/nodes.py`)
- Generate draft → Model adapter: requests draft (evidence: `src/smart_pr_review_workflow/nodes.py`)
- Evaluate draft → Model adapter: requests evaluation (evidence: `src/smart_pr_review_workflow/nodes.py`)
- Revise draft → Model adapter: requests revision (evidence: `src/smart_pr_review_workflow/nodes.py`)
- Model adapter → Amazon Bedrock: invokes model (evidence: `src/smart_pr_review_workflow/model.py`)
