# sakthimurugan03/patchcourt architecture

> Architecture diagram of the GitHub repository sakthimurugan03/patchcourt, 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/sakthimurugan03/patchcourt
- Repository: https://github.com/sakthimurugan03/patchcourt

## Overview

PatchCourt reviews GitHub pull requests and returns an evidence-tiered report and verdict. The principal workflow accepts a PR through the CLI, API, or webhook, fetches PR context, gathers retrieved and static-analysis evidence, runs specialist agents in parallel, resolves conflicts through bounded debate, and scores the result. The dashboard presents reports and related evidence; separate capabilities provide SonarQube baseline/live views and audit history. README statements support several product-level links; unsampled implementation details and UI wiring are not inferred.

Main entry points: [`patchcourt/graph.py`](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/graph.py) (Review graph), [`patchcourt/api/app.py`](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/api/app.py) (REST API), [`dashboard/src/lib/api.ts`](https://github.com/sakthimurugan03/patchcourt/blob/main/dashboard/src/lib/api.ts) (Dashboard API client), [`patchcourt/worker/tasks.py`](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/worker/tasks.py) (Celery worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Review entry points"]
  node_cli["Review CLI<br/>[cli.py]"]
  node_api["REST API<br/>[app.py]"]
  node_webhook["GitHub webhook<br/>[webhook.py]"]
  node_worker["Celery worker<br/>[tasks.py]"]
end

subgraph group_pipeline["Review pipeline"]
  node_ingest["PR ingestion<br/>[github.py]"]
  node_orchestrator["Review graph<br/>[graph.py]"]
  node_agents["Specialist agents"]
  node_conflicts["Conflict detection<br/>[conflict.py]"]
  node_debate["Bounded debate<br/>[debate.py]"]
  node_judge["Scoring and verdict<br/>[scoring.py]"]
  node_schemas["Review data models<br/>[schemas.py]"]
end

subgraph group_evidence["Evidence and analysis"]
  node_rag[("Repository retrieval<br/>[store.py]")]
  node_evidence_engine["Evidence engine<br/>[evidence.py]"]
  node_tools["Static analysis tools"]
  node_sandbox["Isolated scanner<br/>[runner.py]"]
  node_llm["LLM client<br/>[llm.py]"]
  node_sonar_baseline["Sonar baseline"]
  node_sonar_live["Sonar live queries<br/>[sonar_live.py]"]
end

subgraph group_operations["Persistence and integrations"]
  node_audit[("Audit storage<br/>[audit.py]")]
  node_redis["Redis queue"]
  node_postgres[("PostgreSQL")]
  node_llm_config["Runtime LLM settings"]
end

subgraph group_dashboard["Dashboard"]
  node_dashboard["Review dashboard<br/>[page.tsx]"]
  node_dashboard_api["Dashboard API client<br/>[api.ts]"]
  node_dashboard_views["Evidence and review views<br/>[page.tsx]"]
  node_baseline_view["Baseline view"]
  node_live_view["Sonar live view"]
end

node_github(("GitHub PR"))

node_github -->|"submits PR"| node_api
node_github -->|"sends events"| node_webhook
node_cli -->|"runs review"| node_orchestrator
node_dashboard -->|"requests review"| node_api
node_api -->|"runs review"| node_orchestrator
node_webhook -->|"enqueues task"| node_worker
node_worker -->|"runs review"| node_orchestrator
node_worker -->|"uses broker"| node_redis
node_orchestrator -->|"fetches PR"| node_ingest
node_orchestrator -->|"indexes and queries"| node_rag
node_orchestrator -->|"analyzes files"| node_evidence_engine
node_orchestrator -->|"runs in parallel"| node_agents
node_orchestrator -->|"detects conflicts"| node_conflicts
node_orchestrator -->|"runs if needed"| node_debate
node_orchestrator -->|"builds report"| node_judge
node_orchestrator -->|"persists report"| node_audit
node_evidence_engine -->|"runs scanners"| node_tools
node_orchestrator -->|"runs isolated scans"| node_sandbox
node_sandbox -->|"dispatches scans"| node_tools
node_agents -->|"requests claims"| node_llm
node_debate -->|"requests rebuttals"| node_llm
node_debate -->|"retrieves fresh evidence"| node_rag
node_judge -->|"produces report"| node_schemas
node_audit -->|"stores audit trail"| node_postgres
node_api -->|"serves baseline"| node_sonar_baseline
node_api -->|"serves live queries"| node_sonar_live
node_api -->|"updates settings"| node_llm_config
node_llm_config -->|"resets client"| node_llm
node_dashboard -.->|"requests data"| node_dashboard_api
node_dashboard_views -.->|"shows review evidence"| node_dashboard
node_baseline_view -.->|"loads baseline"| node_dashboard_api
node_live_view -.->|"loads Sonar data"| node_dashboard_api
node_dashboard_api -.->|"calls backend"| node_api

click node_cli "https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/cli.py"
click node_api "https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/api/app.py"
click node_webhook "https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/api/webhook.py"
click node_worker "https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/worker/tasks.py"
click node_ingest "https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/ingest/github.py"
click node_orchestrator "https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/graph.py"
click node_agents "https://github.com/sakthimurugan03/patchcourt/tree/main/patchcourt/agents"
click node_conflicts "https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/debate/conflict.py"
click node_debate "https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/debate/debate.py"
click node_judge "https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/judge/scoring.py"
click node_schemas "https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/agents/schemas.py"
click node_rag "https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/rag/store.py"
click node_evidence_engine "https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/evidence.py"
click node_tools "https://github.com/sakthimurugan03/patchcourt/tree/main/patchcourt/tools"
click node_sandbox "https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/sandbox/runner.py"
click node_llm "https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/llm.py"
click node_sonar_baseline "https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/baseline/sonarqube_baseline.py"
click node_sonar_live "https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/sonar_live.py"
click node_audit "https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/db/audit.py"
click node_llm_config "https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/runtime_llm_config.py"
click node_dashboard "https://github.com/sakthimurugan03/patchcourt/blob/main/dashboard/src/app/page.tsx"
click node_dashboard_api "https://github.com/sakthimurugan03/patchcourt/blob/main/dashboard/src/lib/api.ts"
click node_dashboard_views "https://github.com/sakthimurugan03/patchcourt/blob/main/dashboard/src/app/evidence/page.tsx"
click node_baseline_view "https://github.com/sakthimurugan03/patchcourt/blob/main/dashboard/src/components/sonar-baseline-panel.tsx"
click node_live_view "https://github.com/sakthimurugan03/patchcourt/blob/main/dashboard/src/components/sonar-live-panel.tsx"

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_api,node_webhook,node_worker toneBlue
class node_ingest,node_orchestrator,node_agents,node_conflicts,node_debate,node_judge,node_schemas toneAmber
class node_rag,node_evidence_engine,node_tools,node_sandbox,node_llm,node_sonar_baseline,node_sonar_live toneMint
class node_audit,node_redis,node_postgres,node_llm_config toneRose
class node_dashboard,node_dashboard_api,node_dashboard_views,node_baseline_view,node_live_view,node_github toneIndigo
```

## Components

### Review entry points

- [Review CLI](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/cli.py): `patchcourt/cli.py`
- [REST API](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/api/app.py): `patchcourt/api/app.py`
- [GitHub webhook](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/api/webhook.py): `patchcourt/api/webhook.py`
- [Celery worker](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/worker/tasks.py): `patchcourt/worker/tasks.py`

### Review pipeline

- [PR ingestion](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/ingest/github.py): `patchcourt/ingest/github.py`
- [Review graph](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/graph.py): `patchcourt/graph.py`
- [Specialist agents](https://github.com/sakthimurugan03/patchcourt/tree/main/patchcourt/agents): `patchcourt/agents`
- [Conflict detection](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/debate/conflict.py): `patchcourt/debate/conflict.py`
- [Bounded debate](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/debate/debate.py): `patchcourt/debate/debate.py`
- [Scoring and verdict](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/judge/scoring.py): `patchcourt/judge/scoring.py`
- [Review data models](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/agents/schemas.py): `patchcourt/agents/schemas.py`

### Evidence and analysis

- [Repository retrieval](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/rag/store.py): `patchcourt/rag/store.py`
- [Evidence engine](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/evidence.py): `patchcourt/evidence.py`
- [Static analysis tools](https://github.com/sakthimurugan03/patchcourt/tree/main/patchcourt/tools): `patchcourt/tools`
- [Isolated scanner](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/sandbox/runner.py): `patchcourt/sandbox/runner.py`
- [LLM client](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/llm.py): `patchcourt/llm.py`
- [Sonar baseline](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/baseline/sonarqube_baseline.py): `patchcourt/baseline/sonarqube_baseline.py`
- [Sonar live queries](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/sonar_live.py): `patchcourt/sonar_live.py`

### Persistence and integrations

- [Audit storage](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/db/audit.py): `patchcourt/db/audit.py`
- **Redis queue**
- **PostgreSQL**
- [Runtime LLM settings](https://github.com/sakthimurugan03/patchcourt/blob/main/patchcourt/runtime_llm_config.py): `patchcourt/runtime_llm_config.py`

### Dashboard

- [Review dashboard](https://github.com/sakthimurugan03/patchcourt/blob/main/dashboard/src/app/page.tsx): `dashboard/src/app/page.tsx`
- [Dashboard API client](https://github.com/sakthimurugan03/patchcourt/blob/main/dashboard/src/lib/api.ts): `dashboard/src/lib/api.ts`
- [Evidence and review views](https://github.com/sakthimurugan03/patchcourt/blob/main/dashboard/src/app/evidence/page.tsx): `dashboard/src/app/evidence/page.tsx`
- [Baseline view](https://github.com/sakthimurugan03/patchcourt/blob/main/dashboard/src/components/sonar-baseline-panel.tsx): `dashboard/src/components/sonar-baseline-panel.tsx`
- [Sonar live view](https://github.com/sakthimurugan03/patchcourt/blob/main/dashboard/src/components/sonar-live-panel.tsx): `dashboard/src/components/sonar-live-panel.tsx`

### Other components

- **GitHub PR**

## Connections

- GitHub PR → REST API: submits PR (evidence: `README.md`)
- GitHub PR → GitHub webhook: sends events (evidence: `README.md`)
- Review CLI → Review graph: runs review (evidence: `README.md`)
- Review dashboard → REST API: requests review (evidence: `README.md`)
- REST API → Review graph: runs review (evidence: `patchcourt/api/app.py`)
- GitHub webhook → Celery worker: enqueues task (evidence: `patchcourt/api/webhook.py`)
- Celery worker → Review graph: runs review (evidence: `patchcourt/worker/tasks.py`)
- Celery worker → Redis queue: uses broker (evidence: `patchcourt/worker/tasks.py`)
- Review graph → PR ingestion: fetches PR (evidence: `patchcourt/graph.py`)
- Review graph → Repository retrieval: indexes and queries (evidence: `patchcourt/graph.py`)
- Review graph → Evidence engine: analyzes files (evidence: `patchcourt/graph.py`)
- Review graph → Specialist agents: runs in parallel (evidence: `README.md`)
- Review graph → Conflict detection: detects conflicts (evidence: `patchcourt/graph.py`)
- Review graph → Bounded debate: runs if needed (evidence: `patchcourt/graph.py`)
- Review graph → Scoring and verdict: builds report (evidence: `patchcourt/graph.py`)
- Review graph → Audit storage: persists report (evidence: `patchcourt/graph.py`)
- Evidence engine → Static analysis tools: runs scanners (evidence: `README.md`)
- Review graph → Isolated scanner: runs isolated scans (evidence: `patchcourt/graph.py`)
- Isolated scanner → Static analysis tools: dispatches scans (evidence: `patchcourt/sandbox/runner.py`)
- Specialist agents → LLM client: requests claims (evidence: `patchcourt/agents/base.py`)
- Bounded debate → LLM client: requests rebuttals (evidence: `patchcourt/debate/debate.py`)
- Bounded debate → Repository retrieval: retrieves fresh evidence (evidence: `README.md`)
- Scoring and verdict → Review data models: produces report (evidence: `patchcourt/judge/scoring.py`)
- Audit storage → PostgreSQL: stores audit trail (evidence: `README.md`)
- REST API → Sonar baseline: serves baseline (evidence: `patchcourt/api/app.py`)
- REST API → Sonar live queries: serves live queries (evidence: `patchcourt/api/app.py`)
- REST API → Runtime LLM settings: updates settings (evidence: `patchcourt/api/app.py`)
- Runtime LLM settings → LLM client: resets client (evidence: `patchcourt/runtime_llm_config.py`)
- Review dashboard → Dashboard API client: requests data
- Evidence and review views → Review dashboard: shows review evidence
- Baseline view → Dashboard API client: loads baseline
- Sonar live view → Dashboard API client: loads Sonar data
- Dashboard API client → REST API: calls backend
