# micomyiza-alexis/spta_simulator architecture

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

- Interactive diagram: https://gitdiagram.com/micomyiza-alexis/spta_simulator
- Repository: https://github.com/micomyiza-alexis/spta_simulator

## Overview

SPTA Simulator is a research decision-support app for comparing social-protection targeting strategies across selection rates, reviewing robustness, and exploring aggregate VUP participation evidence. Users enter through the dashboard or a focused analysis page; frontend requests pass through the API client to FastAPI routes and services that return validated results. Research scripts prepare simulations, repeated-split evaluations, and VUP aggregates, which are then served by the backend. The sampled source confirms dashboard/result and robustness storage paths; README documents the broader scenario and data-preparation capabilities. Some links among unsampled research scripts and prepared outputs are omitted.

Main entry points: [`frontend/src/lib/api.ts`](https://github.com/micomyiza-alexis/spta_simulator/blob/main/frontend/src/lib/api.ts) (Frontend API client), [`backend/app/main.py`](https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/api/results.py`](https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/api/results.py) (Results routes), [`backend/app/api/robustness.py`](https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/api/robustness.py) (Robustness routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Research analysis"]
  node_simulations["Targeting simulations"]
  node_robustness_runs["Repeated-split evaluation"]
  node_vup_build["VUP aggregate preparation"]
end

subgraph group_backend["API and results"]
  node_fastapi["FastAPI application<br/>[main.py]"]
  node_dashboard_api["Dashboard routes<br/>[dashboard.py]"]
  node_results_api["Results routes<br/>[results.py]"]
  node_robustness_api["Robustness routes<br/>[robustness.py]"]
  node_vup_api["VUP evidence route<br/>[vup_evidence.py]"]
  node_dashboard_service["Dashboard aggregation"]
  node_results_service["Strategy results<br/>[results_service.py]"]
  node_robustness_service["Robustness results"]
  node_results_schema["Results response schema<br/>[results.py]"]
  node_robustness_schema["Robustness schemas<br/>[robustness.py]"]
end

subgraph group_frontend["Decision interface"]
  node_dashboard_page["Overview dashboard<br/>[page.tsx]"]
  node_scenario_page["Scenario comparisons<br/>[page.tsx]"]
  node_simulator_page["Targeting simulator<br/>[page.tsx]"]
  node_robustness_page["Robustness view<br/>[page.tsx]"]
  node_vup_page["VUP evidence view<br/>[page.tsx]"]
  node_dashboard_shell["Shared dashboard shell<br/>[DashboardShell.tsx]"]
  node_api_client["Frontend API client<br/>[api.ts]"]
end

subgraph group_evidence["VUP evidence"]
  node_vup_service["Validated VUP evidence"]
  node_vup_schema["Aggregate response schema<br/>[vup_evidence.py]"]
end

node_researcher(("Policy researcher"))

node_researcher -->|"opens"| node_dashboard_page
node_researcher -->|"explores"| node_scenario_page
node_researcher -->|"simulates"| node_simulator_page
node_researcher -->|"reviews"| node_robustness_page
node_researcher -->|"examines"| node_vup_page
node_dashboard_page -->|"renders"| node_dashboard_shell
node_simulator_page -->|"renders"| node_dashboard_shell
node_dashboard_page -->|"requests data"| node_api_client
node_simulator_page -->|"requests data"| node_api_client
node_scenario_page -->|"requests data"| node_api_client
node_robustness_page -->|"requests data"| node_api_client
node_vup_page -->|"requests evidence"| node_api_client
node_api_client -->|"fetches API"| node_fastapi
node_fastapi -->|"registers routes"| node_dashboard_api
node_fastapi -->|"registers routes"| node_results_api
node_fastapi -->|"registers routes"| node_robustness_api
node_fastapi -->|"registers routes"| node_vup_api
node_dashboard_api -->|"delegates"| node_dashboard_service
node_results_api -->|"queries"| node_results_service
node_robustness_api -->|"queries"| node_robustness_service
node_vup_api -->|"loads evidence"| node_vup_service
node_dashboard_service -->|"aggregates results"| node_results_service
node_dashboard_service -->|"aggregates robustness"| node_robustness_service
node_vup_service -->|"validates payload"| node_vup_schema
node_results_api -->|"shapes response"| node_results_schema
node_robustness_api -->|"shapes response"| node_robustness_schema
node_simulations -.->|"prepares results for"| node_results_service
node_robustness_runs -.->|"prepares results for"| node_robustness_service
node_vup_build -.->|"prepares aggregate for"| node_vup_service

click node_simulations "https://github.com/micomyiza-alexis/spta_simulator/tree/main/scripts"
click node_robustness_runs "https://github.com/micomyiza-alexis/spta_simulator/blob/main/scripts/run_repeated_split_robustness.py"
click node_vup_build "https://github.com/micomyiza-alexis/spta_simulator/blob/main/scripts/build_vup_evidence.py"
click node_dashboard_page "https://github.com/micomyiza-alexis/spta_simulator/blob/main/frontend/src/app/page.tsx"
click node_scenario_page "https://github.com/micomyiza-alexis/spta_simulator/blob/main/frontend/src/app/scenarios/page.tsx"
click node_simulator_page "https://github.com/micomyiza-alexis/spta_simulator/blob/main/frontend/src/app/simulator/page.tsx"
click node_robustness_page "https://github.com/micomyiza-alexis/spta_simulator/blob/main/frontend/src/app/robustness/page.tsx"
click node_vup_page "https://github.com/micomyiza-alexis/spta_simulator/blob/main/frontend/src/app/vup-evidence/page.tsx"
click node_dashboard_shell "https://github.com/micomyiza-alexis/spta_simulator/blob/main/frontend/src/components/DashboardShell.tsx"
click node_api_client "https://github.com/micomyiza-alexis/spta_simulator/blob/main/frontend/src/lib/api.ts"
click node_fastapi "https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/main.py"
click node_dashboard_api "https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/api/dashboard.py"
click node_results_api "https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/api/results.py"
click node_robustness_api "https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/api/robustness.py"
click node_vup_api "https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/api/vup_evidence.py"
click node_dashboard_service "https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/services/dashboard_service.py"
click node_results_service "https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/services/results_service.py"
click node_robustness_service "https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/services/robustness_service.py"
click node_vup_service "https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/services/vup_evidence_service.py"
click node_vup_schema "https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/schemas/vup_evidence.py"
click node_results_schema "https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/schemas/results.py"
click node_robustness_schema "https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/schemas/robustness.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_simulations,node_robustness_runs,node_vup_build toneBlue
class node_fastapi,node_dashboard_api,node_results_api,node_robustness_api,node_vup_api,node_dashboard_service,node_results_service,node_robustness_service,node_results_schema,node_robustness_schema toneAmber
class node_dashboard_page,node_scenario_page,node_simulator_page,node_robustness_page,node_vup_page,node_dashboard_shell,node_api_client toneMint
class node_vup_service,node_vup_schema toneRose
class node_researcher toneIndigo
```

## Components

### Research analysis

- [Targeting simulations](https://github.com/micomyiza-alexis/spta_simulator/tree/main/scripts): `scripts`
- [Repeated-split evaluation](https://github.com/micomyiza-alexis/spta_simulator/blob/main/scripts/run_repeated_split_robustness.py): `scripts/run_repeated_split_robustness.py`
- [VUP aggregate preparation](https://github.com/micomyiza-alexis/spta_simulator/blob/main/scripts/build_vup_evidence.py): `scripts/build_vup_evidence.py`

### API and results

- [FastAPI application](https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/main.py): `backend/app/main.py`
- [Dashboard routes](https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/api/dashboard.py): `backend/app/api/dashboard.py`
- [Results routes](https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/api/results.py): `backend/app/api/results.py`
- [Robustness routes](https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/api/robustness.py): `backend/app/api/robustness.py`
- [VUP evidence route](https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/api/vup_evidence.py): `backend/app/api/vup_evidence.py`
- [Dashboard aggregation](https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/services/dashboard_service.py): `backend/app/services/dashboard_service.py`
- [Strategy results](https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/services/results_service.py): `backend/app/services/results_service.py`
- [Robustness results](https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/services/robustness_service.py): `backend/app/services/robustness_service.py`
- [Results response schema](https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/schemas/results.py): `backend/app/schemas/results.py`
- [Robustness schemas](https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/schemas/robustness.py): `backend/app/schemas/robustness.py`

### Decision interface

- [Overview dashboard](https://github.com/micomyiza-alexis/spta_simulator/blob/main/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`
- [Scenario comparisons](https://github.com/micomyiza-alexis/spta_simulator/blob/main/frontend/src/app/scenarios/page.tsx): `frontend/src/app/scenarios/page.tsx`
- [Targeting simulator](https://github.com/micomyiza-alexis/spta_simulator/blob/main/frontend/src/app/simulator/page.tsx): `frontend/src/app/simulator/page.tsx`
- [Robustness view](https://github.com/micomyiza-alexis/spta_simulator/blob/main/frontend/src/app/robustness/page.tsx): `frontend/src/app/robustness/page.tsx`
- [VUP evidence view](https://github.com/micomyiza-alexis/spta_simulator/blob/main/frontend/src/app/vup-evidence/page.tsx): `frontend/src/app/vup-evidence/page.tsx`
- [Shared dashboard shell](https://github.com/micomyiza-alexis/spta_simulator/blob/main/frontend/src/components/DashboardShell.tsx): `frontend/src/components/DashboardShell.tsx`
- [Frontend API client](https://github.com/micomyiza-alexis/spta_simulator/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### VUP evidence

- [Validated VUP evidence](https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/services/vup_evidence_service.py): `backend/app/services/vup_evidence_service.py`
- [Aggregate response schema](https://github.com/micomyiza-alexis/spta_simulator/blob/main/backend/app/schemas/vup_evidence.py): `backend/app/schemas/vup_evidence.py`

### Other components

- **Policy researcher**

## Connections

- Policy researcher → Overview dashboard: opens (evidence: `README.md`)
- Policy researcher → Scenario comparisons: explores (evidence: `README.md`)
- Policy researcher → Targeting simulator: simulates (evidence: `README.md`)
- Policy researcher → Robustness view: reviews (evidence: `README.md`)
- Policy researcher → VUP evidence view: examines (evidence: `README.md`)
- Overview dashboard → Shared dashboard shell: renders (evidence: `frontend/src/app/page.tsx`)
- Targeting simulator → Shared dashboard shell: renders (evidence: `frontend/src/app/simulator/page.tsx`)
- Overview dashboard → Frontend API client: requests data (evidence: `frontend/src/app/page.tsx`)
- Targeting simulator → Frontend API client: requests data (evidence: `frontend/src/app/simulator/page.tsx`)
- Scenario comparisons → Frontend API client: requests data (evidence: `frontend/src/app/scenarios/page.tsx`)
- Robustness view → Frontend API client: requests data (evidence: `frontend/src/app/robustness/page.tsx`)
- VUP evidence view → Frontend API client: requests evidence (evidence: `frontend/src/app/vup-evidence/page.tsx`)
- Frontend API client → FastAPI application: fetches API (evidence: `frontend/src/lib/api.ts`)
- FastAPI application → Dashboard routes: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Results routes: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Robustness routes: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → VUP evidence route: registers routes (evidence: `backend/app/main.py`)
- Dashboard routes → Dashboard aggregation: delegates (evidence: `backend/app/api/dashboard.py`)
- Results routes → Strategy results: queries (evidence: `backend/app/api/results.py`)
- Robustness routes → Robustness results: queries (evidence: `backend/app/api/robustness.py`)
- VUP evidence route → Validated VUP evidence: loads evidence (evidence: `backend/app/api/vup_evidence.py`)
- Dashboard aggregation → Strategy results: aggregates results (evidence: `backend/app/services/dashboard_service.py`)
- Dashboard aggregation → Robustness results: aggregates robustness (evidence: `backend/app/services/dashboard_service.py`)
- Validated VUP evidence → Aggregate response schema: validates payload (evidence: `backend/app/services/vup_evidence_service.py`)
- Results routes → Results response schema: shapes response (evidence: `backend/app/api/results.py`)
- Robustness routes → Robustness schemas: shapes response (evidence: `backend/app/api/robustness.py`)
- Targeting simulations → Strategy results: prepares results for
- Repeated-split evaluation → Robustness results: prepares results for
- VUP aggregate preparation → Validated VUP evidence: prepares aggregate for
