# nmpfriends1997-cyber/flowmind-ai architecture

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

- Interactive diagram: https://gitdiagram.com/nmpfriends1997-cyber/flowmind-ai
- Repository: https://github.com/nmpfriends1997-cyber/flowmind-ai

## Overview

FlowMind AI is a Bengaluru traffic command center. Users explore live and historical traffic, analytics, and incident data, or configure a scenario to obtain congestion predictions, explanations, and diversion recommendations. The frontend routes these workflows through a shared API client; the FastAPI service mounts domain routers backed by a shared ML engine. The graph preserves the documented live-data, assistant, analytics, resource-planning, and scenario capabilities. Some subsystem connections are omitted where the excerpts do not show the wiring.

Main entry points: [`flowmind-ai/frontend/src/App.tsx`](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/App.tsx) (App routing), [`flowmind-ai/backend/main.py`](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/main.py) (FastAPI application), [`flowmind-ai/backend/ml/engine.py`](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/ml/engine.py) (ML and data engine), [`flowmind-ai/frontend/src/lib/api.ts`](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/lib/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_app["App routing<br/>[App.tsx]"]
  node_shell["Navigation shell<br/>[Sidebar.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_command["Command center<br/>[CommandCenter.tsx]"]
  node_citymap["Live and historical map<br/>[CityMap.tsx]"]
  node_simulation["Scenario simulation"]
  node_resourceplan["Resource planning"]
  node_analytics_view["Analytics<br/>[Analytics.tsx]"]
  node_assistant_view["Traffic assistant<br/>[Assistant.tsx]"]
  node_xai["Explainable predictions<br/>[XAI.tsx]"]
  node_compare["Scenario comparison<br/>[Compare.tsx]"]
end

subgraph group_api["API service"]
  node_backend["FastAPI application<br/>[main.py]"]
  node_events["Event endpoints<br/>[events.py]"]
  node_predictions["Prediction endpoints<br/>[predictions.py]"]
  node_resources["Resource endpoints<br/>[resources.py]"]
  node_diversion["Diversion endpoints<br/>[diversion.py]"]
  node_analytics["Analytics endpoints<br/>[analytics.py]"]
  node_realtime["Realtime endpoints<br/>[realtime.py]"]
  node_livedata["Live-data endpoints<br/>[livedata.py]"]
  node_assistant_api["Assistant endpoints<br/>[assistant.py]"]
end

subgraph group_traffic["Traffic intelligence"]
  node_engine["ML and data engine<br/>[engine.py]"]
end

subgraph group_integrations["External integrations"]
  node_tomtom["TomTom services"]
  node_overpass["Overpass service"]
  node_openrouter["OpenRouter models"]
end

node_app -->|"renders"| node_shell
node_app -->|"routes to"| node_command
node_app -->|"routes to"| node_citymap
node_app -->|"routes to"| node_simulation
node_app -->|"routes to"| node_resourceplan
node_app -->|"routes to"| node_analytics_view
node_app -->|"routes to"| node_assistant_view
node_app -->|"routes to"| node_xai
node_app -->|"routes to"| node_compare
node_citymap -->|"requests data"| node_api_client
node_simulation -->|"requests predictions"| node_api_client
node_xai -->|"requests predictions"| node_api_client
node_command -->|"requests data"| node_api_client
node_resourceplan -->|"requests resources"| node_api_client
node_analytics_view -->|"requests analytics"| node_api_client
node_assistant_view -->|"sends chat"| node_api_client
node_compare -->|"requests data"| node_api_client
node_backend -->|"mounts router"| node_events
node_backend -->|"mounts router"| node_predictions
node_backend -->|"mounts router"| node_resources
node_backend -->|"mounts router"| node_diversion
node_backend -->|"mounts router"| node_analytics
node_backend -->|"mounts router"| node_realtime
node_backend -->|"mounts router"| node_livedata
node_backend -->|"mounts router"| node_assistant_api
node_backend -->|"warms up"| node_engine
node_analytics -->|"reads analytics"| node_engine
node_assistant_api -->|"reads traffic context"| node_engine
node_realtime -->|"reads traffic data"| node_engine
node_events -->|"uses engine"| node_engine
node_predictions -->|"uses engine"| node_engine
node_resources -->|"uses engine"| node_engine
node_diversion -->|"uses engine"| node_engine
node_livedata -->|"uses engine"| node_engine
node_livedata -->|"fetches traffic"| node_tomtom
node_livedata -->|"fetches venues"| node_overpass
node_assistant_api -->|"queries models"| node_openrouter

click node_app "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/App.tsx"
click node_shell "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/components/Sidebar.tsx"
click node_api_client "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/lib/api.ts"
click node_command "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/pages/CommandCenter.tsx"
click node_citymap "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/pages/CityMap.tsx"
click node_simulation "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/pages/SimulationStudio.tsx"
click node_resourceplan "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/pages/ResourcePlanner.tsx"
click node_analytics_view "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/pages/Analytics.tsx"
click node_assistant_view "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/pages/Assistant.tsx"
click node_xai "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/pages/XAI.tsx"
click node_compare "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/pages/Compare.tsx"
click node_backend "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/main.py"
click node_events "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/routers/events.py"
click node_predictions "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/routers/predictions.py"
click node_resources "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/routers/resources.py"
click node_diversion "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/routers/diversion.py"
click node_analytics "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/routers/analytics.py"
click node_realtime "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/routers/realtime.py"
click node_livedata "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/routers/livedata.py"
click node_assistant_api "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/routers/assistant.py"
click node_engine "https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/ml/engine.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_app,node_shell,node_api_client,node_command,node_citymap,node_simulation,node_resourceplan,node_analytics_view,node_assistant_view,node_xai,node_compare toneBlue
class node_backend,node_events,node_predictions,node_resources,node_diversion,node_analytics,node_realtime,node_livedata,node_assistant_api toneAmber
class node_engine toneMint
class node_tomtom,node_overpass,node_openrouter toneRose
```

## Components

### Frontend

- [App routing](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/App.tsx): `flowmind-ai/frontend/src/App.tsx`
- [Navigation shell](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/components/Sidebar.tsx): `flowmind-ai/frontend/src/components/Sidebar.tsx`
- [API client](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/lib/api.ts): `flowmind-ai/frontend/src/lib/api.ts`
- [Command center](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/pages/CommandCenter.tsx): `flowmind-ai/frontend/src/pages/CommandCenter.tsx`
- [Live and historical map](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/pages/CityMap.tsx): `flowmind-ai/frontend/src/pages/CityMap.tsx`
- [Scenario simulation](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/pages/SimulationStudio.tsx): `flowmind-ai/frontend/src/pages/SimulationStudio.tsx`
- [Resource planning](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/pages/ResourcePlanner.tsx): `flowmind-ai/frontend/src/pages/ResourcePlanner.tsx`
- [Analytics](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/pages/Analytics.tsx): `flowmind-ai/frontend/src/pages/Analytics.tsx`
- [Traffic assistant](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/pages/Assistant.tsx): `flowmind-ai/frontend/src/pages/Assistant.tsx`
- [Explainable predictions](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/pages/XAI.tsx): `flowmind-ai/frontend/src/pages/XAI.tsx`
- [Scenario comparison](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/frontend/src/pages/Compare.tsx): `flowmind-ai/frontend/src/pages/Compare.tsx`

### API service

- [FastAPI application](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/main.py): `flowmind-ai/backend/main.py`
- [Event endpoints](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/routers/events.py): `flowmind-ai/backend/routers/events.py`
- [Prediction endpoints](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/routers/predictions.py): `flowmind-ai/backend/routers/predictions.py`
- [Resource endpoints](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/routers/resources.py): `flowmind-ai/backend/routers/resources.py`
- [Diversion endpoints](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/routers/diversion.py): `flowmind-ai/backend/routers/diversion.py`
- [Analytics endpoints](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/routers/analytics.py): `flowmind-ai/backend/routers/analytics.py`
- [Realtime endpoints](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/routers/realtime.py): `flowmind-ai/backend/routers/realtime.py`
- [Live-data endpoints](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/routers/livedata.py): `flowmind-ai/backend/routers/livedata.py`
- [Assistant endpoints](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/routers/assistant.py): `flowmind-ai/backend/routers/assistant.py`

### Traffic intelligence

- [ML and data engine](https://github.com/nmpfriends1997-cyber/flowmind-ai/blob/main/flowmind-ai/backend/ml/engine.py): `flowmind-ai/backend/ml/engine.py`

### External integrations

- **TomTom services**
- **Overpass service**
- **OpenRouter models**

## Connections

- App routing → Navigation shell: renders (evidence: `flowmind-ai/frontend/src/App.tsx`)
- App routing → Command center: routes to (evidence: `flowmind-ai/frontend/src/App.tsx`)
- App routing → Live and historical map: routes to (evidence: `flowmind-ai/frontend/src/App.tsx`)
- App routing → Scenario simulation: routes to (evidence: `flowmind-ai/frontend/src/App.tsx`)
- App routing → Resource planning: routes to (evidence: `flowmind-ai/frontend/src/App.tsx`)
- App routing → Analytics: routes to (evidence: `flowmind-ai/frontend/src/App.tsx`)
- App routing → Traffic assistant: routes to (evidence: `flowmind-ai/frontend/src/App.tsx`)
- App routing → Explainable predictions: routes to (evidence: `flowmind-ai/frontend/src/App.tsx`)
- App routing → Scenario comparison: routes to (evidence: `flowmind-ai/frontend/src/App.tsx`)
- Live and historical map → API client: requests data (evidence: `flowmind-ai/frontend/src/pages/CityMap.tsx`)
- Scenario simulation → API client: requests predictions (evidence: `flowmind-ai/frontend/src/pages/SimulationStudio.tsx`)
- Explainable predictions → API client: requests predictions (evidence: `flowmind-ai/frontend/src/pages/XAI.tsx`)
- Command center → API client: requests data (evidence: `flowmind-ai/frontend/src/pages/CommandCenter.tsx`)
- Resource planning → API client: requests resources (evidence: `flowmind-ai/frontend/src/pages/ResourcePlanner.tsx`)
- Analytics → API client: requests analytics (evidence: `flowmind-ai/frontend/src/pages/Analytics.tsx`)
- Traffic assistant → API client: sends chat (evidence: `flowmind-ai/frontend/src/pages/Assistant.tsx`)
- Scenario comparison → API client: requests data (evidence: `flowmind-ai/frontend/src/pages/Compare.tsx`)
- FastAPI application → Event endpoints: mounts router (evidence: `flowmind-ai/backend/main.py`)
- FastAPI application → Prediction endpoints: mounts router (evidence: `flowmind-ai/backend/main.py`)
- FastAPI application → Resource endpoints: mounts router (evidence: `flowmind-ai/backend/main.py`)
- FastAPI application → Diversion endpoints: mounts router (evidence: `flowmind-ai/backend/main.py`)
- FastAPI application → Analytics endpoints: mounts router (evidence: `flowmind-ai/backend/main.py`)
- FastAPI application → Realtime endpoints: mounts router (evidence: `flowmind-ai/backend/main.py`)
- FastAPI application → Live-data endpoints: mounts router (evidence: `flowmind-ai/backend/main.py`)
- FastAPI application → Assistant endpoints: mounts router (evidence: `flowmind-ai/backend/main.py`)
- FastAPI application → ML and data engine: warms up (evidence: `flowmind-ai/backend/main.py`)
- Analytics endpoints → ML and data engine: reads analytics (evidence: `flowmind-ai/backend/routers/analytics.py`)
- Assistant endpoints → ML and data engine: reads traffic context (evidence: `flowmind-ai/backend/routers/assistant.py`)
- Realtime endpoints → ML and data engine: reads traffic data (evidence: `flowmind-ai/backend/routers/realtime.py`)
- Event endpoints → ML and data engine: uses engine (evidence: `flowmind-ai/backend/routers/events.py`)
- Prediction endpoints → ML and data engine: uses engine (evidence: `flowmind-ai/backend/routers/predictions.py`)
- Resource endpoints → ML and data engine: uses engine (evidence: `flowmind-ai/backend/routers/resources.py`)
- Diversion endpoints → ML and data engine: uses engine (evidence: `flowmind-ai/backend/routers/diversion.py`)
- Live-data endpoints → ML and data engine: uses engine (evidence: `flowmind-ai/backend/routers/livedata.py`)
- Live-data endpoints → TomTom services: fetches traffic (evidence: `flowmind-ai/backend/routers/livedata.py`)
- Live-data endpoints → Overpass service: fetches venues (evidence: `flowmind-ai/backend/routers/livedata.py`)
- Assistant endpoints → OpenRouter models: queries models (evidence: `flowmind-ai/backend/routers/assistant.py`)
