# yogeshwargopi/reviewer-agent architecture

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

- Interactive diagram: https://gitdiagram.com/yogeshwargopi/reviewer-agent
- Repository: https://github.com/yogeshwargopi/reviewer-agent

## Overview

Locus is a self-hosted GitHub App that reviews enabled pull requests and publishes findings and a check. The main flow is GitHub webhook → event handling and queued work → policy-aware review → GitHub publication, with a separate worker for review and installation-sync jobs. The dashboard manages installations, repositories, policies, model keys, and review results. Relationships are based on the README and SOURCE INDEX references; excerpts confirm important worker and pipeline calls, but several implementation details were not sampled.

Main entry points: [`src/server/review/pipeline.ts`](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/review/pipeline.ts) (Review pipeline), [`src/server/db/schema.ts`](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/db/schema.ts) (Postgres data), [`src/server/github/events.ts`](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/github/events.ts) (Event handling), [`src/server/actions.ts`](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/actions.ts) (Dashboard actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web app"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_review_views["Review views<br/>[page.tsx]"]
  node_actions["Dashboard actions<br/>[actions.ts]"]
end

subgraph group_github["GitHub integration"]
  node_webhook_api["Webhook endpoint<br/>[route.ts]"]
  node_github_events["Event handling<br/>[events.ts]"]
  node_github_setup["Installation setup<br/>[sync.ts]"]
  node_github_app["GitHub App client<br/>[app.ts]"]
  node_publishing["Review publishing<br/>[publish.ts]"]
  node_sync["Installation sync<br/>[sync.ts]"]
end

subgraph group_review["Review processing"]
  node_review_pipeline["Review pipeline<br/>[pipeline.ts]"]
  node_policy["Policy resolution<br/>[policy.ts]"]
  node_diff["Diff selection<br/>[diff.ts]"]
  node_prompt["Prompt building<br/>[prompt.ts]"]
  node_model["Model review<br/>[model.ts]"]
  node_findings["Finding validation<br/>[findings.ts]"]
end

subgraph group_platform["Data and operations"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_job_queue["Job queue<br/>[queue.ts]"]
  node_worker["Worker<br/>[worker.ts]"]
  node_database[("Postgres data<br/>[schema.ts]")]
end

node_github_user(("GitHub user"))
node_github["GitHub"]
node_model_provider["OpenAI / Anthropic"]

node_github_user -->|"manages setup"| node_dashboard
node_dashboard -->|"submits changes"| node_actions
node_dashboard -->|"loads session"| node_auth
node_review_views -->|"checks session"| node_auth
node_review_views -->|"loads results"| node_database
node_actions -->|"updates settings"| node_database
node_actions -->|"queues dry run"| node_job_queue
node_actions -->|"gets installation client"| node_github_app
node_webhook_api -->|"dispatches delivery"| node_github_events
node_webhook_api -->|"records delivery"| node_database
node_github_events -->|"queues reviews"| node_job_queue
node_github_events -->|"reads and writes state"| node_database
node_github_events -->|"gets installation client"| node_github_app
node_github_events -->|"requests sync"| node_sync
node_job_queue -.->|"provides jobs"| node_worker
node_worker -->|"processes review jobs"| node_review_pipeline
node_worker -->|"processes sync jobs"| node_sync
node_review_pipeline -->|"reads and writes runs"| node_database
node_review_pipeline -->|"resolves policy"| node_policy
node_review_pipeline -->|"gets installation client"| node_github_app
node_review_pipeline -->|"fetches and publishes"| node_publishing
node_review_pipeline -->|"selects changed files"| node_diff
node_review_pipeline -->|"builds model prompt"| node_prompt
node_review_pipeline -->|"generates findings"| node_model
node_review_pipeline -->|"prepares findings"| node_findings
node_review_pipeline -->|"requests review"| node_model_provider
node_publishing -->|"posts review and check"| node_github
node_sync -->|"gets installation client"| node_github_app
node_sync -->|"updates installation data"| node_database
node_auth -->|"persists accounts"| node_database

click node_dashboard "https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/app/(dashboard)/overview/page.tsx"
click node_review_views "https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/app/(dashboard)/reviews/%5Bid%5D/page.tsx"
click node_actions "https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/actions.ts"
click node_auth "https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/auth.ts"
click node_webhook_api "https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/app/api/github/webhook/route.ts"
click node_github_events "https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/github/events.ts"
click node_github_setup "https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/github/sync.ts"
click node_github_app "https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/github/app.ts"
click node_job_queue "https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/review/queue.ts"
click node_worker "https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/worker.ts"
click node_review_pipeline "https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/review/pipeline.ts"
click node_policy "https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/review/policy.ts"
click node_diff "https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/review/diff.ts"
click node_prompt "https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/review/prompt.ts"
click node_model "https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/review/model.ts"
click node_findings "https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/review/findings.ts"
click node_publishing "https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/github/publish.ts"
click node_sync "https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/github/sync.ts"
click node_database "https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/db/schema.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_dashboard,node_review_views,node_actions,node_github_user toneBlue
class node_webhook_api,node_github_events,node_github_setup,node_github_app,node_publishing,node_sync toneAmber
class node_review_pipeline,node_policy,node_diff,node_prompt,node_model,node_findings toneMint
class node_auth,node_job_queue,node_worker,node_database toneRose
class node_github,node_model_provider toneIndigo
```

## Components

### Web app

- [Dashboard](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/app/(dashboard)/overview/page.tsx): `src/app/(dashboard)/overview/page.tsx`
- [Review views](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/app/(dashboard)/reviews/%5Bid%5D/page.tsx): `src/app/(dashboard)/reviews/[id]/page.tsx`
- [Dashboard actions](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/actions.ts): `src/server/actions.ts`

### GitHub integration

- [Webhook endpoint](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/app/api/github/webhook/route.ts): `src/app/api/github/webhook/route.ts`
- [Event handling](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/github/events.ts): `src/server/github/events.ts`
- [Installation setup](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/github/sync.ts): `src/server/github/sync.ts`
- [GitHub App client](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/github/app.ts): `src/server/github/app.ts`
- [Review publishing](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/github/publish.ts): `src/server/github/publish.ts`
- [Installation sync](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/github/sync.ts): `src/server/github/sync.ts`

### Review processing

- [Review pipeline](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/review/pipeline.ts): `src/server/review/pipeline.ts`
- [Policy resolution](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/review/policy.ts): `src/server/review/policy.ts`
- [Diff selection](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/review/diff.ts): `src/server/review/diff.ts`
- [Prompt building](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/review/prompt.ts): `src/server/review/prompt.ts`
- [Model review](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/review/model.ts): `src/server/review/model.ts`
- [Finding validation](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/review/findings.ts): `src/server/review/findings.ts`

### Data and operations

- [Authentication](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/auth.ts): `src/server/auth.ts`
- [Job queue](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/review/queue.ts): `src/server/review/queue.ts`
- [Worker](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/worker.ts): `src/worker.ts`
- [Postgres data](https://github.com/yogeshwargopi/reviewer-agent/blob/main/src/server/db/schema.ts): `src/server/db/schema.ts`

### Other components

- **GitHub user**
- **GitHub**
- **OpenAI / Anthropic**

## Connections

- GitHub user → Dashboard: manages setup
- Dashboard → Dashboard actions: submits changes (evidence: `src/app/(dashboard)/overview/page.tsx`)
- Dashboard → Authentication: loads session (evidence: `src/app/(dashboard)/overview/page.tsx`)
- Review views → Authentication: checks session (evidence: `src/app/(dashboard)/reviews/[id]/page.tsx`)
- Review views → Postgres data: loads results
- Dashboard actions → Postgres data: updates settings (evidence: `src/server/actions.ts`)
- Dashboard actions → Job queue: queues dry run (evidence: `src/server/actions.ts`)
- Dashboard actions → GitHub App client: gets installation client (evidence: `src/server/actions.ts`)
- Webhook endpoint → Event handling: dispatches delivery (evidence: `src/app/api/github/webhook/route.ts`)
- Webhook endpoint → Postgres data: records delivery (evidence: `src/app/api/github/webhook/route.ts`)
- Event handling → Job queue: queues reviews (evidence: `src/server/github/events.ts`)
- Event handling → Postgres data: reads and writes state (evidence: `src/server/github/events.ts`)
- Event handling → GitHub App client: gets installation client (evidence: `src/server/github/events.ts`)
- Event handling → Installation sync: requests sync (evidence: `src/server/github/events.ts`)
- Job queue → Worker: provides jobs
- Worker → Review pipeline: processes review jobs (evidence: `src/worker.ts`)
- Worker → Installation sync: processes sync jobs (evidence: `src/worker.ts`)
- Review pipeline → Postgres data: reads and writes runs (evidence: `src/server/review/pipeline.ts`)
- Review pipeline → Policy resolution: resolves policy (evidence: `src/server/review/pipeline.ts`)
- Review pipeline → GitHub App client: gets installation client (evidence: `src/server/review/pipeline.ts`)
- Review pipeline → Review publishing: fetches and publishes (evidence: `src/server/review/pipeline.ts`)
- Review pipeline → Diff selection: selects changed files (evidence: `src/server/review/pipeline.ts`)
- Review pipeline → Prompt building: builds model prompt (evidence: `src/server/review/pipeline.ts`)
- Review pipeline → Model review: generates findings (evidence: `src/server/review/pipeline.ts`)
- Review pipeline → Finding validation: prepares findings (evidence: `src/server/review/pipeline.ts`)
- Review pipeline → OpenAI / Anthropic: requests review
- Review publishing → GitHub: posts review and check
- Installation sync → GitHub App client: gets installation client (evidence: `src/server/github/sync.ts`)
- Installation sync → Postgres data: updates installation data (evidence: `src/server/github/sync.ts`)
- Authentication → Postgres data: persists accounts (evidence: `src/server/auth.ts`)
