# 1xcodes-swapnil/receipt architecture

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

- Interactive diagram: https://gitdiagram.com/1xcodes-swapnil/receipt
- Repository: https://github.com/1xcodes-swapnil/receipt

## Overview

Receipts is an evidence-first code review platform: a user submits a PR review, the backend assesses risk and runs review agents, and the resulting verdict and evidence receipts are persisted and displayed. The graph also preserves the documented audit, bug-immunity, and replay capabilities. Source excerpts support the core review, event, audit, and replay relationships; several extension implementations and frontend pages were not sampled, so uncertain wiring is omitted.

Main entry points: [`backend/app/orchestration/orchestrator.py`](https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/orchestration/orchestrator.py) (Review orchestrator), [`backend/app/api/routes.py`](https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/api/routes.py) (HTTP API), [`frontend/src/pages/PRReview.tsx`](https://github.com/1xcodes-swapnil/receipt/blob/main/frontend/src/pages/PRReview.tsx) (PR Review UI), [`backend/app/replay/engine.py`](https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/replay/engine.py) (Replay engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Review interface"]
  node_review_ui["PR Review UI<br/>[PRReview.tsx]"]
  node_details_ui["Review details<br/>[ReviewDetails.tsx]"]
  node_app_routes["Frontend routes<br/>[App.tsx]"]
  node_frontend_api["API client<br/>[api.ts]"]
end

subgraph group_review["Review execution"]
  node_api_routes["HTTP API<br/>[routes.py]"]
  node_review_orch["Review orchestrator<br/>[orchestrator.py]"]
  node_risk["Risk assessment<br/>[risk.py]"]
  node_agents["Review agents"]
  node_sandbox["Test runner<br/>[sandbox.py]"]
end

subgraph group_evidence["Evidence and state"]
  node_event_bus["Live event bus<br/>[bus.py]"]
  node_audit["Audit chain<br/>[service.py]"]
  node_models["Review records<br/>[models.py]"]
  node_database[("Application database<br/>[database.py]")]
end

subgraph group_extensions["Immunity and replay"]
  node_immunity["Immunity pipeline<br/>[orchestrator.py]"]
  node_immunity_stages["Immunity stages<br/>[stages.py]"]
  node_replay_api["Replay engine<br/>[engine.py]"]
  node_replay_cases["Replay cases<br/>[demo_cases.py]"]
end

node_user(("Review user"))
node_demo_repo["Demo repository"]

node_user -->|"submits review"| node_review_ui
node_review_ui -->|"requests review"| node_frontend_api
node_frontend_api -->|"calls API"| node_api_routes
node_api_routes -->|"starts review"| node_review_orch
node_review_orch -->|"assesses risk"| node_risk
node_review_orch -->|"runs agents"| node_agents
node_agents -->|"executes tests"| node_sandbox
node_sandbox -->|"tests repository"| node_demo_repo
node_review_orch -->|"writes review data"| node_models
node_review_orch -->|"emits progress"| node_event_bus
node_api_routes -->|"reads review data"| node_models
node_models -->|"persists records"| node_database
node_review_orch -->|"records audit events"| node_audit
node_audit -->|"stores hash chain"| node_database
node_event_bus -->|"streams progress"| node_review_ui
node_review_ui -->|"fetches run detail"| node_frontend_api
node_app_routes -->|"routes to review"| node_review_ui
node_app_routes -->|"routes to details"| node_details_ui
node_details_ui -->|"fetches run detail"| node_frontend_api
node_api_routes -.->|"starts pipeline"| node_immunity
node_immunity -->|"runs stages"| node_immunity_stages
node_immunity -->|"records transitions"| node_audit
node_api_routes -->|"validates or runs replay"| node_replay_api
node_replay_api -->|"runs case review"| node_review_orch
node_replay_api -.->|"uses seeded cases"| node_replay_cases
node_replay_api -->|"stores replay results"| node_database

click node_review_ui "https://github.com/1xcodes-swapnil/receipt/blob/main/frontend/src/pages/PRReview.tsx"
click node_details_ui "https://github.com/1xcodes-swapnil/receipt/blob/main/frontend/src/pages/ReviewDetails.tsx"
click node_app_routes "https://github.com/1xcodes-swapnil/receipt/blob/main/frontend/src/App.tsx"
click node_frontend_api "https://github.com/1xcodes-swapnil/receipt/blob/main/frontend/src/services/api.ts"
click node_api_routes "https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/api/routes.py"
click node_review_orch "https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/orchestration/orchestrator.py"
click node_risk "https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/services/risk.py"
click node_agents "https://github.com/1xcodes-swapnil/receipt/tree/main/backend/app/agents"
click node_sandbox "https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/sandbox/sandbox.py"
click node_demo_repo "https://github.com/1xcodes-swapnil/receipt/tree/main/demo/repository"
click node_event_bus "https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/events/bus.py"
click node_audit "https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/audit/service.py"
click node_models "https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/models.py"
click node_database "https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/database.py"
click node_immunity "https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/immunity/orchestrator.py"
click node_immunity_stages "https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/immunity/stages.py"
click node_replay_api "https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/replay/engine.py"
click node_replay_cases "https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/replay/demo_cases.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_review_ui,node_details_ui,node_app_routes,node_frontend_api,node_user toneBlue
class node_api_routes,node_review_orch,node_risk,node_agents,node_sandbox toneAmber
class node_event_bus,node_audit,node_models,node_database toneMint
class node_immunity,node_immunity_stages,node_replay_api,node_replay_cases toneRose
class node_demo_repo toneTeal
```

## Components

### Review interface

- [PR Review UI](https://github.com/1xcodes-swapnil/receipt/blob/main/frontend/src/pages/PRReview.tsx): `frontend/src/pages/PRReview.tsx`
- [Review details](https://github.com/1xcodes-swapnil/receipt/blob/main/frontend/src/pages/ReviewDetails.tsx): `frontend/src/pages/ReviewDetails.tsx`
- [Frontend routes](https://github.com/1xcodes-swapnil/receipt/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [API client](https://github.com/1xcodes-swapnil/receipt/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`

### Review execution

- [HTTP API](https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/api/routes.py): `backend/app/api/routes.py`
- [Review orchestrator](https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/orchestration/orchestrator.py): `backend/app/orchestration/orchestrator.py`
- [Risk assessment](https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/services/risk.py): `backend/app/services/risk.py`
- [Review agents](https://github.com/1xcodes-swapnil/receipt/tree/main/backend/app/agents): `backend/app/agents`
- [Test runner](https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/sandbox/sandbox.py): `backend/app/sandbox/sandbox.py`

### Evidence and state

- [Live event bus](https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/events/bus.py): `backend/app/events/bus.py`
- [Audit chain](https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/audit/service.py): `backend/app/audit/service.py`
- [Review records](https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/models.py): `backend/app/models.py`
- [Application database](https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/database.py): `backend/app/database.py`

### Immunity and replay

- [Immunity pipeline](https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/immunity/orchestrator.py): `backend/app/immunity/orchestrator.py`
- [Immunity stages](https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/immunity/stages.py): `backend/app/immunity/stages.py`
- [Replay engine](https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/replay/engine.py): `backend/app/replay/engine.py`
- [Replay cases](https://github.com/1xcodes-swapnil/receipt/blob/main/backend/app/replay/demo_cases.py): `backend/app/replay/demo_cases.py`

### Other components

- **Review user**
- [Demo repository](https://github.com/1xcodes-swapnil/receipt/tree/main/demo/repository): `demo/repository`

## Connections

- Review user → PR Review UI: submits review
- PR Review UI → API client: requests review
- API client → HTTP API: calls API
- HTTP API → Review orchestrator: starts review
- Review orchestrator → Risk assessment: assesses risk
- Review orchestrator → Review agents: runs agents
- Review agents → Test runner: executes tests
- Test runner → Demo repository: tests repository
- Review orchestrator → Review records: writes review data
- Review orchestrator → Live event bus: emits progress
- HTTP API → Review records: reads review data
- Review records → Application database: persists records
- Review orchestrator → Audit chain: records audit events
- Audit chain → Application database: stores hash chain
- Live event bus → PR Review UI: streams progress
- PR Review UI → API client: fetches run detail
- Frontend routes → PR Review UI: routes to review
- Frontend routes → Review details: routes to details
- Review details → API client: fetches run detail
- HTTP API → Immunity pipeline: starts pipeline
- Immunity pipeline → Immunity stages: runs stages
- Immunity pipeline → Audit chain: records transitions
- HTTP API → Replay engine: validates or runs replay
- Replay engine → Review orchestrator: runs case review
- Replay engine → Replay cases: uses seeded cases
- Replay engine → Application database: stores replay results
