# akash-sharma8/sih2026 architecture

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

- Interactive diagram: https://gitdiagram.com/akash-sharma8/sih2026
- Repository: https://github.com/akash-sharma8/sih2026

## Overview

RailETA is a railway journey ETA product: passengers search for trains or choose a journey, request a live or pre-departure forecast, and receive predictions and disruption context. The backend exposes forecast, search, demo, health/readiness, and staff APIs; forecast logic combines rail-provider data, feature preparation, model inference, and response building. Web and mobile clients consume the API. The README documents the intended forecast architecture; several subsystems are represented from the tree and source index because their implementation excerpts were not supplied.

Main entry points: [`app/services/forecast.py`](https://github.com/akash-sharma8/sih2026/blob/main/app/services/forecast.py) (Forecast orchestration), [`app/api`](https://github.com/akash-sharma8/sih2026/tree/main/app/api) (Forecast endpoints), [`app/main.py`](https://github.com/akash-sharma8/sih2026/blob/main/app/main.py) (FastAPI app), [`app/services/train_search.py`](https://github.com/akash-sharma8/sih2026/blob/main/app/services/train_search.py) (Train search service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Backend API"]
  node_main["FastAPI app<br/>[main.py]"]
  node_forecast_api["Forecast endpoints"]
  node_search_api["Train search endpoint<br/>[train_search.py]"]
  node_health_api["Health and readiness<br/>[health.py]"]
  node_staff_api["Staff endpoint<br/>[staff.py]"]
end

subgraph group_services["Journey Services"]
  node_forecast["Forecast orchestration<br/>[forecast.py]"]
  node_search["Train search service<br/>[train_search.py]"]
  node_cache[("Resilient cache<br/>[cache.py]")]
  node_features["Predeparture features"]
  node_disruptions["Disruption alerts"]
  node_routes["Route and map building"]
end

subgraph group_inference["Forecast Inference"]
  node_adapter["Inference adapter<br/>[adapter.py]"]
  node_models["Three-model routing"]
  node_response["Forecast response builder"]
  node_explain["Model explanations<br/>[explainability.py]"]
  node_ml_demo["Saved-demo runtime<br/>[runtime.py]"]
end

subgraph group_providers["External Data"]
  node_railradar["RailRadar client<br/>[railradar.py]"]
  node_weather["Weather clients"]
end

subgraph group_clients["Passenger Clients"]
  node_web["Web interface"]
  node_web_api["Web API client<br/>[api-client.ts]"]
  node_mobile["Mobile journey screen<br/>[index.tsx]"]
  node_mobile_api["Mobile API client<br/>[client.ts]"]
end

node_user(("Passenger"))
node_staff(("Staff"))
node_rail_provider{{"RailRadar service"}}
node_weather_provider{{"Weather service"}}

node_main -->|"registers routes"| node_forecast_api
node_main -->|"registers routes"| node_search_api
node_main -->|"registers routes"| node_health_api
node_main -->|"registers routes"| node_staff_api
node_forecast_api -.->|"dispatches forecast"| node_forecast
node_search_api -.->|"dispatches search"| node_search
node_forecast -->|"fetches journey"| node_railradar
node_search -->|"searches trains"| node_railradar
node_search -->|"reads and writes"| node_cache
node_forecast -->|"prepares features"| node_features
node_forecast -->|"runs inference"| node_adapter
node_forecast -->|"uses disruption context"| node_disruptions
node_forecast -->|"requests weather data"| node_weather
node_forecast -.->|"builds forecast response"| node_response
node_adapter -.->|"routes by journey stage"| node_models
node_response -.->|"adds explanations"| node_explain
node_railradar -.->|"requests rail data"| node_rail_provider
node_weather -.->|"requests weather"| node_weather_provider
node_web -.->|"requests forecasts"| node_web_api
node_web_api -.->|"calls forecast API"| node_forecast_api
node_mobile -->|"requests journey data"| node_mobile_api
node_mobile_api -.->|"calls forecast API"| node_forecast_api
node_user -.->|"uses"| node_web
node_user -.->|"uses"| node_mobile
node_staff -.->|"requests staff data"| node_staff_api
node_forecast_api -.->|"serves saved demo"| node_ml_demo

click node_main "https://github.com/akash-sharma8/sih2026/blob/main/app/main.py"
click node_forecast_api "https://github.com/akash-sharma8/sih2026/tree/main/app/api"
click node_search_api "https://github.com/akash-sharma8/sih2026/blob/main/app/api/train_search.py"
click node_health_api "https://github.com/akash-sharma8/sih2026/blob/main/app/api/health.py"
click node_staff_api "https://github.com/akash-sharma8/sih2026/blob/main/app/api/staff.py"
click node_forecast "https://github.com/akash-sharma8/sih2026/blob/main/app/services/forecast.py"
click node_search "https://github.com/akash-sharma8/sih2026/blob/main/app/services/train_search.py"
click node_cache "https://github.com/akash-sharma8/sih2026/blob/main/app/services/cache.py"
click node_features "https://github.com/akash-sharma8/sih2026/blob/main/app/services/predeparture_features.py"
click node_disruptions "https://github.com/akash-sharma8/sih2026/blob/main/app/services/disruption_alerts.py"
click node_routes "https://github.com/akash-sharma8/sih2026/blob/main/app/services/route_map_builder.py"
click node_adapter "https://github.com/akash-sharma8/sih2026/blob/main/app/inference/adapter.py"
click node_models "https://github.com/akash-sharma8/sih2026/tree/main/app/inference"
click node_response "https://github.com/akash-sharma8/sih2026/blob/main/app/inference/response_builder.py"
click node_explain "https://github.com/akash-sharma8/sih2026/blob/main/app/inference/explainability.py"
click node_railradar "https://github.com/akash-sharma8/sih2026/blob/main/app/clients/railradar.py"
click node_weather "https://github.com/akash-sharma8/sih2026/tree/main/app/clients"
click node_web "https://github.com/akash-sharma8/sih2026/tree/main/frontend/src/app"
click node_web_api "https://github.com/akash-sharma8/sih2026/blob/main/frontend/src/lib/api/api-client.ts"
click node_mobile "https://github.com/akash-sharma8/sih2026/blob/main/mobile/src/app/index.tsx"
click node_mobile_api "https://github.com/akash-sharma8/sih2026/blob/main/mobile/src/api/client.ts"
click node_ml_demo "https://github.com/akash-sharma8/sih2026/blob/main/ml_handoff/raileta_space/runtime.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_main,node_forecast_api,node_search_api,node_health_api,node_staff_api toneBlue
class node_forecast,node_search,node_cache,node_features,node_disruptions,node_routes toneAmber
class node_adapter,node_models,node_response,node_explain,node_ml_demo toneMint
class node_railradar,node_weather toneRose
class node_web,node_web_api,node_mobile,node_mobile_api,node_user,node_staff,node_rail_provider,node_weather_provider toneIndigo
```

## Components

### Backend API

- [FastAPI app](https://github.com/akash-sharma8/sih2026/blob/main/app/main.py): `app/main.py`
- [Forecast endpoints](https://github.com/akash-sharma8/sih2026/tree/main/app/api): `app/api`
- [Train search endpoint](https://github.com/akash-sharma8/sih2026/blob/main/app/api/train_search.py): `app/api/train_search.py`
- [Health and readiness](https://github.com/akash-sharma8/sih2026/blob/main/app/api/health.py): `app/api/health.py`
- [Staff endpoint](https://github.com/akash-sharma8/sih2026/blob/main/app/api/staff.py): `app/api/staff.py`

### Journey Services

- [Forecast orchestration](https://github.com/akash-sharma8/sih2026/blob/main/app/services/forecast.py): `app/services/forecast.py`
- [Train search service](https://github.com/akash-sharma8/sih2026/blob/main/app/services/train_search.py): `app/services/train_search.py`
- [Resilient cache](https://github.com/akash-sharma8/sih2026/blob/main/app/services/cache.py): `app/services/cache.py`
- [Predeparture features](https://github.com/akash-sharma8/sih2026/blob/main/app/services/predeparture_features.py): `app/services/predeparture_features.py`
- [Disruption alerts](https://github.com/akash-sharma8/sih2026/blob/main/app/services/disruption_alerts.py): `app/services/disruption_alerts.py`
- [Route and map building](https://github.com/akash-sharma8/sih2026/blob/main/app/services/route_map_builder.py): `app/services/route_map_builder.py`

### Forecast Inference

- [Inference adapter](https://github.com/akash-sharma8/sih2026/blob/main/app/inference/adapter.py): `app/inference/adapter.py`
- [Three-model routing](https://github.com/akash-sharma8/sih2026/tree/main/app/inference): `app/inference`
- [Forecast response builder](https://github.com/akash-sharma8/sih2026/blob/main/app/inference/response_builder.py): `app/inference/response_builder.py`
- [Model explanations](https://github.com/akash-sharma8/sih2026/blob/main/app/inference/explainability.py): `app/inference/explainability.py`
- [Saved-demo runtime](https://github.com/akash-sharma8/sih2026/blob/main/ml_handoff/raileta_space/runtime.py): `ml_handoff/raileta_space/runtime.py`

### External Data

- [RailRadar client](https://github.com/akash-sharma8/sih2026/blob/main/app/clients/railradar.py): `app/clients/railradar.py`
- [Weather clients](https://github.com/akash-sharma8/sih2026/tree/main/app/clients): `app/clients`

### Passenger Clients

- [Web interface](https://github.com/akash-sharma8/sih2026/tree/main/frontend/src/app): `frontend/src/app`
- [Web API client](https://github.com/akash-sharma8/sih2026/blob/main/frontend/src/lib/api/api-client.ts): `frontend/src/lib/api/api-client.ts`
- [Mobile journey screen](https://github.com/akash-sharma8/sih2026/blob/main/mobile/src/app/index.tsx): `mobile/src/app/index.tsx`
- [Mobile API client](https://github.com/akash-sharma8/sih2026/blob/main/mobile/src/api/client.ts): `mobile/src/api/client.ts`

### Other components

- **Passenger**
- **Staff**
- **RailRadar service**
- **Weather service**

## Connections

- FastAPI app → Forecast endpoints: registers routes (evidence: `app/main.py`)
- FastAPI app → Train search endpoint: registers routes (evidence: `app/main.py`)
- FastAPI app → Health and readiness: registers routes (evidence: `app/main.py`)
- FastAPI app → Staff endpoint: registers routes (evidence: `app/main.py`)
- Forecast endpoints → Forecast orchestration: dispatches forecast
- Train search endpoint → Train search service: dispatches search
- Forecast orchestration → RailRadar client: fetches journey (evidence: `app/services/forecast.py`)
- Train search service → RailRadar client: searches trains (evidence: `app/services/train_search.py`)
- Train search service → Resilient cache: reads and writes (evidence: `app/services/train_search.py`)
- Forecast orchestration → Predeparture features: prepares features (evidence: `app/services/forecast.py`)
- Forecast orchestration → Inference adapter: runs inference (evidence: `app/services/forecast.py`)
- Forecast orchestration → Disruption alerts: uses disruption context (evidence: `app/services/forecast.py`)
- Forecast orchestration → Weather clients: requests weather data (evidence: `app/services/forecast.py`)
- Forecast orchestration → Forecast response builder: builds forecast response
- Inference adapter → Three-model routing: routes by journey stage
- Forecast response builder → Model explanations: adds explanations
- RailRadar client → RailRadar service: requests rail data
- Weather clients → Weather service: requests weather
- Web interface → Web API client: requests forecasts
- Web API client → Forecast endpoints: calls forecast API
- Mobile journey screen → Mobile API client: requests journey data (evidence: `mobile/src/app/index.tsx`)
- Mobile API client → Forecast endpoints: calls forecast API
- Passenger → Web interface: uses
- Passenger → Mobile journey screen: uses
- Staff → Staff endpoint: requests staff data
- Forecast endpoints → Saved-demo runtime: serves saved demo
