# shreesha1-ux/spark-lens architecture

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

- Interactive diagram: https://gitdiagram.com/shreesha1-ux/spark-lens
- Repository: https://github.com/shreesha1-ux/spark-lens

## Overview

Spark Lens is a civic infrastructure complaint review product: users select synthetic reports, load them into the Cockpit, and inspect assessments, evidence, urgency, and repair estimates. The backend exposes analysis workflows, combining specialist assessments and persisting results. The graph follows shown frontend imports and backend calls; connections from the Cockpit to backend APIs are left unverified because the excerpts do not show the request destinations. Some core modules are represented by their exact paths despite not being excerpted.

Main entry points: [`server/safeguard.mjs`](https://github.com/shreesha1-ux/spark-lens/blob/main/server/safeguard.mjs) (SafeGuard risk), [`server/app.mjs`](https://github.com/shreesha1-ux/spark-lens/blob/main/server/app.mjs) (HTTP API), [`server/budgetwise.mjs`](https://github.com/shreesha1-ux/spark-lens/blob/main/server/budgetwise.mjs) (BudgetWise estimate), [`server/civicjudge.mjs`](https://github.com/shreesha1-ux/spark-lens/blob/main/server/civicjudge.mjs) (CivicJudge batch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Report and review"]
  node_entry["Web app<br/>[main.tsx]"]
  node_report["Report selection<br/>[Report.tsx]"]
  node_cockpit["Review cockpit<br/>[Cockpit.tsx]"]
  node_complaint_data[("Complaint catalog<br/>[complaints.ts]")]
  node_shared_ui["Shared UI<br/>[ui.tsx]"]
end

subgraph group_backend["Assessment workflows"]
  node_api["HTTP API<br/>[app.mjs]"]
  node_agent1["Agent 1<br/>[agent1.mjs]"]
  node_agent2["Damage analysis<br/>[agent2.mjs]"]
  node_civicjudge["CivicJudge batch<br/>[civicjudge.mjs]"]
  node_safeguard["SafeGuard risk<br/>[safeguard.mjs]"]
  node_budgetwise["BudgetWise estimate<br/>[budgetwise.mjs]"]
end

subgraph group_support["Evidence and persistence"]
  node_complaint_inputs["Complaint inputs<br/>[complaints.mjs]"]
  node_gemini["Gemini client<br/>[gemini.mjs]"]
  node_nearby["Nearby places<br/>[overpass.mjs]"]
  node_weather["Incident weather<br/>[weather.mjs]"]
  node_risk_rules["Risk rules<br/>[safeguardRules.mjs]"]
  node_stores[("Assessment stores<br/>[store.mjs]")]
end

subgraph group_rubrics["Civic evaluation"]
  node_python_judge["Judge rubric<br/>[civic_judge.py]"]
  node_demo_rubric["Demo rubric"]
end

node_resident(("Reviewer"))

node_resident -->|"uses"| node_entry
node_entry -->|"routes to"| node_report
node_entry -->|"routes to"| node_cockpit
node_entry -->|"restores selections"| node_complaint_data
node_report -->|"lists reports"| node_complaint_data
node_report -->|"renders"| node_shared_ui
node_cockpit -->|"renders"| node_shared_ui
node_cockpit -.->|"requests assessments"| node_api
node_api -->|"dispatches analysis"| node_agent1
node_api -->|"dispatches analysis"| node_agent2
node_api -->|"dispatches analysis"| node_budgetwise
node_api -->|"dispatches analysis"| node_safeguard
node_api -->|"runs batch"| node_civicjudge
node_api -->|"reads and writes"| node_stores
node_civicjudge -->|"analyzes cases"| node_agent1
node_civicjudge -->|"analyzes cases"| node_agent2
node_civicjudge -->|"requests estimates"| node_budgetwise
node_civicjudge -->|"saves results"| node_stores
node_safeguard -->|"reuses assessment"| node_agent2
node_safeguard -->|"loads input"| node_complaint_inputs
node_safeguard -->|"fetches places"| node_nearby
node_safeguard -->|"fetches weather"| node_weather
node_safeguard -->|"evaluates risk"| node_risk_rules
node_safeguard -->|"requests assessment"| node_gemini
node_safeguard -->|"reads and saves"| node_stores
node_budgetwise -->|"reuses assessment"| node_agent2
node_budgetwise -->|"requests risk context"| node_safeguard
node_budgetwise -->|"loads input"| node_complaint_inputs
node_budgetwise -->|"requests estimate"| node_gemini
node_budgetwise -->|"reads and saves"| node_stores
node_python_judge -->|"imports rubric"| node_demo_rubric

click node_entry "https://github.com/shreesha1-ux/spark-lens/blob/main/src/main.tsx"
click node_report "https://github.com/shreesha1-ux/spark-lens/blob/main/src/Report.tsx"
click node_cockpit "https://github.com/shreesha1-ux/spark-lens/blob/main/src/Cockpit.tsx"
click node_complaint_data "https://github.com/shreesha1-ux/spark-lens/blob/main/src/data/complaints.ts"
click node_shared_ui "https://github.com/shreesha1-ux/spark-lens/blob/main/src/ui.tsx"
click node_api "https://github.com/shreesha1-ux/spark-lens/blob/main/server/app.mjs"
click node_agent1 "https://github.com/shreesha1-ux/spark-lens/blob/main/server/agent1.mjs"
click node_agent2 "https://github.com/shreesha1-ux/spark-lens/blob/main/server/agent2.mjs"
click node_civicjudge "https://github.com/shreesha1-ux/spark-lens/blob/main/server/civicjudge.mjs"
click node_safeguard "https://github.com/shreesha1-ux/spark-lens/blob/main/server/safeguard.mjs"
click node_budgetwise "https://github.com/shreesha1-ux/spark-lens/blob/main/server/budgetwise.mjs"
click node_complaint_inputs "https://github.com/shreesha1-ux/spark-lens/blob/main/server/complaints.mjs"
click node_gemini "https://github.com/shreesha1-ux/spark-lens/blob/main/server/gemini.mjs"
click node_nearby "https://github.com/shreesha1-ux/spark-lens/blob/main/server/overpass.mjs"
click node_weather "https://github.com/shreesha1-ux/spark-lens/blob/main/server/weather.mjs"
click node_risk_rules "https://github.com/shreesha1-ux/spark-lens/blob/main/server/safeguardRules.mjs"
click node_stores "https://github.com/shreesha1-ux/spark-lens/blob/main/server/store.mjs"
click node_python_judge "https://github.com/shreesha1-ux/spark-lens/blob/main/scripts/civic_judge.py"
click node_demo_rubric "https://github.com/shreesha1-ux/spark-lens/blob/main/scripts/spark_demo_rubric.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_entry,node_report,node_cockpit,node_complaint_data,node_shared_ui,node_resident toneBlue
class node_api,node_agent1,node_agent2,node_civicjudge,node_safeguard,node_budgetwise toneAmber
class node_complaint_inputs,node_gemini,node_nearby,node_weather,node_risk_rules,node_stores toneMint
class node_python_judge,node_demo_rubric toneRose
```

## Components

### Report and review

- [Web app](https://github.com/shreesha1-ux/spark-lens/blob/main/src/main.tsx): `src/main.tsx`
- [Report selection](https://github.com/shreesha1-ux/spark-lens/blob/main/src/Report.tsx): `src/Report.tsx`
- [Review cockpit](https://github.com/shreesha1-ux/spark-lens/blob/main/src/Cockpit.tsx): `src/Cockpit.tsx`
- [Complaint catalog](https://github.com/shreesha1-ux/spark-lens/blob/main/src/data/complaints.ts): `src/data/complaints.ts`
- [Shared UI](https://github.com/shreesha1-ux/spark-lens/blob/main/src/ui.tsx): `src/ui.tsx`

### Assessment workflows

- [HTTP API](https://github.com/shreesha1-ux/spark-lens/blob/main/server/app.mjs): `server/app.mjs`
- [Agent 1](https://github.com/shreesha1-ux/spark-lens/blob/main/server/agent1.mjs): `server/agent1.mjs`
- [Damage analysis](https://github.com/shreesha1-ux/spark-lens/blob/main/server/agent2.mjs): `server/agent2.mjs`
- [CivicJudge batch](https://github.com/shreesha1-ux/spark-lens/blob/main/server/civicjudge.mjs): `server/civicjudge.mjs`
- [SafeGuard risk](https://github.com/shreesha1-ux/spark-lens/blob/main/server/safeguard.mjs): `server/safeguard.mjs`
- [BudgetWise estimate](https://github.com/shreesha1-ux/spark-lens/blob/main/server/budgetwise.mjs): `server/budgetwise.mjs`

### Evidence and persistence

- [Complaint inputs](https://github.com/shreesha1-ux/spark-lens/blob/main/server/complaints.mjs): `server/complaints.mjs`
- [Gemini client](https://github.com/shreesha1-ux/spark-lens/blob/main/server/gemini.mjs): `server/gemini.mjs`
- [Nearby places](https://github.com/shreesha1-ux/spark-lens/blob/main/server/overpass.mjs): `server/overpass.mjs`
- [Incident weather](https://github.com/shreesha1-ux/spark-lens/blob/main/server/weather.mjs): `server/weather.mjs`
- [Risk rules](https://github.com/shreesha1-ux/spark-lens/blob/main/server/safeguardRules.mjs): `server/safeguardRules.mjs`
- [Assessment stores](https://github.com/shreesha1-ux/spark-lens/blob/main/server/store.mjs): `server/store.mjs`

### Civic evaluation

- [Judge rubric](https://github.com/shreesha1-ux/spark-lens/blob/main/scripts/civic_judge.py): `scripts/civic_judge.py`
- [Demo rubric](https://github.com/shreesha1-ux/spark-lens/blob/main/scripts/spark_demo_rubric.py): `scripts/spark_demo_rubric.py`

### Other components

- **Reviewer**

## Connections

- Reviewer → Web app: uses (evidence: `src/main.tsx`)
- Web app → Report selection: routes to (evidence: `src/main.tsx`)
- Web app → Review cockpit: routes to (evidence: `src/main.tsx`)
- Web app → Complaint catalog: restores selections (evidence: `src/main.tsx`)
- Report selection → Complaint catalog: lists reports (evidence: `src/Report.tsx`)
- Report selection → Shared UI: renders (evidence: `src/Report.tsx`)
- Review cockpit → Shared UI: renders (evidence: `src/Cockpit.tsx`)
- Review cockpit → HTTP API: requests assessments
- HTTP API → Agent 1: dispatches analysis (evidence: `server/app.mjs`)
- HTTP API → Damage analysis: dispatches analysis (evidence: `server/app.mjs`)
- HTTP API → BudgetWise estimate: dispatches analysis (evidence: `server/app.mjs`)
- HTTP API → SafeGuard risk: dispatches analysis (evidence: `server/app.mjs`)
- HTTP API → CivicJudge batch: runs batch (evidence: `server/app.mjs`)
- HTTP API → Assessment stores: reads and writes (evidence: `server/app.mjs`)
- CivicJudge batch → Agent 1: analyzes cases (evidence: `server/civicjudge.mjs`)
- CivicJudge batch → Damage analysis: analyzes cases (evidence: `server/civicjudge.mjs`)
- CivicJudge batch → BudgetWise estimate: requests estimates (evidence: `server/civicjudge.mjs`)
- CivicJudge batch → Assessment stores: saves results (evidence: `server/civicjudge.mjs`)
- SafeGuard risk → Damage analysis: reuses assessment (evidence: `server/safeguard.mjs`)
- SafeGuard risk → Complaint inputs: loads input (evidence: `server/safeguard.mjs`)
- SafeGuard risk → Nearby places: fetches places (evidence: `server/safeguard.mjs`)
- SafeGuard risk → Incident weather: fetches weather (evidence: `server/safeguard.mjs`)
- SafeGuard risk → Risk rules: evaluates risk (evidence: `server/safeguard.mjs`)
- SafeGuard risk → Gemini client: requests assessment (evidence: `server/safeguard.mjs`)
- SafeGuard risk → Assessment stores: reads and saves (evidence: `server/safeguard.mjs`)
- BudgetWise estimate → Damage analysis: reuses assessment (evidence: `server/budgetwise.mjs`)
- BudgetWise estimate → SafeGuard risk: requests risk context (evidence: `server/budgetwise.mjs`)
- BudgetWise estimate → Complaint inputs: loads input (evidence: `server/budgetwise.mjs`)
- BudgetWise estimate → Gemini client: requests estimate (evidence: `server/budgetwise.mjs`)
- BudgetWise estimate → Assessment stores: reads and saves (evidence: `server/budgetwise.mjs`)
- Judge rubric → Demo rubric: imports rubric (evidence: `scripts/civic_judge.py`)
