How karaagexc/traintracks works
TrainTracks is a map-first Metro Manila rail companion: riders plan transfer-aware journeys, follow progress with location assistance, and consult fares, train estimates, and community conditions. Its domain layer supplies routing, journey tracking, simulation, and prediction logic; the app also exposes public APIs and account-backed trip history. The graph emphasizes documented product capabilities and sampled call relationships. Some UI and API wiring is inferred only from route/module names and the README; uncertain links are omitted.
Main entry points: MainApp.tsx Map and trip UI · useJourneyRuntime.ts Journey runtime · index.ts Route builder · engine.ts Journey engine
Components 26
Rider experience
- Map and trip UI
src/components/MainApp.tsx - Map explorer
src/components/MapExplorer.tsx - Line explorer
src/components/LineExplorer.tsx - Trip progress
src/components/TripProgress.tsx - Fare selection
src/components/FareSelector.tsx
Journey domain
- Journey runtime
src/hooks/useJourneyRuntime.ts - Journey engine
src/domain/journey/engine.ts - Route builder
src/domain/routing/index.ts - Rail network data
src/data/stations.ts - Location runtime
src/hooks/useSmartLocation.ts - GPS and proximity
src/domain/location/stationProximity.ts - Train simulation
src/domain/simulation/engine.ts
Transit signals
- Train presence
src/domain/trainPresence.ts - Train estimates
src/domain/predictions/engine.ts - Crowd forecasting
src/domain/congestion/engine.ts - Community reports
src/domain/crowd/service.ts - Incident endpoints
src/app/api/incidents/route.ts - Prediction endpoints
src/app/api/predictions/route.ts
Accounts and APIs
- Auth and profile
src/hooks/useAuth.ts - Trip history API
src/app/api/trips/route.ts - Public congestion API
src/app/api/public/congestion/route.ts
Offline runtime
- Offline runtime
src/hooks/useOfflineRuntime.ts - Offline storage
src/domain/offline/indexedDb.ts
Other components
- Rider
- Supabase
- API consumer
Connections 23
- Rider → Map and trip UI: uses
- Map and trip UI → Map explorer: renders
- Map and trip UI → Line explorer: explores
- Map and trip UI → Trip progress: shows progress
- Map and trip UI → Fare selection: selects fare
- Map and trip UI → Journey runtime: tracks trip
- Journey runtime → Journey engine: updates journey
- Journey engine → Route builder: builds route
- Route builder → Rail network data: reads stations
- Location runtime → GPS and proximity: checks proximity
- Journey runtime → Location runtime: uses location
- Train simulation → Route builder: builds simulated route
- Journey runtime → Train simulation: simulates trip
- Map and trip UI → Train presence: shows train signals
- Prediction endpoints → Train estimates: computes estimates
- Public congestion API → Crowd forecasting: computes crowd level
- API consumer → Public congestion API: requests data
- Rider → Incident endpoints: reports conditions
- Incident endpoints → Community reports: handles reports
- Community reports → Supabase: persists signals
- Auth and profile → Supabase: authenticates
- Trip history API → Supabase: reads and writes trips
- Offline runtime → Offline storage: stores offline data