# madhavan200/ai-powered-railway-traffic-optimization-system architecture

> Architecture diagram of the GitHub repository madhavan200/ai-powered-railway-traffic-optimization-system, 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/madhavan200/ai-powered-railway-traffic-optimization-system
- Repository: https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system

## Overview

RailSync AI is a railway operations control center: operators sign in, select a role-authorized workspace, inspect live state, and request or apply operational actions. The SPA calls Express feature routes, which invoke isolated Python agents over JSON stdin/stdout; agents share SQLite-backed state and may use Groq for generated recommendations or communications. The README documents scheduling, platform assignment, disruption recovery, passenger communications, simulation, monitoring, human approval, audit, and dashboard capabilities. Several routes and agent links are documented but their implementation details were not sampled.

Main entry points: [`frontend/src/App.jsx`](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/App.jsx) (Operations SPA), [`server/runPython.js`](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/server/runPython.js) (Python process runner), [`server/server.js`](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/server/server.js) (Express API), [`python/shared/data_store.py`](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/shared/data_store.py) (Shared state store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Operator interface"]
  node_spa["Operations SPA<br/>[App.jsx]"]
  node_navigation["Role navigation<br/>[Sidebar.jsx]"]
  node_header["Workspace header<br/>[Header.jsx]"]
  node_login["Login view<br/>[LoginPage.jsx]"]
  node_dashboard_ui["Dashboard view<br/>[DashboardPage.jsx]"]
  node_scheduling_ui["Scheduling view<br/>[SchedulingPage.jsx]"]
  node_platform_ui["Platform view<br/>[PlatformPage.jsx]"]
  node_disruption_ui["Disruption view<br/>[DisruptionPage.jsx]"]
  node_passenger_ui["Passenger comms"]
  node_simulation_ui["Simulation lab"]
  node_monitoring_ui["System monitoring"]
  node_hitl_ui["Approval workspace"]
  node_audit_ui["Audit logs<br/>[AuditLogsPage.jsx]"]
end

subgraph group_api["API gateway"]
  node_gateway["Express API<br/>[server.js]"]
  node_python_runner["Python process runner<br/>[runPython.js]"]
end

subgraph group_agents["Operations agents"]
  node_dashboard_agent["Dashboard agent<br/>[dashboard_agent.py]"]
  node_scheduler_agent["Scheduler agent<br/>[scheduler_agent.py]"]
  node_platform_agent["Platform agent<br/>[platform_agent.py]"]
  node_disruption_agent["Disruption agent"]
  node_passenger_agent["Passenger agent<br/>[passenger_agent.py]"]
  node_simulation_agent["Simulation agent"]
  node_monitoring_agent["Monitoring agent"]
  node_hitl_agent["Human review agent<br/>[hitl_agent.py]"]
  node_audit_agent["Audit agent<br/>[audit_agent.py]"]
end

subgraph group_state["State and intelligence"]
  node_store["Shared state store<br/>[data_store.py]"]
  node_sqlite[("SQLite operations DB")]
  node_groq["Groq language model"]
  node_llm_client["Groq client<br/>[groq_client.py]"]
end

node_operator(("Rail operator"))

node_operator -->|"signs in"| node_login
node_operator -->|"selects workspace"| node_navigation
node_spa -->|"renders"| node_login
node_spa -->|"renders"| node_navigation
node_spa -->|"renders"| node_header
node_spa -->|"renders"| node_dashboard_ui
node_spa -->|"renders"| node_scheduling_ui
node_spa -->|"renders"| node_platform_ui
node_spa -->|"renders"| node_disruption_ui
node_spa -->|"renders"| node_passenger_ui
node_spa -->|"renders"| node_simulation_ui
node_spa -->|"renders"| node_monitoring_ui
node_spa -->|"renders"| node_hitl_ui
node_spa -->|"renders"| node_audit_ui
node_dashboard_ui -.->|"requests API"| node_gateway
node_scheduling_ui -.->|"requests API"| node_gateway
node_platform_ui -->|"requests API"| node_gateway
node_disruption_ui -.->|"requests API"| node_gateway
node_passenger_ui -.->|"requests API"| node_gateway
node_simulation_ui -.->|"requests API"| node_gateway
node_monitoring_ui -.->|"requests API"| node_gateway
node_hitl_ui -.->|"requests API"| node_gateway
node_audit_ui -.->|"requests API"| node_gateway
node_gateway -->|"routes agent calls"| node_python_runner
node_python_runner -.->|"spawns with JSON"| node_dashboard_agent
node_python_runner -->|"spawns with JSON"| node_scheduler_agent
node_python_runner -.->|"spawns with JSON"| node_platform_agent
node_python_runner -.->|"spawns with JSON"| node_disruption_agent
node_python_runner -.->|"spawns with JSON"| node_passenger_agent
node_python_runner -.->|"spawns with JSON"| node_simulation_agent
node_python_runner -.->|"spawns with JSON"| node_monitoring_agent
node_python_runner -->|"spawns with JSON"| node_hitl_agent
node_python_runner -.->|"spawns with JSON"| node_audit_agent
node_dashboard_agent -->|"reads and updates"| node_store
node_scheduler_agent -.->|"uses shared state"| node_store
node_platform_agent -.->|"uses shared state"| node_store
node_disruption_agent -.->|"uses shared state"| node_store
node_passenger_agent -.->|"uses shared state"| node_store
node_simulation_agent -.->|"uses shared state"| node_store
node_monitoring_agent -.->|"uses shared state"| node_store
node_hitl_agent -.->|"uses shared state"| node_store
node_audit_agent -.->|"uses shared state"| node_store
node_store -->|"reads and writes"| node_sqlite
node_dashboard_agent -->|"requests insights"| node_llm_client
node_scheduler_agent -.->|"uses generated guidance"| node_llm_client
node_platform_agent -.->|"uses generated guidance"| node_llm_client
node_disruption_agent -.->|"uses generated guidance"| node_llm_client
node_passenger_agent -.->|"uses generated text"| node_llm_client

click node_spa "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/App.jsx"
click node_navigation "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/components/Sidebar.jsx"
click node_header "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/components/Header.jsx"
click node_login "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/LoginPage.jsx"
click node_dashboard_ui "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/DashboardPage.jsx"
click node_scheduling_ui "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/SchedulingPage.jsx"
click node_platform_ui "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/PlatformPage.jsx"
click node_disruption_ui "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/DisruptionPage.jsx"
click node_passenger_ui "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/PassengerCommsPage.jsx"
click node_simulation_ui "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/SimulationLabPage.jsx"
click node_monitoring_ui "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/SystemMonitoringPage.jsx"
click node_hitl_ui "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/HumanInLoopPage.jsx"
click node_audit_ui "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/AuditLogsPage.jsx"
click node_gateway "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/server/server.js"
click node_python_runner "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/server/runPython.js"
click node_dashboard_agent "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/dashboard_agent.py"
click node_scheduler_agent "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/scheduler_agent.py"
click node_platform_agent "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/platform_agent.py"
click node_disruption_agent "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/disruption_agent.py"
click node_passenger_agent "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/passenger_agent.py"
click node_simulation_agent "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/simulation_agent.py"
click node_monitoring_agent "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/monitoring_agent.py"
click node_hitl_agent "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/hitl_agent.py"
click node_audit_agent "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/audit_agent.py"
click node_store "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/shared/data_store.py"
click node_llm_client "https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/shared/groq_client.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_spa,node_navigation,node_header,node_login,node_dashboard_ui,node_scheduling_ui,node_platform_ui,node_disruption_ui,node_passenger_ui,node_simulation_ui,node_monitoring_ui,node_hitl_ui,node_audit_ui toneBlue
class node_gateway,node_python_runner toneAmber
class node_dashboard_agent,node_scheduler_agent,node_platform_agent,node_disruption_agent,node_passenger_agent,node_simulation_agent,node_monitoring_agent,node_hitl_agent,node_audit_agent toneMint
class node_store,node_sqlite,node_groq,node_llm_client toneRose
class node_operator toneIndigo
```

## Components

### Operator interface

- [Operations SPA](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Role navigation](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/components/Sidebar.jsx): `frontend/src/components/Sidebar.jsx`
- [Workspace header](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/components/Header.jsx): `frontend/src/components/Header.jsx`
- [Login view](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/LoginPage.jsx): `frontend/src/pages/LoginPage.jsx`
- [Dashboard view](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/DashboardPage.jsx): `frontend/src/pages/DashboardPage.jsx`
- [Scheduling view](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/SchedulingPage.jsx): `frontend/src/pages/SchedulingPage.jsx`
- [Platform view](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/PlatformPage.jsx): `frontend/src/pages/PlatformPage.jsx`
- [Disruption view](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/DisruptionPage.jsx): `frontend/src/pages/DisruptionPage.jsx`
- [Passenger comms](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/PassengerCommsPage.jsx): `frontend/src/pages/PassengerCommsPage.jsx`
- [Simulation lab](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/SimulationLabPage.jsx): `frontend/src/pages/SimulationLabPage.jsx`
- [System monitoring](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/SystemMonitoringPage.jsx): `frontend/src/pages/SystemMonitoringPage.jsx`
- [Approval workspace](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/HumanInLoopPage.jsx): `frontend/src/pages/HumanInLoopPage.jsx`
- [Audit logs](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/frontend/src/pages/AuditLogsPage.jsx): `frontend/src/pages/AuditLogsPage.jsx`

### API gateway

- [Express API](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/server/server.js): `server/server.js`
- [Python process runner](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/server/runPython.js): `server/runPython.js`

### Operations agents

- [Dashboard agent](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/dashboard_agent.py): `python/dashboard_agent.py`
- [Scheduler agent](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/scheduler_agent.py): `python/scheduler_agent.py`
- [Platform agent](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/platform_agent.py): `python/platform_agent.py`
- [Disruption agent](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/disruption_agent.py): `python/disruption_agent.py`
- [Passenger agent](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/passenger_agent.py): `python/passenger_agent.py`
- [Simulation agent](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/simulation_agent.py): `python/simulation_agent.py`
- [Monitoring agent](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/monitoring_agent.py): `python/monitoring_agent.py`
- [Human review agent](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/hitl_agent.py): `python/hitl_agent.py`
- [Audit agent](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/audit_agent.py): `python/audit_agent.py`

### State and intelligence

- [Shared state store](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/shared/data_store.py): `python/shared/data_store.py`
- **SQLite operations DB**
- **Groq language model**
- [Groq client](https://github.com/madhavan200/ai-powered-railway-traffic-optimization-system/blob/main/python/shared/groq_client.py): `python/shared/groq_client.py`

### Other components

- **Rail operator**

## Connections

- Rail operator → Login view: signs in
- Rail operator → Role navigation: selects workspace (evidence: `frontend/src/components/Sidebar.jsx`)
- Operations SPA → Login view: renders (evidence: `frontend/src/App.jsx`)
- Operations SPA → Role navigation: renders (evidence: `frontend/src/App.jsx`)
- Operations SPA → Workspace header: renders (evidence: `frontend/src/App.jsx`)
- Operations SPA → Dashboard view: renders (evidence: `frontend/src/App.jsx`)
- Operations SPA → Scheduling view: renders (evidence: `frontend/src/App.jsx`)
- Operations SPA → Platform view: renders (evidence: `frontend/src/App.jsx`)
- Operations SPA → Disruption view: renders (evidence: `frontend/src/App.jsx`)
- Operations SPA → Passenger comms: renders (evidence: `frontend/src/App.jsx`)
- Operations SPA → Simulation lab: renders (evidence: `frontend/src/App.jsx`)
- Operations SPA → System monitoring: renders (evidence: `frontend/src/App.jsx`)
- Operations SPA → Approval workspace: renders (evidence: `frontend/src/App.jsx`)
- Operations SPA → Audit logs: renders (evidence: `frontend/src/App.jsx`)
- Dashboard view → Express API: requests API
- Scheduling view → Express API: requests API
- Platform view → Express API: requests API (evidence: `frontend/src/pages/PlatformPage.jsx`)
- Disruption view → Express API: requests API
- Passenger comms → Express API: requests API
- Simulation lab → Express API: requests API
- System monitoring → Express API: requests API
- Approval workspace → Express API: requests API
- Audit logs → Express API: requests API
- Express API → Python process runner: routes agent calls (evidence: `server/server.js`)
- Python process runner → Dashboard agent: spawns with JSON
- Python process runner → Scheduler agent: spawns with JSON
- Python process runner → Platform agent: spawns with JSON
- Python process runner → Disruption agent: spawns with JSON
- Python process runner → Passenger agent: spawns with JSON
- Python process runner → Simulation agent: spawns with JSON
- Python process runner → Monitoring agent: spawns with JSON
- Python process runner → Human review agent: spawns with JSON
- Python process runner → Audit agent: spawns with JSON
- Dashboard agent → Shared state store: reads and updates (evidence: `python/dashboard_agent.py`)
- Scheduler agent → Shared state store: uses shared state (evidence: `python/scheduler_agent.py`)
- Platform agent → Shared state store: uses shared state (evidence: `python/platform_agent.py`)
- Disruption agent → Shared state store: uses shared state (evidence: `python/disruption_agent.py`)
- Passenger agent → Shared state store: uses shared state (evidence: `python/passenger_agent.py`)
- Simulation agent → Shared state store: uses shared state (evidence: `python/simulation_agent.py`)
- Monitoring agent → Shared state store: uses shared state (evidence: `python/monitoring_agent.py`)
- Human review agent → Shared state store: uses shared state (evidence: `python/hitl_agent.py`)
- Audit agent → Shared state store: uses shared state (evidence: `python/audit_agent.py`)
- Shared state store → SQLite operations DB: reads and writes
- Dashboard agent → Groq client: requests insights (evidence: `python/dashboard_agent.py`)
- Scheduler agent → Groq client: uses generated guidance (evidence: `python/scheduler_agent.py`)
- Platform agent → Groq client: uses generated guidance (evidence: `python/platform_agent.py`)
- Disruption agent → Groq client: uses generated guidance (evidence: `python/disruption_agent.py`)
- Passenger agent → Groq client: uses generated text (evidence: `python/passenger_agent.py`)
