# sumitagg24/repoverix architecture

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

- Interactive diagram: https://gitdiagram.com/sumitagg24/repoverix
- Repository: https://github.com/sumitagg24/repoverix

## Overview

#### Purpose and entry points
RepoVeriX is a full-stack research prototype for evidence-grounded repository auditing, patch generation, and Docker-isolated repair verification. The backend FastAPI application starts at `backend/app/main.py`; the frontend is a Next.js App Router application rooted at `frontend/src/app/layout.tsx` and `frontend/src/app/page.tsx`. Deployment composes frontend, backend, PostgreSQL, and Nginx via `docker-compose.yml`, `docker-compose.prod.yml`, and `nginx/nginx.conf`.

#### API, identity, and tenant boundary
FastAPI route modules expose authenticated workflows for repositories, scans, findings, patches, intelligence, websites, reporting, and integrations. Route handlers should remain the HTTP boundary; authorization, organizations/RBAC, tokens, and account security are centralized through dependencies and services.
- `backend/app/api/dependencies.py`
- `backend/app/api/routes/scans.py`
- `backend/app/api/routes/organizations.py`

The browser client accesses this API through a typed service and feature hooks; application pages are organized around scan/repository/finding operations.
- `frontend/src/services/api.ts`
- `frontend/src/hooks/useScans.ts`
- `frontend/src/app/(app)/repositories/[id]/page.tsx`

#### Persistence and domain records
SQLAlchemy async models hold durable users, organizations, repositories, scans, findings, feedback/sharing, billing, and website-audit state. Alembic is the schema-evolution boundary; PostgreSQL is production storage while SQLite supports development/tests.
- `backend/app/db/models.py`
- `backend/app/db/database.py`
- `backend/alembic/versions/003_orgs_rbac_tokens.py`

#### Repository ingestion and knowledge construction
A scan begins with a GitHub-connected repository or guarded ZIP upload. Ingestion treats source as untrusted data, detects repository characteristics, and feeds parsing. Tree-sitter-derived symbols, imports, calls, and contextual knowledge create the cross-file model used by later analysis.
- `backend/app/analysis/ingest.py`
- `backend/app/analysis/parsing.py`
- `backend/app/analysis/knowledge.py`

GitHub/OAuth integration is isolated from analysis, while SSRF, security, and redaction facilities enforce trust boundaries around external/repository-originated content.
- `backend/app/services/github.py`
- `backend/app/core/ssrf.py`
- `backend/app/analysis/redaction.py`

#### Audit orchestration and evidence decisions
The orchestrator selects an experimental configuration (`static_only`, `llm_only`, combined, or RepoVeriX), coordinates deterministic detectors and contextual/LLM analysis, then validates claims into evidence-backed findings. Evidence status is the key reliability boundary: ungrounded LLM assertions are not trusted.
- `backend/app/analysis/orchestrate.py`
- `backend/app/analysis/detectors.py`
- `backend/app/analysis/evidence.py`

Analysis also includes risk/impact, dependency reachability, attack paths, architecture smells, regression, and repository query/intelligence outputs.
- `backend/app/analysis/impact.py`
- `backend/app/analysis/attackpaths.py`
- `backend/app/analysis/intel.py`

#### Repair and execution verification
For accepted findings, repair uses deterministic templates before LLM generation. Candidate diffs are evaluated by patch-quality logic and proof-of-fix, then executed only in a constrained Docker sandbox: apply patch, run tests/static checks, re-analyze the original finding, and persist a verified/failed verdict.
- `backend/app/analysis/repair.py`
- `backend/app/analysis/verify.py`
- `backend/app/analysis/runtime.py`

LLM access is provider-abstracted and prompt-driven; repository text is redacted before requests.
- `backend/app/analysis/llm.py`
- `backend/prompts/repair_generation_v1.txt`

#### User experience, reporting, and research evaluation
The Next.js UI presents scans, findings/evidence, patch verification, repository intelligence, and dashboards; TanStack-query-style hooks separate API state from views.
- `frontend/src/app/(app)/scans/[id]/page.tsx`
- `frontend/src/components/audit/evidence-graph-diagram.tsx`
- `frontend/src/components/findings/proof-of-fix.tsx`

Reports/SARIF exports form the external result boundary. A CLI benchmark runner evaluates actual outputs against seeded ground truth and configured experiment matrices.
- `backend/app/services/reporting.py`
- `backend/app/services/sarif.py`
- `backend/app/benchmark/__main__.py`

Main entry points: [`backend/app/api/routes/scans.py`](https://github.com/sumitagg24/repoverix/blob/main/backend/app/api/routes/scans.py) (Workflow routes), [`backend/app/db/models.py`](https://github.com/sumitagg24/repoverix/blob/main/backend/app/db/models.py) (Domain records), [`backend/app/analysis/repair.py`](https://github.com/sumitagg24/repoverix/blob/main/backend/app/analysis/repair.py) (Patch generation), [`backend/app/analysis/orchestrate.py`](https://github.com/sumitagg24/repoverix/blob/main/backend/app/analysis/orchestrate.py) (Audit orchestrator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_ui["Next.js application<br/>App Router UI<br/>[layout.tsx]"]
  node_client_api["Typed API client<br/>client service<br/>[api.ts]"]
  node_scan_hook["Scan state hooks<br/>query hooks<br/>[useScans.ts]"]
  node_evidence_view["Evidence and proof views<br/>UI components"]
end

subgraph group_api["API and domain"]
  node_fastapi["FastAPI application<br/>HTTP application<br/>[main.py]"]
  node_routes["Workflow routes<br/>route modules<br/>[scans.py]"]
  node_identity["Identity and tenant policy<br/>dependencies and services<br/>[dependencies.py]"]
  node_domain["Domain records<br/>SQLAlchemy models<br/>[models.py]"]
  node_database[("PostgreSQL / SQLite<br/>persistence<br/>[database.py]")]
  node_migrations["Schema migrations<br/>Alembic migrations"]
  node_reports["Reports and SARIF<br/>result export<br/>[reporting.py]"]
end

subgraph group_analysis["Audit pipeline"]
  node_ingestion["Repository ingestion<br/>untrusted source intake<br/>[ingest.py]"]
  node_github{{"GitHub and OAuth<br/>external integration<br/>[github.py]"}}
  node_knowledge["Code knowledge model<br/>Tree-sitter analysis<br/>[knowledge.py]"]
  node_orchestrator["Audit orchestrator<br/>analysis coordinator<br/>[orchestrate.py]"]
  node_evidence["Evidence validation<br/>reliability gate<br/>[evidence.py]"]
  node_benchmark["Benchmark runner<br/>CLI evaluation<br/>[__main__.py]"]
end

subgraph group_repair["Repair verification"]
  node_repair_engine["Patch generation<br/>repair engine<br/>[repair.py]"]
  node_llm["LLM provider layer<br/>provider abstraction<br/>[llm.py]"]
  node_sandbox["Docker verification sandbox<br/>constrained execution<br/>[runtime.py]"]
end

node_deployment{{"Deployment compose<br/>container deployment<br/>[docker-compose.yml]"}}

node_ui -->|"uses"| node_scan_hook
node_scan_hook -->|"fetches through"| node_client_api
node_client_api -->|"API calls"| node_fastapi
node_fastapi -->|"mounts"| node_routes
node_routes -->|"authorizes via"| node_identity
node_routes -->|"starts scans"| node_orchestrator
node_routes -->|"accepts repairs"| node_repair_engine
node_routes -->|"reads and writes"| node_domain
node_domain -->|"persists to"| node_database
node_migrations -->|"evolves schema"| node_database
node_github -->|"supplies repositories"| node_ingestion
node_ingestion -->|"parses source"| node_knowledge
node_knowledge -->|"context for analysis"| node_orchestrator
node_orchestrator -->|"validates claims"| node_evidence
node_evidence -->|"stores findings"| node_domain
node_evidence -->|"accepted findings"| node_repair_engine
node_repair_engine -->|"generates candidates"| node_llm
node_repair_engine -->|"submits candidate diff"| node_sandbox
node_sandbox -->|"persists verdict"| node_domain
node_domain -->|"audit results"| node_reports
node_evidence_view -->|"loads evidence"| node_client_api
node_benchmark -->|"runs experiment matrix"| node_orchestrator
node_deployment -->|"deploys"| node_ui
node_deployment -->|"deploys"| node_fastapi
node_deployment -->|"deploys"| node_database

click node_ui "https://github.com/sumitagg24/repoverix/blob/main/frontend/src/app/layout.tsx"
click node_client_api "https://github.com/sumitagg24/repoverix/blob/main/frontend/src/services/api.ts"
click node_scan_hook "https://github.com/sumitagg24/repoverix/blob/main/frontend/src/hooks/useScans.ts"
click node_evidence_view "https://github.com/sumitagg24/repoverix/blob/main/frontend/src/components/audit/evidence-graph-diagram.tsx"
click node_fastapi "https://github.com/sumitagg24/repoverix/blob/main/backend/app/main.py"
click node_routes "https://github.com/sumitagg24/repoverix/blob/main/backend/app/api/routes/scans.py"
click node_identity "https://github.com/sumitagg24/repoverix/blob/main/backend/app/api/dependencies.py"
click node_domain "https://github.com/sumitagg24/repoverix/blob/main/backend/app/db/models.py"
click node_database "https://github.com/sumitagg24/repoverix/blob/main/backend/app/db/database.py"
click node_migrations "https://github.com/sumitagg24/repoverix/blob/main/backend/alembic/versions/003_orgs_rbac_tokens.py"
click node_ingestion "https://github.com/sumitagg24/repoverix/blob/main/backend/app/analysis/ingest.py"
click node_github "https://github.com/sumitagg24/repoverix/blob/main/backend/app/services/github.py"
click node_knowledge "https://github.com/sumitagg24/repoverix/blob/main/backend/app/analysis/knowledge.py"
click node_orchestrator "https://github.com/sumitagg24/repoverix/blob/main/backend/app/analysis/orchestrate.py"
click node_evidence "https://github.com/sumitagg24/repoverix/blob/main/backend/app/analysis/evidence.py"
click node_repair_engine "https://github.com/sumitagg24/repoverix/blob/main/backend/app/analysis/repair.py"
click node_llm "https://github.com/sumitagg24/repoverix/blob/main/backend/app/analysis/llm.py"
click node_sandbox "https://github.com/sumitagg24/repoverix/blob/main/backend/app/analysis/runtime.py"
click node_reports "https://github.com/sumitagg24/repoverix/blob/main/backend/app/services/reporting.py"
click node_benchmark "https://github.com/sumitagg24/repoverix/blob/main/backend/app/benchmark/__main__.py"
click node_deployment "https://github.com/sumitagg24/repoverix/blob/main/docker-compose.yml"

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_ui,node_client_api,node_scan_hook,node_evidence_view toneBlue
class node_fastapi,node_routes,node_identity,node_domain,node_database,node_migrations,node_reports toneAmber
class node_ingestion,node_github,node_knowledge,node_orchestrator,node_evidence,node_benchmark toneMint
class node_repair_engine,node_llm,node_sandbox toneRose
class node_deployment toneNeutral
```

## Components

### Web client

- [Next.js application](https://github.com/sumitagg24/repoverix/blob/main/frontend/src/app/layout.tsx): App Router UI · Presents repository, scan, finding, and verification workflows. · `frontend/src/app/layout.tsx`
- [Typed API client](https://github.com/sumitagg24/repoverix/blob/main/frontend/src/services/api.ts): client service · `frontend/src/services/api.ts`
- [Scan state hooks](https://github.com/sumitagg24/repoverix/blob/main/frontend/src/hooks/useScans.ts): query hooks · `frontend/src/hooks/useScans.ts`
- [Evidence and proof views](https://github.com/sumitagg24/repoverix/blob/main/frontend/src/components/audit/evidence-graph-diagram.tsx): UI components · `frontend/src/components/audit/evidence-graph-diagram.tsx`

### API and domain

- [FastAPI application](https://github.com/sumitagg24/repoverix/blob/main/backend/app/main.py): HTTP application · `backend/app/main.py`
- [Workflow routes](https://github.com/sumitagg24/repoverix/blob/main/backend/app/api/routes/scans.py): route modules · HTTP boundary for scans, repositories, findings, patches, and organization workflows. · `backend/app/api/routes/scans.py`
- [Identity and tenant policy](https://github.com/sumitagg24/repoverix/blob/main/backend/app/api/dependencies.py): dependencies and services · Centralizes authentication, RBAC, organizations, tokens, and account security. · `backend/app/api/dependencies.py`
- [Domain records](https://github.com/sumitagg24/repoverix/blob/main/backend/app/db/models.py): SQLAlchemy models · Durable users, organizations, repositories, scans, findings, sharing, billing, and website audits. · `backend/app/db/models.py`
- [PostgreSQL / SQLite](https://github.com/sumitagg24/repoverix/blob/main/backend/app/db/database.py): persistence · PostgreSQL is production storage; SQLite supports development and tests. · `backend/app/db/database.py`
- [Schema migrations](https://github.com/sumitagg24/repoverix/blob/main/backend/alembic/versions/003_orgs_rbac_tokens.py): Alembic migrations · `backend/alembic/versions/003_orgs_rbac_tokens.py`
- [Reports and SARIF](https://github.com/sumitagg24/repoverix/blob/main/backend/app/services/reporting.py): result export · External boundary for audit results. · `backend/app/services/reporting.py`

### Audit pipeline

- [Repository ingestion](https://github.com/sumitagg24/repoverix/blob/main/backend/app/analysis/ingest.py): untrusted source intake · Accepts GitHub repositories or guarded ZIP uploads and detects repository characteristics. · `backend/app/analysis/ingest.py`
- [GitHub and OAuth](https://github.com/sumitagg24/repoverix/blob/main/backend/app/services/github.py): external integration · `backend/app/services/github.py`
- [Code knowledge model](https://github.com/sumitagg24/repoverix/blob/main/backend/app/analysis/knowledge.py): Tree-sitter analysis · Builds cross-file symbols, imports, calls, and contextual knowledge. · `backend/app/analysis/knowledge.py`
- [Audit orchestrator](https://github.com/sumitagg24/repoverix/blob/main/backend/app/analysis/orchestrate.py): analysis coordinator · Selects experimental mode and coordinates deterministic and contextual analysis. · `backend/app/analysis/orchestrate.py`
- [Evidence validation](https://github.com/sumitagg24/repoverix/blob/main/backend/app/analysis/evidence.py): reliability gate · Only evidence-backed claims become trusted findings. · `backend/app/analysis/evidence.py`
- [Benchmark runner](https://github.com/sumitagg24/repoverix/blob/main/backend/app/benchmark/__main__.py): CLI evaluation · Compares actual outputs with seeded ground truth and experiment matrices. · `backend/app/benchmark/__main__.py`

### Repair verification

- [Patch generation](https://github.com/sumitagg24/repoverix/blob/main/backend/app/analysis/repair.py): repair engine · Uses deterministic templates before LLM candidate generation and patch-quality checks. · `backend/app/analysis/repair.py`
- [LLM provider layer](https://github.com/sumitagg24/repoverix/blob/main/backend/app/analysis/llm.py): provider abstraction · Prompt-driven access receives redacted repository text. · `backend/app/analysis/llm.py`
- [Docker verification sandbox](https://github.com/sumitagg24/repoverix/blob/main/backend/app/analysis/runtime.py): constrained execution · Applies patches, runs checks, re-analyzes findings, and records verdicts. · `backend/app/analysis/runtime.py`

### Other components

- [Deployment compose](https://github.com/sumitagg24/repoverix/blob/main/docker-compose.yml): container deployment · Composes frontend, backend, database, and Nginx. · `docker-compose.yml`

## Connections

- Next.js application → Scan state hooks: uses
- Scan state hooks → Typed API client: fetches through
- Typed API client → FastAPI application: API calls
- FastAPI application → Workflow routes: mounts
- Workflow routes → Identity and tenant policy: authorizes via
- Workflow routes → Audit orchestrator: starts scans
- Workflow routes → Patch generation: accepts repairs
- Workflow routes → Domain records: reads and writes
- Domain records → PostgreSQL / SQLite: persists to
- Schema migrations → PostgreSQL / SQLite: evolves schema
- GitHub and OAuth → Repository ingestion: supplies repositories
- Repository ingestion → Code knowledge model: parses source
- Code knowledge model → Audit orchestrator: context for analysis
- Audit orchestrator → Evidence validation: validates claims
- Evidence validation → Domain records: stores findings
- Evidence validation → Patch generation: accepted findings
- Patch generation → LLM provider layer: generates candidates
- Patch generation → Docker verification sandbox: submits candidate diff
- Docker verification sandbox → Domain records: persists verdict
- Domain records → Reports and SARIF: audit results
- Evidence and proof views → Typed API client: loads evidence
- Benchmark runner → Audit orchestrator: runs experiment matrix
- Deployment compose → Next.js application: deploys
- Deployment compose → FastAPI application: deploys
- Deployment compose → PostgreSQL / SQLite: deploys
