# jeevithar3/nexflow architecture

> Architecture diagram of the GitHub repository jeevithar3/nexflow, 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/jeevithar3/nexflow
- Repository: https://github.com/jeevithar3/nexflow

## Overview

NexFlow is a synthetic-traffic forecasting and digital-twin prototype. Users request a SUMO prediction, inspect current and forecast congestion, then evaluate or search for signal-timing interventions; candidate plans are simulated and memory-retrieved plans are re-verified before recommendation. The dashboard also exposes network routing estimates, experience search, benchmarks, and model evaluation. Relationships are based on the README and shown excerpts; several internal modules and page implementations were not sampled, so their detailed call paths are not asserted.

Main entry points: [`backend/app/api/v1/routes.py`](https://github.com/jeevithar3/nexflow/blob/main/backend/app/api/v1/routes.py) (REST endpoints), [`backend/app/services/decision.py`](https://github.com/jeevithar3/nexflow/blob/main/backend/app/services/decision.py) (Intervention search), [`backend/app/experience_memory/memory.py`](https://github.com/jeevithar3/nexflow/blob/main/backend/app/experience_memory/memory.py) (Experience retrieval), [`backend/app/ml/inference.py`](https://github.com/jeevithar3/nexflow/blob/main/backend/app/ml/inference.py) (GNN inference)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Dashboard"]
  node_pages["Dashboard pages"]
  node_app["Page router<br/>[App.tsx]"]
  node_client["API client<br/>[client.ts]"]
end

subgraph group_api["API and orchestration"]
  node_routes["REST endpoints<br/>[routes.py]"]
  node_services["Decision services"]
  node_jobs["Background jobs<br/>[jobs.py]"]
end

subgraph group_forecast["Forecast and twin"]
  node_network["Road network model<br/>[network.py]"]
  node_twin[("Digital twin state<br/>[twin.py]")]
  node_congestion["Congestion metrics<br/>[congestion.py]"]
  node_inference["GNN inference<br/>[inference.py]"]
  node_ml["Training and data"]
end

subgraph group_simulation["Simulation and decisions"]
  node_sumo["SUMO runner<br/>[runner.py]"]
  node_collector["Traffic collector<br/>[collector.py]"]
  node_decision["Intervention search<br/>[decision.py]"]
  node_plans["Plan scoring<br/>[objective.py]"]
  node_routing["Route estimates<br/>[routing.py]"]
end

subgraph group_memory["Experience memory"]
  node_memory["Experience retrieval<br/>[memory.py]"]
  node_faiss[("FAISS index<br/>[faiss_store.py]")]
  node_db[("Persistent records<br/>[db.py]")]
end

node_user(("Dashboard user"))
node_sumo_external{{"SUMO / TraCI"}}
node_http{{"HTTP API"}}

node_user -->|"uses"| node_pages
node_app -->|"routes to"| node_pages
node_pages -.->|"requests"| node_client
node_client -->|"sends requests"| node_http
node_http -->|"serves"| node_routes
node_routes -->|"reads snapshot"| node_twin
node_routes -->|"starts decision"| node_decision
node_routes -.->|"submits run"| node_jobs
node_decision -->|"tests plans"| node_sumo
node_decision -->|"searches"| node_memory
node_memory -->|"verifies plan"| node_sumo
node_decision -->|"scores candidates"| node_plans
node_sumo -->|"runs simulation"| node_sumo_external
node_sumo -->|"collects measurements"| node_collector
node_collector -->|"syncs observations"| node_twin
node_twin -.->|"provides observations"| node_inference
node_inference -->|"computes index"| node_congestion
node_inference -->|"uses topology"| node_network
node_ml -.->|"trains checkpoint"| node_inference
node_routes -.->|"offers estimates"| node_routing
node_memory -.->|"retrieves vectors"| node_faiss
node_memory -.->|"persists experiences"| node_db

click node_pages "https://github.com/jeevithar3/nexflow/tree/main/frontend/src/pages"
click node_app "https://github.com/jeevithar3/nexflow/blob/main/frontend/src/App.tsx"
click node_client "https://github.com/jeevithar3/nexflow/blob/main/frontend/src/api/client.ts"
click node_routes "https://github.com/jeevithar3/nexflow/blob/main/backend/app/api/v1/routes.py"
click node_services "https://github.com/jeevithar3/nexflow/tree/main/backend/app/services"
click node_jobs "https://github.com/jeevithar3/nexflow/blob/main/backend/app/services/jobs.py"
click node_network "https://github.com/jeevithar3/nexflow/blob/main/backend/app/digital_twin/network.py"
click node_twin "https://github.com/jeevithar3/nexflow/blob/main/backend/app/digital_twin/twin.py"
click node_congestion "https://github.com/jeevithar3/nexflow/blob/main/backend/app/digital_twin/congestion.py"
click node_inference "https://github.com/jeevithar3/nexflow/blob/main/backend/app/ml/inference.py"
click node_ml "https://github.com/jeevithar3/nexflow/tree/main/backend/app/ml"
click node_sumo "https://github.com/jeevithar3/nexflow/blob/main/backend/app/sumo/runner.py"
click node_collector "https://github.com/jeevithar3/nexflow/blob/main/backend/app/sumo/collector.py"
click node_decision "https://github.com/jeevithar3/nexflow/blob/main/backend/app/services/decision.py"
click node_plans "https://github.com/jeevithar3/nexflow/blob/main/backend/app/interventions/objective.py"
click node_routing "https://github.com/jeevithar3/nexflow/blob/main/backend/app/services/routing.py"
click node_memory "https://github.com/jeevithar3/nexflow/blob/main/backend/app/experience_memory/memory.py"
click node_faiss "https://github.com/jeevithar3/nexflow/blob/main/backend/app/experience_memory/faiss_store.py"
click node_db "https://github.com/jeevithar3/nexflow/blob/main/backend/app/models/db.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_pages,node_app,node_client,node_user toneBlue
class node_routes,node_services,node_jobs toneAmber
class node_network,node_twin,node_congestion,node_inference,node_ml,node_http toneMint
class node_sumo,node_collector,node_decision,node_plans,node_routing toneRose
class node_memory,node_faiss,node_db,node_sumo_external toneIndigo
```

## Components

### Dashboard

- [Dashboard pages](https://github.com/jeevithar3/nexflow/tree/main/frontend/src/pages): `frontend/src/pages`
- [Page router](https://github.com/jeevithar3/nexflow/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [API client](https://github.com/jeevithar3/nexflow/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`

### API and orchestration

- [REST endpoints](https://github.com/jeevithar3/nexflow/blob/main/backend/app/api/v1/routes.py): `backend/app/api/v1/routes.py`
- [Decision services](https://github.com/jeevithar3/nexflow/tree/main/backend/app/services): `backend/app/services`
- [Background jobs](https://github.com/jeevithar3/nexflow/blob/main/backend/app/services/jobs.py): `backend/app/services/jobs.py`

### Forecast and twin

- [Road network model](https://github.com/jeevithar3/nexflow/blob/main/backend/app/digital_twin/network.py): `backend/app/digital_twin/network.py`
- [Digital twin state](https://github.com/jeevithar3/nexflow/blob/main/backend/app/digital_twin/twin.py): `backend/app/digital_twin/twin.py`
- [Congestion metrics](https://github.com/jeevithar3/nexflow/blob/main/backend/app/digital_twin/congestion.py): `backend/app/digital_twin/congestion.py`
- [GNN inference](https://github.com/jeevithar3/nexflow/blob/main/backend/app/ml/inference.py): `backend/app/ml/inference.py`
- [Training and data](https://github.com/jeevithar3/nexflow/tree/main/backend/app/ml): `backend/app/ml`

### Simulation and decisions

- [SUMO runner](https://github.com/jeevithar3/nexflow/blob/main/backend/app/sumo/runner.py): `backend/app/sumo/runner.py`
- [Traffic collector](https://github.com/jeevithar3/nexflow/blob/main/backend/app/sumo/collector.py): `backend/app/sumo/collector.py`
- [Intervention search](https://github.com/jeevithar3/nexflow/blob/main/backend/app/services/decision.py): `backend/app/services/decision.py`
- [Plan scoring](https://github.com/jeevithar3/nexflow/blob/main/backend/app/interventions/objective.py): `backend/app/interventions/objective.py`
- [Route estimates](https://github.com/jeevithar3/nexflow/blob/main/backend/app/services/routing.py): `backend/app/services/routing.py`

### Experience memory

- [Experience retrieval](https://github.com/jeevithar3/nexflow/blob/main/backend/app/experience_memory/memory.py): `backend/app/experience_memory/memory.py`
- [FAISS index](https://github.com/jeevithar3/nexflow/blob/main/backend/app/experience_memory/faiss_store.py): `backend/app/experience_memory/faiss_store.py`
- [Persistent records](https://github.com/jeevithar3/nexflow/blob/main/backend/app/models/db.py): `backend/app/models/db.py`

### Other components

- **Dashboard user**
- **SUMO / TraCI**
- **HTTP API**

## Connections

- Dashboard user → Dashboard pages: uses
- Page router → Dashboard pages: routes to (evidence: `frontend/src/App.tsx`)
- Dashboard pages → API client: requests
- API client → HTTP API: sends requests (evidence: `frontend/src/api/client.ts`)
- HTTP API → REST endpoints: serves
- REST endpoints → Digital twin state: reads snapshot (evidence: `backend/app/api/v1/routes.py`)
- REST endpoints → Intervention search: starts decision (evidence: `backend/app/api/v1/routes.py`)
- REST endpoints → Background jobs: submits run
- Intervention search → SUMO runner: tests plans
- Intervention search → Experience retrieval: searches
- Experience retrieval → SUMO runner: verifies plan
- Intervention search → Plan scoring: scores candidates
- SUMO runner → SUMO / TraCI: runs simulation (evidence: `backend/app/sumo/runner.py`)
- SUMO runner → Traffic collector: collects measurements (evidence: `backend/app/sumo/runner.py`)
- Traffic collector → Digital twin state: syncs observations (evidence: `backend/app/digital_twin/twin.py`)
- Digital twin state → GNN inference: provides observations
- GNN inference → Congestion metrics: computes index (evidence: `backend/app/ml/inference.py`)
- GNN inference → Road network model: uses topology (evidence: `backend/app/ml/inference.py`)
- Training and data → GNN inference: trains checkpoint (evidence: `backend/app/ml/inference.py`)
- REST endpoints → Route estimates: offers estimates
- Experience retrieval → FAISS index: retrieves vectors
- Experience retrieval → Persistent records: persists experiences
