# pvcube66/pr-reviewer architecture

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

- Interactive diagram: https://gitdiagram.com/pvcube66/pr-reviewer
- Repository: https://github.com/pvcube66/pr-reviewer

## Overview

PR Reviewer accepts GitHub pull-request webhooks, verifies and deduplicates them, obtains and indexes the diff, runs four sequential specialist reviews plus aggregation, and posts the resulting comment. The graph also shows prompt assets, injection filtering, vector context, and event logging. Main call relationships are supported by excerpts; the specialist sequence and ChromaDB context role are also documented in the README. External service details beyond those shown are not inferred.

Main entry points: [`app/orchestrator.py`](https://github.com/pvcube66/pr-reviewer/blob/master/app/orchestrator.py) (Review orchestrator), [`app/main.py`](https://github.com/pvcube66/pr-reviewer/blob/master/app/main.py) (Webhook API), [`app/prompts.py`](https://github.com/pvcube66/pr-reviewer/blob/master/app/prompts.py) (Prompt loader), [`app/agents.py`](https://github.com/pvcube66/pr-reviewer/blob/master/app/agents.py) (Security review)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingress["Webhook ingress"]
  node_webhook["Webhook API<br/>[main.py]"]
end

subgraph group_review["Review pipeline"]
  node_review_graph["Review orchestrator<br/>[orchestrator.py]"]
  node_security_agent["Security review<br/>[agents.py]"]
  node_quality_agent["Quality review<br/>[agents.py]"]
  node_tests_agent["Test review<br/>[agents.py]"]
  node_docs_agent["Docs review<br/>[agents.py]"]
  node_aggregator["Findings aggregator<br/>[agents.py]"]
end

subgraph group_context["Context and prompts"]
  node_diff_memory[("Diff index<br/>[memory.py]")]
  node_context_retrieval["Context retrieval<br/>[memory.py]"]
  node_prompt_loader["Prompt loader<br/>[prompts.py]"]
  node_role_prompts["Role prompts"]
end

subgraph group_observability["Safety and events"]
  node_injection_guard["Injection guard<br/>[security.py]"]
  node_event_spine["Event spine<br/>[spine.py]"]
  node_event_log[("JSONL event log")]
end

node_github_pr(("GitHub PR"))
node_github_api["GitHub API"]
node_groq["Groq LLM"]

node_github_pr -->|"sends webhook"| node_webhook
node_webhook -->|"fetches diff"| node_github_api
node_webhook -->|"indexes diff"| node_diff_memory
node_webhook -->|"starts review"| node_review_graph
node_webhook -->|"posts comment"| node_github_api
node_github_api -->|"returns diff"| node_github_pr
node_github_api -->|"publishes comment"| node_github_pr
node_review_graph -->|"retrieves context"| node_context_retrieval
node_review_graph -->|"dispatches first"| node_security_agent
node_review_graph -->|"dispatches next"| node_quality_agent
node_review_graph -->|"dispatches next"| node_tests_agent
node_review_graph -->|"dispatches next"| node_docs_agent
node_review_graph -->|"dispatches last"| node_aggregator
node_security_agent -->|"requests findings"| node_groq
node_quality_agent -->|"requests findings"| node_groq
node_tests_agent -->|"requests findings"| node_groq
node_docs_agent -->|"requests findings"| node_groq
node_aggregator -->|"requests summary"| node_groq
node_security_agent -->|"loads role prompt"| node_prompt_loader
node_quality_agent -->|"loads role prompt"| node_prompt_loader
node_tests_agent -->|"loads role prompt"| node_prompt_loader
node_docs_agent -->|"loads role prompt"| node_prompt_loader
node_aggregator -->|"loads role prompt"| node_prompt_loader
node_prompt_loader -->|"reads prompt"| node_role_prompts
node_security_agent -->|"filters diff"| node_injection_guard
node_security_agent -->|"emits review events"| node_event_spine
node_aggregator -->|"emits call events"| node_event_spine
node_webhook -->|"emits lifecycle events"| node_event_spine
node_event_spine -->|"appends events"| node_event_log

click node_webhook "https://github.com/pvcube66/pr-reviewer/blob/master/app/main.py"
click node_diff_memory "https://github.com/pvcube66/pr-reviewer/blob/master/app/memory.py"
click node_review_graph "https://github.com/pvcube66/pr-reviewer/blob/master/app/orchestrator.py"
click node_context_retrieval "https://github.com/pvcube66/pr-reviewer/blob/master/app/memory.py"
click node_security_agent "https://github.com/pvcube66/pr-reviewer/blob/master/app/agents.py"
click node_quality_agent "https://github.com/pvcube66/pr-reviewer/blob/master/app/agents.py"
click node_tests_agent "https://github.com/pvcube66/pr-reviewer/blob/master/app/agents.py"
click node_docs_agent "https://github.com/pvcube66/pr-reviewer/blob/master/app/agents.py"
click node_aggregator "https://github.com/pvcube66/pr-reviewer/blob/master/app/agents.py"
click node_prompt_loader "https://github.com/pvcube66/pr-reviewer/blob/master/app/prompts.py"
click node_role_prompts "https://github.com/pvcube66/pr-reviewer/tree/master/prompts/v1"
click node_injection_guard "https://github.com/pvcube66/pr-reviewer/blob/master/app/security.py"
click node_event_spine "https://github.com/pvcube66/pr-reviewer/blob/master/app/spine.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_webhook toneBlue
class node_review_graph,node_security_agent,node_quality_agent,node_tests_agent,node_docs_agent,node_aggregator toneAmber
class node_diff_memory,node_context_retrieval,node_prompt_loader,node_role_prompts,node_github_api toneMint
class node_injection_guard,node_event_spine,node_event_log toneRose
class node_github_pr,node_groq toneIndigo
```

## Components

### Webhook ingress

- [Webhook API](https://github.com/pvcube66/pr-reviewer/blob/master/app/main.py): `app/main.py`

### Review pipeline

- [Review orchestrator](https://github.com/pvcube66/pr-reviewer/blob/master/app/orchestrator.py): `app/orchestrator.py`
- [Security review](https://github.com/pvcube66/pr-reviewer/blob/master/app/agents.py): `app/agents.py`
- [Quality review](https://github.com/pvcube66/pr-reviewer/blob/master/app/agents.py): `app/agents.py`
- [Test review](https://github.com/pvcube66/pr-reviewer/blob/master/app/agents.py): `app/agents.py`
- [Docs review](https://github.com/pvcube66/pr-reviewer/blob/master/app/agents.py): `app/agents.py`
- [Findings aggregator](https://github.com/pvcube66/pr-reviewer/blob/master/app/agents.py): `app/agents.py`

### Context and prompts

- [Diff index](https://github.com/pvcube66/pr-reviewer/blob/master/app/memory.py): `app/memory.py`
- [Context retrieval](https://github.com/pvcube66/pr-reviewer/blob/master/app/memory.py): `app/memory.py`
- [Prompt loader](https://github.com/pvcube66/pr-reviewer/blob/master/app/prompts.py): `app/prompts.py`
- [Role prompts](https://github.com/pvcube66/pr-reviewer/tree/master/prompts/v1): `prompts/v1`

### Safety and events

- [Injection guard](https://github.com/pvcube66/pr-reviewer/blob/master/app/security.py): `app/security.py`
- [Event spine](https://github.com/pvcube66/pr-reviewer/blob/master/app/spine.py): `app/spine.py`
- **JSONL event log**

### Other components

- **GitHub PR**
- **GitHub API**
- **Groq LLM**

## Connections

- GitHub PR → Webhook API: sends webhook (evidence: `README.md`)
- Webhook API → GitHub API: fetches diff (evidence: `app/main.py`)
- Webhook API → Diff index: indexes diff (evidence: `app/main.py`)
- Webhook API → Review orchestrator: starts review (evidence: `app/main.py`)
- Webhook API → GitHub API: posts comment (evidence: `app/main.py`)
- GitHub API → GitHub PR: returns diff (evidence: `README.md`)
- GitHub API → GitHub PR: publishes comment (evidence: `README.md`)
- Review orchestrator → Context retrieval: retrieves context (evidence: `app/orchestrator.py`)
- Review orchestrator → Security review: dispatches first (evidence: `app/orchestrator.py`)
- Review orchestrator → Quality review: dispatches next (evidence: `app/orchestrator.py`)
- Review orchestrator → Test review: dispatches next (evidence: `app/orchestrator.py`)
- Review orchestrator → Docs review: dispatches next (evidence: `app/orchestrator.py`)
- Review orchestrator → Findings aggregator: dispatches last (evidence: `app/orchestrator.py`)
- Security review → Groq LLM: requests findings (evidence: `app/agents.py`)
- Quality review → Groq LLM: requests findings (evidence: `app/agents.py`)
- Test review → Groq LLM: requests findings (evidence: `app/agents.py`)
- Docs review → Groq LLM: requests findings (evidence: `app/agents.py`)
- Findings aggregator → Groq LLM: requests summary (evidence: `app/agents.py`)
- Security review → Prompt loader: loads role prompt (evidence: `app/agents.py`)
- Quality review → Prompt loader: loads role prompt (evidence: `app/agents.py`)
- Test review → Prompt loader: loads role prompt (evidence: `app/agents.py`)
- Docs review → Prompt loader: loads role prompt (evidence: `app/agents.py`)
- Findings aggregator → Prompt loader: loads role prompt (evidence: `app/agents.py`)
- Prompt loader → Role prompts: reads prompt (evidence: `app/prompts.py`)
- Security review → Injection guard: filters diff (evidence: `app/agents.py`)
- Security review → Event spine: emits review events (evidence: `app/agents.py`)
- Findings aggregator → Event spine: emits call events (evidence: `app/agents.py`)
- Webhook API → Event spine: emits lifecycle events (evidence: `app/main.py`)
- Event spine → JSONL event log: appends events (evidence: `README.md`)
