# raphbag/webtrain architecture

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

- Interactive diagram: https://gitdiagram.com/raphbag/webtrain
- Repository: https://github.com/raphbag/webtrain

## Overview

WebTrain is a French rail-information site: users view stations and rail lines on a map, filter transport modes, and inspect station departures/arrivals and service disruptions. Its browser UI is backed by Astro API routes that proxy IDFM and SNCF data; additional routes support theoretical schedules and trip details. The README documents the major UI and API capabilities, while sampled source confirms selected proxy, enrichment, and rendering behavior. The client-to-route wiring and several route implementations were not shown, so those links are marked unverified or omitted.

Main entry points: [`src/scripts/stopMonitoring.ts`](https://github.com/raphbag/webtrain/blob/master/src/scripts/stopMonitoring.ts) (Schedules and disruptions), [`src/pages/index.astro`](https://github.com/raphbag/webtrain/blob/master/src/pages/index.astro) (Map page), [`src/components/formTheoreticalSchedule.astro`](https://github.com/raphbag/webtrain/blob/master/src/components/formTheoreticalSchedule.astro) (Theoretical schedule form), [`src/pages/api/idfm/horaires.json.ts`](https://github.com/raphbag/webtrain/blob/master/src/pages/api/idfm/horaires.json.ts) (IDFM live times)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Map and interface"]
  node_home["Map page<br/>[index.astro]"]
  node_filters["Mode filters<br/>[FilterPanel.astro]"]
  node_header["Site header<br/>[Header.astro]"]
  node_monitor["Schedules and disruptions<br/>[stopMonitoring.ts]"]
  node_theoretical_ui["Theoretical schedule form"]
  node_theoretical_page["Theoretical schedules page"]
end

subgraph group_idfm["IDFM services"]
  node_idfm_stations["IDFM stations<br/>[gares.json.ts]"]
  node_idfm_lines["IDFM lines<br/>[lignes.json.ts]"]
  node_idfm_times["IDFM live times<br/>[horaires.json.ts]"]
  node_idfm_disruptions["IDFM disruptions"]
  node_idfm_theoretical["IDFM theoretical times<br/>[theoriques.json.ts]"]
  node_idfm_trip["IDFM trip details<br/>[trajet.json.ts]"]
end

subgraph group_sncf["SNCF services"]
  node_sncf_stations["SNCF stations<br/>[gares.json.ts]"]
  node_sncf_lines["SNCF lines<br/>[lignes.json.ts]"]
  node_sncf_times["SNCF live times<br/>[horaires.json.ts]"]
  node_sncf_disruptions["SNCF disruptions"]
end

subgraph group_providers["External data"]
  node_google_maps["Google Maps"]
  node_idfm_api["IDFM PRIM"]
  node_sncf_api["SNCF Navitia"]
  node_siri_api["SNCF SIRI Lite"]
end

node_traveler(("Traveler"))

node_traveler -->|"views map"| node_home
node_home -->|"renders map"| node_google_maps
node_home -->|"offers filters"| node_filters
node_home -.->|"shows live info"| node_monitor
node_theoretical_page -.->|"presents form"| node_theoretical_ui
node_theoretical_ui -.->|"requests schedules"| node_idfm_theoretical
node_monitor -.->|"requests times"| node_idfm_times
node_monitor -.->|"requests disruptions"| node_idfm_disruptions
node_monitor -.->|"requests times"| node_sncf_times
node_monitor -.->|"requests disruptions"| node_sncf_disruptions
node_monitor -.->|"requests trip details"| node_idfm_trip
node_idfm_stations -->|"fetches stations"| node_idfm_api
node_idfm_lines -->|"fetches lines"| node_idfm_api
node_idfm_times -->|"fetches live times"| node_idfm_api
node_idfm_disruptions -->|"fetches reports"| node_idfm_api
node_idfm_theoretical -->|"fetches schedules"| node_idfm_api
node_idfm_trip -->|"fetches trip"| node_idfm_api
node_sncf_stations -->|"fetches stations"| node_sncf_api
node_sncf_lines -->|"fetches lines"| node_sncf_api
node_sncf_disruptions -->|"fetches reports"| node_sncf_api
node_sncf_times -->|"fetches SIRI feed"| node_siri_api

click node_home "https://github.com/raphbag/webtrain/blob/master/src/pages/index.astro"
click node_filters "https://github.com/raphbag/webtrain/blob/master/src/components/FilterPanel.astro"
click node_header "https://github.com/raphbag/webtrain/blob/master/src/components/Header.astro"
click node_monitor "https://github.com/raphbag/webtrain/blob/master/src/scripts/stopMonitoring.ts"
click node_theoretical_ui "https://github.com/raphbag/webtrain/blob/master/src/components/formTheoreticalSchedule.astro"
click node_theoretical_page "https://github.com/raphbag/webtrain/blob/master/src/pages/horaires-theoriques.astro"
click node_idfm_stations "https://github.com/raphbag/webtrain/blob/master/src/pages/api/idfm/gares.json.ts"
click node_idfm_lines "https://github.com/raphbag/webtrain/blob/master/src/pages/api/idfm/lignes.json.ts"
click node_idfm_times "https://github.com/raphbag/webtrain/blob/master/src/pages/api/idfm/horaires.json.ts"
click node_idfm_disruptions "https://github.com/raphbag/webtrain/blob/master/src/pages/api/idfm/perturbations.json.ts"
click node_idfm_theoretical "https://github.com/raphbag/webtrain/blob/master/src/pages/api/idfm/theoriques.json.ts"
click node_idfm_trip "https://github.com/raphbag/webtrain/blob/master/src/pages/api/idfm/trajet.json.ts"
click node_sncf_stations "https://github.com/raphbag/webtrain/blob/master/src/pages/api/sncf/gares.json.ts"
click node_sncf_lines "https://github.com/raphbag/webtrain/blob/master/src/pages/api/sncf/lignes.json.ts"
click node_sncf_times "https://github.com/raphbag/webtrain/blob/master/src/pages/api/sncf/horaires.json.ts"
click node_sncf_disruptions "https://github.com/raphbag/webtrain/blob/master/src/pages/api/sncf/perturbations.json.ts"

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_home,node_filters,node_header,node_monitor,node_theoretical_ui,node_theoretical_page toneBlue
class node_idfm_stations,node_idfm_lines,node_idfm_times,node_idfm_disruptions,node_idfm_theoretical,node_idfm_trip toneAmber
class node_sncf_stations,node_sncf_lines,node_sncf_times,node_sncf_disruptions toneMint
class node_google_maps,node_idfm_api,node_sncf_api,node_siri_api toneRose
class node_traveler toneIndigo
```

## Components

### Map and interface

- [Map page](https://github.com/raphbag/webtrain/blob/master/src/pages/index.astro): `src/pages/index.astro`
- [Mode filters](https://github.com/raphbag/webtrain/blob/master/src/components/FilterPanel.astro): `src/components/FilterPanel.astro`
- [Site header](https://github.com/raphbag/webtrain/blob/master/src/components/Header.astro): `src/components/Header.astro`
- [Schedules and disruptions](https://github.com/raphbag/webtrain/blob/master/src/scripts/stopMonitoring.ts): `src/scripts/stopMonitoring.ts`
- [Theoretical schedule form](https://github.com/raphbag/webtrain/blob/master/src/components/formTheoreticalSchedule.astro): `src/components/formTheoreticalSchedule.astro`
- [Theoretical schedules page](https://github.com/raphbag/webtrain/blob/master/src/pages/horaires-theoriques.astro): `src/pages/horaires-theoriques.astro`

### IDFM services

- [IDFM stations](https://github.com/raphbag/webtrain/blob/master/src/pages/api/idfm/gares.json.ts): `src/pages/api/idfm/gares.json.ts`
- [IDFM lines](https://github.com/raphbag/webtrain/blob/master/src/pages/api/idfm/lignes.json.ts): `src/pages/api/idfm/lignes.json.ts`
- [IDFM live times](https://github.com/raphbag/webtrain/blob/master/src/pages/api/idfm/horaires.json.ts): `src/pages/api/idfm/horaires.json.ts`
- [IDFM disruptions](https://github.com/raphbag/webtrain/blob/master/src/pages/api/idfm/perturbations.json.ts): `src/pages/api/idfm/perturbations.json.ts`
- [IDFM theoretical times](https://github.com/raphbag/webtrain/blob/master/src/pages/api/idfm/theoriques.json.ts): `src/pages/api/idfm/theoriques.json.ts`
- [IDFM trip details](https://github.com/raphbag/webtrain/blob/master/src/pages/api/idfm/trajet.json.ts): `src/pages/api/idfm/trajet.json.ts`

### SNCF services

- [SNCF stations](https://github.com/raphbag/webtrain/blob/master/src/pages/api/sncf/gares.json.ts): `src/pages/api/sncf/gares.json.ts`
- [SNCF lines](https://github.com/raphbag/webtrain/blob/master/src/pages/api/sncf/lignes.json.ts): `src/pages/api/sncf/lignes.json.ts`
- [SNCF live times](https://github.com/raphbag/webtrain/blob/master/src/pages/api/sncf/horaires.json.ts): `src/pages/api/sncf/horaires.json.ts`
- [SNCF disruptions](https://github.com/raphbag/webtrain/blob/master/src/pages/api/sncf/perturbations.json.ts): `src/pages/api/sncf/perturbations.json.ts`

### External data

- **Google Maps**
- **IDFM PRIM**
- **SNCF Navitia**
- **SNCF SIRI Lite**

### Other components

- **Traveler**

## Connections

- Traveler → Map page: views map (evidence: `README.md`)
- Map page → Google Maps: renders map (evidence: `README.md`)
- Map page → Mode filters: offers filters (evidence: `README.md`)
- Map page → Schedules and disruptions: shows live info
- Theoretical schedules page → Theoretical schedule form: presents form
- Theoretical schedule form → IDFM theoretical times: requests schedules
- Schedules and disruptions → IDFM live times: requests times
- Schedules and disruptions → IDFM disruptions: requests disruptions
- Schedules and disruptions → SNCF live times: requests times
- Schedules and disruptions → SNCF disruptions: requests disruptions
- Schedules and disruptions → IDFM trip details: requests trip details
- IDFM stations → IDFM PRIM: fetches stations (evidence: `README.md`)
- IDFM lines → IDFM PRIM: fetches lines (evidence: `README.md`)
- IDFM live times → IDFM PRIM: fetches live times (evidence: `src/pages/api/idfm/horaires.json.ts`)
- IDFM disruptions → IDFM PRIM: fetches reports (evidence: `src/pages/api/idfm/perturbations.json.ts`)
- IDFM theoretical times → IDFM PRIM: fetches schedules (evidence: `src/pages/api/idfm/theoriques.json.ts`)
- IDFM trip details → IDFM PRIM: fetches trip (evidence: `src/pages/api/idfm/trajet.json.ts`)
- SNCF stations → SNCF Navitia: fetches stations (evidence: `README.md`)
- SNCF lines → SNCF Navitia: fetches lines (evidence: `README.md`)
- SNCF disruptions → SNCF Navitia: fetches reports (evidence: `src/pages/api/sncf/perturbations.json.ts`)
- SNCF live times → SNCF SIRI Lite: fetches SIRI feed (evidence: `src/pages/api/sncf/horaires.json.ts`)
