How kyle20192005/hk-next-transit works
NextLeg is a Hong Kong transit arrivals and route-planning product, delivered as a web app and Expo app. The main journey is: a rider chooses a route or nearby stop, the backend loads transit data and obtains live arrivals, and the client presents ETAs, route details and maps. Separate branches cover rail and tram arrivals, nearby discovery, service news, and favorites. A data pipeline builds route, timetable and map datasets; a tracker service can serve shared live bus data. Some connections are documented rather than visible in sampled runtime code, so those links are cited to the README.
Main entry points: build.py Transit data builder · data.ts Route data access · index.ts Tracker HTTP service · api Transit API
Components 23
Rider apps
- Web experience
apps/web/app - Mobile experience
apps/mobile/src/app
Web API
- Transit API
apps/web/app/api - Route ETA endpoint
apps/web/app/api/eta/route.ts - Nearby endpoint
apps/web/app/api/nearby/route.ts - Service news
apps/web/app/api/news/route.ts - Tram endpoint
apps/web/app/api/tram/route.ts
Transit logic
- Live client
packages/core/src/tracker-client.ts - Route and ETA logic
packages/core/src/eta.ts - Stop arrivals
packages/core/src/stop-live.ts - Minibus support
packages/core/src/gmb.ts - Nearby and search
packages/core/src/stop-search.ts - Rail and tram
packages/core/src
Transit data
- Route data access
apps/web/lib/data.ts - Transit data builder
pipeline/build.py - Minibus data
pipeline/gmb.py - Other route data
pipeline/others.py - Tram data
pipeline/tram.py
Live tracker
- Tracker HTTP service
apps/tracker/src/index.ts - Tracker data access
apps/tracker/src/data.ts - Operator upstream
apps/tracker/src/upstream.ts
Other components
- Rider
- Transit data sources
Connections 23
- Rider → Web experience: uses
- Rider → Mobile experience: uses
- Web experience → Transit API: requests
- Mobile experience → Live client: requests live data
- Transit API → Route ETA endpoint: routes requests
- Route ETA endpoint → Route and ETA logic: uses
apps/web/app/api/eta/route.ts - Nearby endpoint → Nearby and search: uses
apps/web/app/api/nearby/route.ts - Nearby endpoint → Route data access: loads stops
apps/web/app/api/nearby/route.ts - Service news → Route data access: loads stops
apps/web/app/api/news/route.ts - Tram endpoint → Rail and tram: uses
apps/web/app/api/tram/route.ts - Tram endpoint → Route data access: loads timetable
apps/web/app/api/tram/route.ts - Stop arrivals → Minibus support: uses
packages/core/src/stop-live.ts - Live client → Tracker HTTP service: requests live feed
packages/core/src/tracker-client.ts - Live client → Transit API: falls back to
packages/core/src/tracker-client.ts - Tracker HTTP service → Tracker data access: loads transit data
apps/tracker/src/index.ts - Tracker HTTP service → Operator upstream: fetches arrivals
apps/tracker/src/index.ts - Tracker HTTP service → Stop arrivals: uses
apps/tracker/src/index.ts - Transit data sources → Transit data builder: provides source data
- Transit data builder → Minibus data: builds minibus data
pipeline/build.py - Transit data builder → Other route data: uses route helpers
pipeline/build.py - Transit data builder → Tram data: builds tram data
pipeline/build.py - Transit data builder → Route data access: produces datasets
- Route data access → Transit API: serves API data