# sumitkumar-990/railway_info architecture

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

- Interactive diagram: https://gitdiagram.com/sumitkumar-990/railway_info
- Repository: https://github.com/sumitkumar-990/railway_info

## Overview

RailVue AI serves passenger tracking and railway operations intelligence. Users enter through the React app; its live-data hook calls the train service, which requests backend APIs, while the backend simulation ticker updates the fleet registry. The APIs expose live status, dynamic ETA, explanations, alerts, and network congestion to the frontend’s passenger and officer views. A separate data pipeline integrates historical delay, station, weather, and derived features for model preparation. The README documents further prediction and analytics capabilities; unsampled route internals are represented only where documented, not as inferred call chains.

Main entry points: [`src/App.tsx`](https://github.com/sumitkumar-990/railway_info/blob/main/src/App.tsx) (App navigation), [`src/services/mockTrainService.ts`](https://github.com/sumitkumar-990/railway_info/blob/main/src/services/mockTrainService.ts) (Train API client), [`backend/app/api/trains.py`](https://github.com/sumitkumar-990/railway_info/blob/main/backend/app/api/trains.py) (Train endpoints), [`backend/data/pipeline.py`](https://github.com/sumitkumar-990/railway_info/blob/main/backend/data/pipeline.py) (Integrated data pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend experience"]
  node_app["App navigation<br/>[App.tsx]"]
  node_live_hook["Live data hook"]
  node_train_service["Train API client"]
  node_passenger["Passenger tracking"]
  node_officer["Operations dashboard"]
  node_eta_view["ETA predictions"]
  node_network_view["Network intelligence"]
  node_analytics["Delay analytics"]
  node_alerts["Alerts and events"]
  node_details["Train details"]
end

subgraph group_api["Backend API"]
  node_api_app["FastAPI application<br/>[main.py]"]
  node_train_api["Train endpoints<br/>[trains.py]"]
  node_network_api["Network endpoints<br/>[network.py]"]
end

subgraph group_operations["Live operations"]
  node_registry["Fleet registry<br/>[train_registry.py]"]
  node_location["Live location"]
  node_congestion["Congestion engine"]
end

subgraph group_prediction["ETA prediction"]
  node_predict["ETA prediction<br/>[predict.py]"]
  node_features["Feature engineering"]
  node_classifier["Delay risk classifier"]
  node_explain["Prediction explanations<br/>[explainability.py]"]
end

subgraph group_data["Data integration"]
  node_data_pipeline["Integrated data pipeline<br/>[pipeline.py]"]
  node_station_master["Station master<br/>[station_master.py]"]
  node_weather_fetch["Weather integration"]
  node_derived["Derived delay features"]
end

node_user(("Passenger or officer"))
node_historical["Historical delay source"]
node_weather(("Open-Meteo weather"))

node_user -->|"uses"| node_app
node_app -->|"loads live data"| node_live_hook
node_app -->|"shows passenger view"| node_passenger
node_app -->|"shows overview"| node_officer
node_app -->|"shows predictions"| node_eta_view
node_app -->|"shows network"| node_network_view
node_app -->|"shows analytics"| node_analytics
node_app -->|"shows alerts"| node_alerts
node_app -->|"shows details"| node_details
node_live_hook -->|"requests fleet data"| node_train_service
node_live_hook -->|"requests train details"| node_train_service
node_train_service -->|"fetches train data"| node_train_api
node_train_service -->|"fetches congestion"| node_network_api
node_train_api -->|"returns train data"| node_train_service
node_network_api -->|"returns congestion"| node_train_service
node_api_app -->|"mounts router"| node_train_api
node_api_app -->|"mounts router"| node_network_api
node_api_app -->|"ticks fleet simulation"| node_registry
node_train_api -.->|"serves fleet data"| node_registry
node_network_api -.->|"computes congestion"| node_congestion
node_registry -.->|"resolves train position"| node_location
node_registry -.->|"recomputes ETA"| node_predict
node_predict -.->|"derives model features"| node_features
node_predict -.->|"classifies delay risk"| node_classifier
node_train_api -.->|"requests explanation"| node_explain
node_data_pipeline -->|"loads delay records"| node_historical
node_data_pipeline -->|"resolves coordinates"| node_station_master
node_data_pipeline -->|"fetches station weather"| node_weather_fetch
node_weather_fetch -.->|"requests weather"| node_weather
node_data_pipeline -->|"fits and transforms"| node_derived

click node_app "https://github.com/sumitkumar-990/railway_info/blob/main/src/App.tsx"
click node_live_hook "https://github.com/sumitkumar-990/railway_info/blob/main/src/hooks/useLiveTrainData.ts"
click node_train_service "https://github.com/sumitkumar-990/railway_info/blob/main/src/services/mockTrainService.ts"
click node_passenger "https://github.com/sumitkumar-990/railway_info/blob/main/src/components/passenger/PassengerTrainTracker.tsx"
click node_officer "https://github.com/sumitkumar-990/railway_info/blob/main/src/components/overview/OverviewDashboard.tsx"
click node_eta_view "https://github.com/sumitkumar-990/railway_info/blob/main/src/components/predictions/EtaPredictionsView.tsx"
click node_network_view "https://github.com/sumitkumar-990/railway_info/blob/main/src/components/network/NetworkIntelligenceView.tsx"
click node_analytics "https://github.com/sumitkumar-990/railway_info/blob/main/src/components/analytics/DelayAnalyticsView.tsx"
click node_alerts "https://github.com/sumitkumar-990/railway_info/blob/main/src/components/alerts/AlertsEventsView.tsx"
click node_details "https://github.com/sumitkumar-990/railway_info/blob/main/src/components/details/TrainDetailsView.tsx"
click node_api_app "https://github.com/sumitkumar-990/railway_info/blob/main/backend/app/main.py"
click node_train_api "https://github.com/sumitkumar-990/railway_info/blob/main/backend/app/api/trains.py"
click node_network_api "https://github.com/sumitkumar-990/railway_info/blob/main/backend/app/api/network.py"
click node_registry "https://github.com/sumitkumar-990/railway_info/blob/main/backend/app/api/train_registry.py"
click node_location "https://github.com/sumitkumar-990/railway_info/blob/main/backend/services/live_location_engine.py"
click node_congestion "https://github.com/sumitkumar-990/railway_info/blob/main/backend/services/congestion_engine.py"
click node_predict "https://github.com/sumitkumar-990/railway_info/blob/main/backend/ml/predict.py"
click node_features "https://github.com/sumitkumar-990/railway_info/blob/main/backend/ml/feature_engineering.py"
click node_classifier "https://github.com/sumitkumar-990/railway_info/blob/main/backend/ml/delay_classifier.py"
click node_explain "https://github.com/sumitkumar-990/railway_info/blob/main/backend/ml/explainability.py"
click node_data_pipeline "https://github.com/sumitkumar-990/railway_info/blob/main/backend/data/pipeline.py"
click node_station_master "https://github.com/sumitkumar-990/railway_info/blob/main/backend/data/station_master.py"
click node_weather_fetch "https://github.com/sumitkumar-990/railway_info/blob/main/backend/data/fetch_open_meteo_weather.py"
click node_derived "https://github.com/sumitkumar-990/railway_info/blob/main/backend/data/derived_features.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_live_hook,node_train_service,node_passenger,node_officer,node_eta_view,node_network_view,node_analytics,node_alerts,node_details toneBlue
class node_api_app,node_train_api,node_network_api toneAmber
class node_registry,node_location,node_congestion toneMint
class node_predict,node_features,node_classifier,node_explain toneRose
class node_data_pipeline,node_station_master,node_weather_fetch,node_derived,node_user,node_historical,node_weather toneIndigo
```

## Components

### Frontend experience

- [App navigation](https://github.com/sumitkumar-990/railway_info/blob/main/src/App.tsx): `src/App.tsx`
- [Live data hook](https://github.com/sumitkumar-990/railway_info/blob/main/src/hooks/useLiveTrainData.ts): `src/hooks/useLiveTrainData.ts`
- [Train API client](https://github.com/sumitkumar-990/railway_info/blob/main/src/services/mockTrainService.ts): `src/services/mockTrainService.ts`
- [Passenger tracking](https://github.com/sumitkumar-990/railway_info/blob/main/src/components/passenger/PassengerTrainTracker.tsx): `src/components/passenger/PassengerTrainTracker.tsx`
- [Operations dashboard](https://github.com/sumitkumar-990/railway_info/blob/main/src/components/overview/OverviewDashboard.tsx): `src/components/overview/OverviewDashboard.tsx`
- [ETA predictions](https://github.com/sumitkumar-990/railway_info/blob/main/src/components/predictions/EtaPredictionsView.tsx): `src/components/predictions/EtaPredictionsView.tsx`
- [Network intelligence](https://github.com/sumitkumar-990/railway_info/blob/main/src/components/network/NetworkIntelligenceView.tsx): `src/components/network/NetworkIntelligenceView.tsx`
- [Delay analytics](https://github.com/sumitkumar-990/railway_info/blob/main/src/components/analytics/DelayAnalyticsView.tsx): `src/components/analytics/DelayAnalyticsView.tsx`
- [Alerts and events](https://github.com/sumitkumar-990/railway_info/blob/main/src/components/alerts/AlertsEventsView.tsx): `src/components/alerts/AlertsEventsView.tsx`
- [Train details](https://github.com/sumitkumar-990/railway_info/blob/main/src/components/details/TrainDetailsView.tsx): `src/components/details/TrainDetailsView.tsx`

### Backend API

- [FastAPI application](https://github.com/sumitkumar-990/railway_info/blob/main/backend/app/main.py): `backend/app/main.py`
- [Train endpoints](https://github.com/sumitkumar-990/railway_info/blob/main/backend/app/api/trains.py): `backend/app/api/trains.py`
- [Network endpoints](https://github.com/sumitkumar-990/railway_info/blob/main/backend/app/api/network.py): `backend/app/api/network.py`

### Live operations

- [Fleet registry](https://github.com/sumitkumar-990/railway_info/blob/main/backend/app/api/train_registry.py): `backend/app/api/train_registry.py`
- [Live location](https://github.com/sumitkumar-990/railway_info/blob/main/backend/services/live_location_engine.py): `backend/services/live_location_engine.py`
- [Congestion engine](https://github.com/sumitkumar-990/railway_info/blob/main/backend/services/congestion_engine.py): `backend/services/congestion_engine.py`

### ETA prediction

- [ETA prediction](https://github.com/sumitkumar-990/railway_info/blob/main/backend/ml/predict.py): `backend/ml/predict.py`
- [Feature engineering](https://github.com/sumitkumar-990/railway_info/blob/main/backend/ml/feature_engineering.py): `backend/ml/feature_engineering.py`
- [Delay risk classifier](https://github.com/sumitkumar-990/railway_info/blob/main/backend/ml/delay_classifier.py): `backend/ml/delay_classifier.py`
- [Prediction explanations](https://github.com/sumitkumar-990/railway_info/blob/main/backend/ml/explainability.py): `backend/ml/explainability.py`

### Data integration

- [Integrated data pipeline](https://github.com/sumitkumar-990/railway_info/blob/main/backend/data/pipeline.py): `backend/data/pipeline.py`
- [Station master](https://github.com/sumitkumar-990/railway_info/blob/main/backend/data/station_master.py): `backend/data/station_master.py`
- [Weather integration](https://github.com/sumitkumar-990/railway_info/blob/main/backend/data/fetch_open_meteo_weather.py): `backend/data/fetch_open_meteo_weather.py`
- [Derived delay features](https://github.com/sumitkumar-990/railway_info/blob/main/backend/data/derived_features.py): `backend/data/derived_features.py`

### Other components

- **Passenger or officer**
- **Historical delay source**
- **Open-Meteo weather**

## Connections

- Passenger or officer → App navigation: uses
- App navigation → Live data hook: loads live data
- App navigation → Passenger tracking: shows passenger view
- App navigation → Operations dashboard: shows overview
- App navigation → ETA predictions: shows predictions
- App navigation → Network intelligence: shows network
- App navigation → Delay analytics: shows analytics
- App navigation → Alerts and events: shows alerts
- App navigation → Train details: shows details
- Live data hook → Train API client: requests fleet data
- Live data hook → Train API client: requests train details
- Train API client → Train endpoints: fetches train data
- Train API client → Network endpoints: fetches congestion
- Train endpoints → Train API client: returns train data
- Network endpoints → Train API client: returns congestion
- FastAPI application → Train endpoints: mounts router
- FastAPI application → Network endpoints: mounts router
- FastAPI application → Fleet registry: ticks fleet simulation
- Train endpoints → Fleet registry: serves fleet data
- Network endpoints → Congestion engine: computes congestion
- Fleet registry → Live location: resolves train position
- Fleet registry → ETA prediction: recomputes ETA
- ETA prediction → Feature engineering: derives model features
- ETA prediction → Delay risk classifier: classifies delay risk
- Train endpoints → Prediction explanations: requests explanation
- Integrated data pipeline → Historical delay source: loads delay records
- Integrated data pipeline → Station master: resolves coordinates
- Integrated data pipeline → Weather integration: fetches station weather
- Weather integration → Open-Meteo weather: requests weather
- Integrated data pipeline → Derived delay features: fits and transforms
