# yashhhh2526/rail_safe_alert- architecture

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

- Interactive diagram: https://gitdiagram.com/yashhhh2526/rail_safe_alert-
- Repository: https://github.com/yashhhh2526/rail_safe_alert-

## Overview

RailSafe Alert is a railway journey tracker whose central workflow is train search, route and destination selection, live monitoring, then an approaching-destination alarm. The web client is the most fully documented product surface, backed by an Express API, train data and persistent account/journey services; the tree also includes a separate React Native client. README documents capabilities that the sampled excerpts do not fully expose, so those relationships are cited to the README; uncertain implementation links are omitted.

Main entry points: [`web-frontend/src/App.jsx`](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/App.jsx) (Web app routing), [`web-frontend/src/pages/TrainDetails.jsx`](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/pages/TrainDetails.jsx) (Route and alarm setup), [`web-frontend/src/pages/ActiveAlarm.jsx`](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/pages/ActiveAlarm.jsx) (Active monitoring), [`backend/server.js`](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/backend/server.js) (Express API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web journey experience"]
  node_web_app["Web app routing<br/>[App.jsx]"]
  node_train_search["Train search<br/>[Home.jsx]"]
  node_route_setup["Route and alarm setup<br/>[TrainDetails.jsx]"]
  node_journey_history["Journey history<br/>[Journeys.jsx]"]
  node_preferences["Alarm preferences<br/>[Settings.jsx]"]
  node_auth_client["Authentication client<br/>[authService.js]"]
  node_journey_client["Journey persistence client<br/>[journeyService.js]"]
end

subgraph group_tracking["Tracking and alerts"]
  node_tracking_view["Active monitoring<br/>[ActiveAlarm.jsx]"]
  node_telemetry_client["Telemetry client"]
  node_eta_helpers["ETA and time helpers<br/>[timeUtils.js]"]
  node_client_distance["Route distance math<br/>[railwayDistance.js]"]
  node_alarm_engine["Multisensory alarm"]
  node_settings_store["Preference storage<br/>[settingsService.js]"]
end

subgraph group_api["Backend API"]
  node_api_server["Express API<br/>[server.js]"]
  node_train_routes["Train and telemetry routes<br/>[trains.js]"]
  node_auth_routes["Account routes<br/>[auth.js]"]
  node_journey_routes["Journey routes<br/>[journey.js]"]
  node_rail_distance["Rail kilometrage service"]
end

subgraph group_data["Persistence and integrations"]
  node_demo_data["Timetable and demo trains<br/>[demoTrains.js]"]
  node_database[("MySQL database<br/>[database.js]")]
  node_railradar["RailRadar telemetry"]
  node_device_alerts["Browser alert APIs"]
end

node_passenger(("Passenger"))

node_passenger -->|"uses"| node_web_app
node_web_app -->|"routes to"| node_train_search
node_web_app -->|"routes to"| node_route_setup
node_web_app -->|"routes to"| node_tracking_view
node_web_app -->|"routes to"| node_journey_history
node_web_app -->|"routes to"| node_preferences
node_train_search -->|"selects train"| node_route_setup
node_route_setup -->|"starts monitoring"| node_tracking_view
node_route_setup -->|"calculates route distance"| node_client_distance
node_route_setup -->|"requests telemetry"| node_telemetry_client
node_route_setup -->|"saves journey"| node_journey_client
node_tracking_view -->|"fetches live data"| node_telemetry_client
node_tracking_view -->|"uses time helpers"| node_eta_helpers
node_tracking_view -->|"reads preferences"| node_settings_store
node_tracking_view -->|"triggers alarm"| node_alarm_engine
node_alarm_engine -->|"uses audio vibration speech"| node_device_alerts
node_preferences -->|"stores preferences"| node_settings_store
node_preferences -->|"previews sound"| node_alarm_engine
node_journey_history -->|"loads journeys"| node_journey_client
node_journey_client -->|"gets token"| node_auth_client
node_auth_client -->|"calls account API"| node_api_server
node_journey_client -->|"calls journey API"| node_api_server
node_telemetry_client -->|"requests live endpoint"| node_api_server
node_api_server -->|"mounts routes"| node_train_routes
node_api_server -->|"mounts routes"| node_auth_routes
node_api_server -->|"mounts routes"| node_journey_routes
node_train_routes -->|"processes route distances"| node_rail_distance
node_train_routes -->|"uses train profiles"| node_demo_data
node_train_routes -.->|"proxies telemetry"| node_railradar
node_auth_routes -->|"persists accounts"| node_database
node_journey_routes -->|"persists journeys"| node_database
node_train_search -->|"uses verified search data"| node_demo_data

click node_web_app "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/App.jsx"
click node_train_search "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/pages/Home.jsx"
click node_route_setup "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/pages/TrainDetails.jsx"
click node_journey_history "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/pages/Journeys.jsx"
click node_preferences "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/pages/Settings.jsx"
click node_tracking_view "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/pages/ActiveAlarm.jsx"
click node_telemetry_client "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/services/liveTrackingService.js"
click node_eta_helpers "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/utils/timeUtils.js"
click node_client_distance "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/utils/railwayDistance.js"
click node_alarm_engine "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/utils/alarmAudioService.js"
click node_settings_store "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/utils/settingsService.js"
click node_auth_client "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/utils/authService.js"
click node_journey_client "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/utils/journeyService.js"
click node_api_server "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/backend/server.js"
click node_train_routes "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/backend/routes/trains.js"
click node_auth_routes "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/backend/routes/auth.js"
click node_journey_routes "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/backend/routes/journey.js"
click node_rail_distance "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/backend/services/railwayDistanceService.js"
click node_demo_data "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/backend/data/demoTrains.js"
click node_database "https://github.com/yashhhh2526/rail_safe_alert-/blob/main/backend/config/database.js"

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_web_app,node_train_search,node_route_setup,node_journey_history,node_preferences,node_auth_client,node_journey_client toneBlue
class node_tracking_view,node_telemetry_client,node_eta_helpers,node_client_distance,node_alarm_engine,node_settings_store toneAmber
class node_api_server,node_train_routes,node_auth_routes,node_journey_routes,node_rail_distance toneMint
class node_demo_data,node_database,node_railradar,node_device_alerts toneRose
class node_passenger toneIndigo
```

## Components

### Web journey experience

- [Web app routing](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/App.jsx): `web-frontend/src/App.jsx`
- [Train search](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/pages/Home.jsx): `web-frontend/src/pages/Home.jsx`
- [Route and alarm setup](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/pages/TrainDetails.jsx): `web-frontend/src/pages/TrainDetails.jsx`
- [Journey history](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/pages/Journeys.jsx): `web-frontend/src/pages/Journeys.jsx`
- [Alarm preferences](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/pages/Settings.jsx): `web-frontend/src/pages/Settings.jsx`
- [Authentication client](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/utils/authService.js): `web-frontend/src/utils/authService.js`
- [Journey persistence client](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/utils/journeyService.js): `web-frontend/src/utils/journeyService.js`

### Tracking and alerts

- [Active monitoring](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/pages/ActiveAlarm.jsx): `web-frontend/src/pages/ActiveAlarm.jsx`
- [Telemetry client](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/services/liveTrackingService.js): `web-frontend/src/services/liveTrackingService.js`
- [ETA and time helpers](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/utils/timeUtils.js): `web-frontend/src/utils/timeUtils.js`
- [Route distance math](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/utils/railwayDistance.js): `web-frontend/src/utils/railwayDistance.js`
- [Multisensory alarm](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/utils/alarmAudioService.js): `web-frontend/src/utils/alarmAudioService.js`
- [Preference storage](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/web-frontend/src/utils/settingsService.js): `web-frontend/src/utils/settingsService.js`

### Backend API

- [Express API](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/backend/server.js): `backend/server.js`
- [Train and telemetry routes](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/backend/routes/trains.js): `backend/routes/trains.js`
- [Account routes](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/backend/routes/auth.js): `backend/routes/auth.js`
- [Journey routes](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/backend/routes/journey.js): `backend/routes/journey.js`
- [Rail kilometrage service](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/backend/services/railwayDistanceService.js): `backend/services/railwayDistanceService.js`

### Persistence and integrations

- [Timetable and demo trains](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/backend/data/demoTrains.js): `backend/data/demoTrains.js`
- [MySQL database](https://github.com/yashhhh2526/rail_safe_alert-/blob/main/backend/config/database.js): `backend/config/database.js`
- **RailRadar telemetry**
- **Browser alert APIs**

### Other components

- **Passenger**

## Connections

- Passenger → Web app routing: uses (evidence: `README.md`)
- Web app routing → Train search: routes to (evidence: `web-frontend/src/App.jsx`)
- Web app routing → Route and alarm setup: routes to (evidence: `web-frontend/src/App.jsx`)
- Web app routing → Active monitoring: routes to (evidence: `web-frontend/src/App.jsx`)
- Web app routing → Journey history: routes to (evidence: `web-frontend/src/App.jsx`)
- Web app routing → Alarm preferences: routes to (evidence: `web-frontend/src/App.jsx`)
- Train search → Route and alarm setup: selects train (evidence: `README.md`)
- Route and alarm setup → Active monitoring: starts monitoring (evidence: `README.md`)
- Route and alarm setup → Route distance math: calculates route distance (evidence: `web-frontend/src/pages/TrainDetails.jsx`)
- Route and alarm setup → Telemetry client: requests telemetry (evidence: `web-frontend/src/pages/TrainDetails.jsx`)
- Route and alarm setup → Journey persistence client: saves journey (evidence: `web-frontend/src/pages/TrainDetails.jsx`)
- Active monitoring → Telemetry client: fetches live data (evidence: `web-frontend/src/pages/ActiveAlarm.jsx`)
- Active monitoring → ETA and time helpers: uses time helpers (evidence: `web-frontend/src/pages/ActiveAlarm.jsx`)
- Active monitoring → Preference storage: reads preferences (evidence: `web-frontend/src/pages/ActiveAlarm.jsx`)
- Active monitoring → Multisensory alarm: triggers alarm (evidence: `README.md`)
- Multisensory alarm → Browser alert APIs: uses audio vibration speech (evidence: `web-frontend/src/utils/alarmAudioService.js`)
- Alarm preferences → Preference storage: stores preferences (evidence: `web-frontend/src/pages/Settings.jsx`)
- Alarm preferences → Multisensory alarm: previews sound (evidence: `web-frontend/src/pages/Settings.jsx`)
- Journey history → Journey persistence client: loads journeys (evidence: `web-frontend/src/pages/Journeys.jsx`)
- Journey persistence client → Authentication client: gets token (evidence: `web-frontend/src/utils/journeyService.js`)
- Authentication client → Express API: calls account API (evidence: `web-frontend/src/utils/authService.js`)
- Journey persistence client → Express API: calls journey API (evidence: `web-frontend/src/utils/journeyService.js`)
- Telemetry client → Express API: requests live endpoint (evidence: `web-frontend/src/services/liveTrackingService.js`)
- Express API → Train and telemetry routes: mounts routes (evidence: `backend/server.js`)
- Express API → Account routes: mounts routes (evidence: `backend/server.js`)
- Express API → Journey routes: mounts routes (evidence: `backend/server.js`)
- Train and telemetry routes → Rail kilometrage service: processes route distances (evidence: `backend/routes/trains.js`)
- Train and telemetry routes → Timetable and demo trains: uses train profiles (evidence: `backend/routes/trains.js`)
- Train and telemetry routes → RailRadar telemetry: proxies telemetry (evidence: `README.md`)
- Account routes → MySQL database: persists accounts (evidence: `README.md`)
- Journey routes → MySQL database: persists journeys (evidence: `README.md`)
- Train search → Timetable and demo trains: uses verified search data (evidence: `web-frontend/src/pages/Home.jsx`)
