# revaix7/ottatransit architecture

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

- Interactive diagram: https://gitdiagram.com/revaix7/ottatransit
- Repository: https://github.com/revaix7/ottatransit

## Overview

OttaTransit serves nearby Ottawa stops, live and scheduled departures, stop and route views, favourites, and a vehicle map. The browser obtains location, requests data through the app’s API, and presents arrivals and route selections; the server loads static GTFS data and refreshes realtime feeds before serving API responses. The graph preserves these stages and the map/favourites branches. Frontend calls are supported by excerpts and index references; server details are based on the README and source index, so unsampled implementation links are limited to documented relationships.

Main entry points: [`src/App.jsx`](https://github.com/revaix7/ottatransit/blob/master/src/App.jsx) (App coordinator), [`src/lib/api.js`](https://github.com/revaix7/ottatransit/blob/master/src/lib/api.js) (JSON API client), [`server/index.js`](https://github.com/revaix7/ottatransit/blob/master/server/index.js) (Express API), [`server/realtime.js`](https://github.com/revaix7/ottatransit/blob/master/server/realtime.js) (Realtime refresh and snapshot)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Transit experience"]
  node_app["App coordinator<br/>[App.jsx]"]
  node_nearby_ui["Nearby and favourites<br/>[NearbySheet.jsx]"]
  node_stop_ui["Stop departures<br/>[StopView.jsx]"]
  node_map_ui["Live map<br/>[MapView.jsx]"]
  node_route_ui["Route banner<br/>[RouteBanner.jsx]"]
  node_favorites_ui["Saved routes and stops<br/>[Favorites.jsx]"]
  node_stop_card["Stop card<br/>[StopCard.jsx]"]
  node_departures["Departure grouping<br/>[departures.js]"]
  node_favorites_store[("Favourite state<br/>[favorites.js]")]
end

subgraph group_frontend_data["Browser data"]
  node_location["Location lookup<br/>[useGeolocation.js]"]
  node_nearby_query["Nearby stops query<br/>[useNearby.js]"]
  node_arrivals_query["Arrivals queries<br/>[useArrivals.js]"]
  node_map_queries["Map stop and rail queries<br/>[useMapStops.js]"]
  node_vehicle_query["Vehicle query<br/>[useVehicles.js]"]
  node_route_queries["Route detail queries<br/>[useRouteDetails.js]"]
  node_http_client["JSON API client<br/>[api.js]"]
end

subgraph group_server["Transit server"]
  node_api_server["Express API<br/>[index.js]"]
  node_gtfs_import["Static GTFS import<br/>[gtfs.js]"]
  node_realtime_refresh["Realtime refresh and snapshot<br/>[realtime.js]"]
end

subgraph group_storage["Schedule and realtime data"]
  node_schedule_db[("GTFS SQLite data<br/>[gtfs.js]")]
  node_realtime_db[("Realtime snapshot<br/>[realtime.js]")]
end

node_rider(("Rider"))
node_static_feed["OC Transpo static feed"]
node_realtime_feed{{"OC Transpo realtime feeds"}}

node_rider -->|"uses"| node_app
node_app -->|"gets location"| node_location
node_app -->|"requests nearby"| node_nearby_query
node_app -->|"requests arrivals"| node_arrivals_query
node_app -->|"requests map data"| node_map_queries
node_app -->|"requests vehicles"| node_vehicle_query
node_app -->|"requests route data"| node_route_queries
node_app -->|"renders"| node_nearby_ui
node_app -->|"renders"| node_stop_ui
node_app -->|"renders"| node_map_ui
node_app -->|"renders"| node_route_ui
node_nearby_ui -->|"shows"| node_favorites_ui
node_nearby_ui -->|"renders"| node_stop_card
node_favorites_ui -->|"renders"| node_stop_card
node_favorites_ui -->|"reads and updates"| node_favorites_store
node_stop_card -->|"groups arrivals"| node_departures
node_stop_ui -->|"loads departures"| node_arrivals_query
node_nearby_query -->|"fetches via"| node_http_client
node_arrivals_query -->|"fetches via"| node_http_client
node_map_queries -->|"fetches via"| node_http_client
node_vehicle_query -->|"fetches via"| node_http_client
node_route_queries -->|"fetches via"| node_http_client
node_http_client -->|"requests JSON"| node_api_server
node_api_server -->|"uses schedule data"| node_gtfs_import
node_api_server -->|"serves feed data"| node_realtime_refresh
node_static_feed -->|"imports schedule"| node_gtfs_import
node_gtfs_import -->|"loads static data"| node_schedule_db
node_realtime_feed -->|"polls positions and updates"| node_realtime_refresh
node_realtime_refresh -->|"matches predictions"| node_schedule_db
node_realtime_refresh -->|"snapshots refresh"| node_realtime_db
node_api_server -->|"serves snapshot reads"| node_realtime_db

click node_app "https://github.com/revaix7/ottatransit/blob/master/src/App.jsx"
click node_nearby_ui "https://github.com/revaix7/ottatransit/blob/master/src/components/NearbySheet.jsx"
click node_stop_ui "https://github.com/revaix7/ottatransit/blob/master/src/components/StopView.jsx"
click node_map_ui "https://github.com/revaix7/ottatransit/blob/master/src/components/MapView.jsx"
click node_route_ui "https://github.com/revaix7/ottatransit/blob/master/src/components/RouteBanner.jsx"
click node_favorites_ui "https://github.com/revaix7/ottatransit/blob/master/src/components/Favorites.jsx"
click node_stop_card "https://github.com/revaix7/ottatransit/blob/master/src/components/StopCard.jsx"
click node_departures "https://github.com/revaix7/ottatransit/blob/master/src/lib/departures.js"
click node_favorites_store "https://github.com/revaix7/ottatransit/blob/master/src/store/favorites.js"
click node_location "https://github.com/revaix7/ottatransit/blob/master/src/hooks/useGeolocation.js"
click node_nearby_query "https://github.com/revaix7/ottatransit/blob/master/src/hooks/useNearby.js"
click node_arrivals_query "https://github.com/revaix7/ottatransit/blob/master/src/hooks/useArrivals.js"
click node_map_queries "https://github.com/revaix7/ottatransit/blob/master/src/hooks/useMapStops.js"
click node_vehicle_query "https://github.com/revaix7/ottatransit/blob/master/src/hooks/useVehicles.js"
click node_route_queries "https://github.com/revaix7/ottatransit/blob/master/src/hooks/useRouteDetails.js"
click node_http_client "https://github.com/revaix7/ottatransit/blob/master/src/lib/api.js"
click node_api_server "https://github.com/revaix7/ottatransit/blob/master/server/index.js"
click node_gtfs_import "https://github.com/revaix7/ottatransit/blob/master/server/gtfs.js"
click node_realtime_refresh "https://github.com/revaix7/ottatransit/blob/master/server/realtime.js"
click node_schedule_db "https://github.com/revaix7/ottatransit/blob/master/server/gtfs.js"
click node_realtime_db "https://github.com/revaix7/ottatransit/blob/master/server/realtime.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_app,node_nearby_ui,node_stop_ui,node_map_ui,node_route_ui,node_favorites_ui,node_stop_card,node_departures,node_favorites_store toneBlue
class node_location,node_nearby_query,node_arrivals_query,node_map_queries,node_vehicle_query,node_route_queries,node_http_client toneAmber
class node_api_server,node_gtfs_import,node_realtime_refresh toneMint
class node_schedule_db,node_realtime_db toneRose
class node_rider,node_static_feed,node_realtime_feed toneIndigo
```

## Components

### Transit experience

- [App coordinator](https://github.com/revaix7/ottatransit/blob/master/src/App.jsx): `src/App.jsx`
- [Nearby and favourites](https://github.com/revaix7/ottatransit/blob/master/src/components/NearbySheet.jsx): `src/components/NearbySheet.jsx`
- [Stop departures](https://github.com/revaix7/ottatransit/blob/master/src/components/StopView.jsx): `src/components/StopView.jsx`
- [Live map](https://github.com/revaix7/ottatransit/blob/master/src/components/MapView.jsx): `src/components/MapView.jsx`
- [Route banner](https://github.com/revaix7/ottatransit/blob/master/src/components/RouteBanner.jsx): `src/components/RouteBanner.jsx`
- [Saved routes and stops](https://github.com/revaix7/ottatransit/blob/master/src/components/Favorites.jsx): `src/components/Favorites.jsx`
- [Stop card](https://github.com/revaix7/ottatransit/blob/master/src/components/StopCard.jsx): `src/components/StopCard.jsx`
- [Departure grouping](https://github.com/revaix7/ottatransit/blob/master/src/lib/departures.js): `src/lib/departures.js`
- [Favourite state](https://github.com/revaix7/ottatransit/blob/master/src/store/favorites.js): `src/store/favorites.js`

### Browser data

- [Location lookup](https://github.com/revaix7/ottatransit/blob/master/src/hooks/useGeolocation.js): `src/hooks/useGeolocation.js`
- [Nearby stops query](https://github.com/revaix7/ottatransit/blob/master/src/hooks/useNearby.js): `src/hooks/useNearby.js`
- [Arrivals queries](https://github.com/revaix7/ottatransit/blob/master/src/hooks/useArrivals.js): `src/hooks/useArrivals.js`
- [Map stop and rail queries](https://github.com/revaix7/ottatransit/blob/master/src/hooks/useMapStops.js): `src/hooks/useMapStops.js`
- [Vehicle query](https://github.com/revaix7/ottatransit/blob/master/src/hooks/useVehicles.js): `src/hooks/useVehicles.js`
- [Route detail queries](https://github.com/revaix7/ottatransit/blob/master/src/hooks/useRouteDetails.js): `src/hooks/useRouteDetails.js`
- [JSON API client](https://github.com/revaix7/ottatransit/blob/master/src/lib/api.js): `src/lib/api.js`

### Transit server

- [Express API](https://github.com/revaix7/ottatransit/blob/master/server/index.js): `server/index.js`
- [Static GTFS import](https://github.com/revaix7/ottatransit/blob/master/server/gtfs.js): `server/gtfs.js`
- [Realtime refresh and snapshot](https://github.com/revaix7/ottatransit/blob/master/server/realtime.js): `server/realtime.js`

### Schedule and realtime data

- [GTFS SQLite data](https://github.com/revaix7/ottatransit/blob/master/server/gtfs.js): `server/gtfs.js`
- [Realtime snapshot](https://github.com/revaix7/ottatransit/blob/master/server/realtime.js): `server/realtime.js`

### Other components

- **Rider**
- **OC Transpo static feed**
- **OC Transpo realtime feeds**

## Connections

- Rider → App coordinator: uses (evidence: `README.md`)
- App coordinator → Location lookup: gets location (evidence: `src/App.jsx`)
- App coordinator → Nearby stops query: requests nearby (evidence: `src/App.jsx`)
- App coordinator → Arrivals queries: requests arrivals (evidence: `src/App.jsx`)
- App coordinator → Map stop and rail queries: requests map data (evidence: `src/App.jsx`)
- App coordinator → Vehicle query: requests vehicles (evidence: `src/App.jsx`)
- App coordinator → Route detail queries: requests route data (evidence: `src/App.jsx`)
- App coordinator → Nearby and favourites: renders (evidence: `src/App.jsx`)
- App coordinator → Stop departures: renders (evidence: `src/App.jsx`)
- App coordinator → Live map: renders (evidence: `src/App.jsx`)
- App coordinator → Route banner: renders (evidence: `src/App.jsx`)
- Nearby and favourites → Saved routes and stops: shows (evidence: `src/App.jsx`)
- Nearby and favourites → Stop card: renders (evidence: `src/components/NearbySheet.jsx`)
- Saved routes and stops → Stop card: renders (evidence: `src/components/Favorites.jsx`)
- Saved routes and stops → Favourite state: reads and updates (evidence: `src/components/Favorites.jsx`)
- Stop card → Departure grouping: groups arrivals (evidence: `src/components/StopCard.jsx`)
- Stop departures → Arrivals queries: loads departures (evidence: `src/components/StopView.jsx`)
- Nearby stops query → JSON API client: fetches via (evidence: `src/hooks/useNearby.js`)
- Arrivals queries → JSON API client: fetches via (evidence: `src/hooks/useArrivals.js`)
- Map stop and rail queries → JSON API client: fetches via (evidence: `src/hooks/useMapStops.js`)
- Vehicle query → JSON API client: fetches via (evidence: `src/hooks/useVehicles.js`)
- Route detail queries → JSON API client: fetches via (evidence: `src/hooks/useRouteDetails.js`)
- JSON API client → Express API: requests JSON (evidence: `README.md`)
- Express API → Static GTFS import: uses schedule data (evidence: `server/index.js`)
- Express API → Realtime refresh and snapshot: serves feed data (evidence: `README.md`)
- OC Transpo static feed → Static GTFS import: imports schedule (evidence: `README.md`)
- Static GTFS import → GTFS SQLite data: loads static data (evidence: `README.md`)
- OC Transpo realtime feeds → Realtime refresh and snapshot: polls positions and updates (evidence: `README.md`)
- Realtime refresh and snapshot → GTFS SQLite data: matches predictions (evidence: `README.md`)
- Realtime refresh and snapshot → Realtime snapshot: snapshots refresh (evidence: `README.md`)
- Express API → Realtime snapshot: serves snapshot reads (evidence: `README.md`)
