# tetashler/mrtcrowd architecture

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

- Interactive diagram: https://gitdiagram.com/tetashler/mrtcrowd
- Repository: https://github.com/tetashler/mrtcrowd

## Overview

MRTCrowd is a mobile-first Singapore MRT companion: passengers browse lines or a map, search stations, and open a line view for live crowd levels, operating status, and favourites. The React app routes between Home and LineScreen; both retrieve crowd data through a shared hook backed by Supabase, while station/line and timetable data drive presentation. Home also surfaces service alerts, a documented capability whose fetching implementation is not shown. Source excerpts support the principal UI calls and crowd-data read; several README capabilities and backend ingestion details are only documented or not evidenced in sampled source.

Main entry points: [`src/components/Home.tsx`](https://github.com/tetashler/mrtcrowd/blob/main/src/components/Home.tsx) (Home search), [`src/components/LineScreen.tsx`](https://github.com/tetashler/mrtcrowd/blob/main/src/components/LineScreen.tsx) (Line detail), [`src/components/InteractiveMap.tsx`](https://github.com/tetashler/mrtcrowd/blob/main/src/components/InteractiveMap.tsx) (Interactive map), [`src/data/stations.ts`](https://github.com/tetashler/mrtcrowd/blob/main/src/data/stations.ts) (Line and station catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Passenger experience"]
  node_app["App router<br/>[App.tsx]"]
  node_home["Home search<br/>[Home.tsx]"]
  node_lineview["Line detail<br/>[LineScreen.tsx]"]
  node_map["Interactive map<br/>[InteractiveMap.tsx]"]
  node_favourites_ui["Favourite stations"]
  node_linecard["Line cards<br/>[LineCard.tsx]"]
  node_stationcard["Station cards<br/>[StationCard.tsx]"]
  node_disruptions["Service alerts"]
  node_popup["Station popup<br/>[StationPopup.tsx]"]
  node_crowdicon["Crowd indicator<br/>[CrowdIcon.tsx]"]
end

subgraph group_domain["Network and service data"]
  node_network["Line and station catalog<br/>[stations.ts]"]
  node_mapstations["Map station layout<br/>[mrtStations.ts]"]
  node_coordinates["Station coordinates"]
  node_positions["Station positions"]
  node_hours["Operating hours<br/>[operatingHours.ts]"]
end

subgraph group_state["User preferences"]
  node_favourite_store["Favourite storage<br/>[favourites.ts]"]
  node_theme["Theme state<br/>[ThemeContext.tsx]"]
  node_view["Map-list state<br/>[ViewContext.tsx]"]
end

subgraph group_live["Live data services"]
  node_crowdhook["Crowd data hook<br/>[useCrowdData.ts]"]
  node_supabase[("Supabase crowd store")]
  node_crowd_sync["Crowd ingestion<br/>[sync-crowd.js]"]
  node_alert_sync["Alert ingestion<br/>[sync-alerts.js]"]
end

node_passenger(("Passenger"))

node_passenger -->|"opens app"| node_app
node_app -->|"routes home"| node_home
node_app -->|"routes line"| node_lineview
node_home -->|"navigates to"| node_lineview
node_home -->|"renders map"| node_map
node_home -->|"renders favourites"| node_favourites_ui
node_home -->|"renders lines"| node_linecard
node_home -->|"renders alerts"| node_disruptions
node_home -->|"uses station catalog"| node_network
node_home -->|"reads theme"| node_theme
node_home -->|"reads view mode"| node_view
node_lineview -->|"renders stations"| node_stationcard
node_lineview -->|"reads line data"| node_network
node_lineview -->|"checks status"| node_hours
node_lineview -->|"loads crowd data"| node_crowdhook
node_lineview -->|"updates favourites"| node_favourite_store
node_lineview -->|"reads theme"| node_theme
node_map -->|"loads crowd data"| node_crowdhook
node_map -->|"uses station layout"| node_mapstations
node_map -->|"shows station hours"| node_hours
node_map -->|"renders indicator"| node_crowdicon
node_map -.->|"shows station details"| node_popup
node_favourites_ui -->|"reads favourites"| node_favourite_store
node_favourites_ui -->|"loads crowd data"| node_crowdhook
node_favourites_ui -->|"reads station names"| node_network
node_linecard -->|"uses line data"| node_network
node_stationcard -->|"uses station data"| node_network
node_crowdhook -->|"queries crowd rows"| node_supabase
node_crowd_sync -.->|"writes crowd rows"| node_supabase
node_alert_sync -.->|"provides service alerts"| node_disruptions
node_coordinates -.->|"supplies coordinates"| node_map
node_positions -.->|"supplies positions"| node_map
node_favourite_store -->|"persists choices"| node_passenger

click node_app "https://github.com/tetashler/mrtcrowd/blob/main/src/App.tsx"
click node_home "https://github.com/tetashler/mrtcrowd/blob/main/src/components/Home.tsx"
click node_lineview "https://github.com/tetashler/mrtcrowd/blob/main/src/components/LineScreen.tsx"
click node_map "https://github.com/tetashler/mrtcrowd/blob/main/src/components/InteractiveMap.tsx"
click node_favourites_ui "https://github.com/tetashler/mrtcrowd/blob/main/src/components/FavouriteStations.tsx"
click node_linecard "https://github.com/tetashler/mrtcrowd/blob/main/src/components/LineCard.tsx"
click node_stationcard "https://github.com/tetashler/mrtcrowd/blob/main/src/components/StationCard.tsx"
click node_disruptions "https://github.com/tetashler/mrtcrowd/blob/main/src/components/DisruptionBanner.tsx"
click node_popup "https://github.com/tetashler/mrtcrowd/blob/main/src/components/StationPopup.tsx"
click node_crowdicon "https://github.com/tetashler/mrtcrowd/blob/main/src/components/CrowdIcon.tsx"
click node_network "https://github.com/tetashler/mrtcrowd/blob/main/src/data/stations.ts"
click node_mapstations "https://github.com/tetashler/mrtcrowd/blob/main/src/data/mrtStations.ts"
click node_coordinates "https://github.com/tetashler/mrtcrowd/blob/main/src/data/stationCoordinates.ts"
click node_positions "https://github.com/tetashler/mrtcrowd/blob/main/src/data/stationPositions.ts"
click node_hours "https://github.com/tetashler/mrtcrowd/blob/main/src/data/operatingHours.ts"
click node_crowdhook "https://github.com/tetashler/mrtcrowd/blob/main/src/hooks/useCrowdData.ts"
click node_crowd_sync "https://github.com/tetashler/mrtcrowd/blob/main/api/sync-crowd.js"
click node_alert_sync "https://github.com/tetashler/mrtcrowd/blob/main/api/sync-alerts.js"
click node_favourite_store "https://github.com/tetashler/mrtcrowd/blob/main/src/utils/favourites.ts"
click node_theme "https://github.com/tetashler/mrtcrowd/blob/main/src/context/ThemeContext.tsx"
click node_view "https://github.com/tetashler/mrtcrowd/blob/main/src/context/ViewContext.tsx"

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_home,node_lineview,node_map,node_favourites_ui,node_linecard,node_stationcard,node_disruptions,node_popup,node_crowdicon toneBlue
class node_network,node_mapstations,node_coordinates,node_positions,node_hours toneAmber
class node_favourite_store,node_theme,node_view toneMint
class node_crowdhook,node_supabase,node_crowd_sync,node_alert_sync toneRose
class node_passenger toneIndigo
```

## Components

### Passenger experience

- [App router](https://github.com/tetashler/mrtcrowd/blob/main/src/App.tsx): `src/App.tsx`
- [Home search](https://github.com/tetashler/mrtcrowd/blob/main/src/components/Home.tsx): `src/components/Home.tsx`
- [Line detail](https://github.com/tetashler/mrtcrowd/blob/main/src/components/LineScreen.tsx): `src/components/LineScreen.tsx`
- [Interactive map](https://github.com/tetashler/mrtcrowd/blob/main/src/components/InteractiveMap.tsx): `src/components/InteractiveMap.tsx`
- [Favourite stations](https://github.com/tetashler/mrtcrowd/blob/main/src/components/FavouriteStations.tsx): `src/components/FavouriteStations.tsx`
- [Line cards](https://github.com/tetashler/mrtcrowd/blob/main/src/components/LineCard.tsx): `src/components/LineCard.tsx`
- [Station cards](https://github.com/tetashler/mrtcrowd/blob/main/src/components/StationCard.tsx): `src/components/StationCard.tsx`
- [Service alerts](https://github.com/tetashler/mrtcrowd/blob/main/src/components/DisruptionBanner.tsx): `src/components/DisruptionBanner.tsx`
- [Station popup](https://github.com/tetashler/mrtcrowd/blob/main/src/components/StationPopup.tsx): `src/components/StationPopup.tsx`
- [Crowd indicator](https://github.com/tetashler/mrtcrowd/blob/main/src/components/CrowdIcon.tsx): `src/components/CrowdIcon.tsx`

### Network and service data

- [Line and station catalog](https://github.com/tetashler/mrtcrowd/blob/main/src/data/stations.ts): `src/data/stations.ts`
- [Map station layout](https://github.com/tetashler/mrtcrowd/blob/main/src/data/mrtStations.ts): `src/data/mrtStations.ts`
- [Station coordinates](https://github.com/tetashler/mrtcrowd/blob/main/src/data/stationCoordinates.ts): `src/data/stationCoordinates.ts`
- [Station positions](https://github.com/tetashler/mrtcrowd/blob/main/src/data/stationPositions.ts): `src/data/stationPositions.ts`
- [Operating hours](https://github.com/tetashler/mrtcrowd/blob/main/src/data/operatingHours.ts): `src/data/operatingHours.ts`

### User preferences

- [Favourite storage](https://github.com/tetashler/mrtcrowd/blob/main/src/utils/favourites.ts): `src/utils/favourites.ts`
- [Theme state](https://github.com/tetashler/mrtcrowd/blob/main/src/context/ThemeContext.tsx): `src/context/ThemeContext.tsx`
- [Map-list state](https://github.com/tetashler/mrtcrowd/blob/main/src/context/ViewContext.tsx): `src/context/ViewContext.tsx`

### Live data services

- [Crowd data hook](https://github.com/tetashler/mrtcrowd/blob/main/src/hooks/useCrowdData.ts): `src/hooks/useCrowdData.ts`
- **Supabase crowd store**
- [Crowd ingestion](https://github.com/tetashler/mrtcrowd/blob/main/api/sync-crowd.js): `api/sync-crowd.js`
- [Alert ingestion](https://github.com/tetashler/mrtcrowd/blob/main/api/sync-alerts.js): `api/sync-alerts.js`

### Other components

- **Passenger**

## Connections

- Passenger → App router: opens app (evidence: `README.md`)
- App router → Home search: routes home (evidence: `src/App.tsx`)
- App router → Line detail: routes line (evidence: `src/App.tsx`)
- Home search → Line detail: navigates to (evidence: `src/components/Home.tsx`)
- Home search → Interactive map: renders map (evidence: `src/components/Home.tsx`)
- Home search → Favourite stations: renders favourites (evidence: `src/components/Home.tsx`)
- Home search → Line cards: renders lines (evidence: `src/components/Home.tsx`)
- Home search → Service alerts: renders alerts (evidence: `src/components/Home.tsx`)
- Home search → Line and station catalog: uses station catalog (evidence: `src/components/Home.tsx`)
- Home search → Theme state: reads theme (evidence: `src/components/Home.tsx`)
- Home search → Map-list state: reads view mode (evidence: `src/components/Home.tsx`)
- Line detail → Station cards: renders stations (evidence: `src/components/LineScreen.tsx`)
- Line detail → Line and station catalog: reads line data (evidence: `src/components/LineScreen.tsx`)
- Line detail → Operating hours: checks status (evidence: `src/components/LineScreen.tsx`)
- Line detail → Crowd data hook: loads crowd data (evidence: `src/components/LineScreen.tsx`)
- Line detail → Favourite storage: updates favourites (evidence: `src/components/LineScreen.tsx`)
- Line detail → Theme state: reads theme (evidence: `src/components/LineScreen.tsx`)
- Interactive map → Crowd data hook: loads crowd data (evidence: `src/components/InteractiveMap.tsx`)
- Interactive map → Map station layout: uses station layout (evidence: `src/components/InteractiveMap.tsx`)
- Interactive map → Operating hours: shows station hours (evidence: `src/components/InteractiveMap.tsx`)
- Interactive map → Crowd indicator: renders indicator (evidence: `src/components/InteractiveMap.tsx`)
- Interactive map → Station popup: shows station details
- Favourite stations → Favourite storage: reads favourites (evidence: `src/components/FavouriteStations.tsx`)
- Favourite stations → Crowd data hook: loads crowd data (evidence: `src/components/FavouriteStations.tsx`)
- Favourite stations → Line and station catalog: reads station names (evidence: `src/components/FavouriteStations.tsx`)
- Line cards → Line and station catalog: uses line data (evidence: `src/components/LineCard.tsx`)
- Station cards → Line and station catalog: uses station data (evidence: `src/components/StationCard.tsx`)
- Crowd data hook → Supabase crowd store: queries crowd rows (evidence: `src/hooks/useCrowdData.ts`)
- Crowd ingestion → Supabase crowd store: writes crowd rows
- Alert ingestion → Service alerts: provides service alerts
- Station coordinates → Interactive map: supplies coordinates
- Station positions → Interactive map: supplies positions
- Favourite storage → Passenger: persists choices (evidence: `src/utils/favourites.ts`)
