KMB Bus Tracker
Status: active
Started: 2026-07-08
Path: /opt/data/kmb/server/
Port: 5050
Proxy: Ming's Note → /kmb/
Last Fix: 2026-07-15
Core Question
How to use HK government open data to build a practical mini app for daily commute?
What It Is
A web app tracking KMB bus arrivals, built with Express + SQLite + HTML, served via Ming's Note (MD Reader proxy).
Key Features
- Real-time bus arrival data from KMB API
- Route filtering (hide routes with no buses)
- Transfer station info
- Mobile-friendly UI for daily use
Architecture
- Express server (port 5050): API proxy + static HTML
- MD Reader (port 9119): serves HTML at
/kmb/, proxies /kmb/api/* → localhost:5050/api/*
- apps-watchdog: cron every 5 min, restarts if down
- DB: kmb.db (SQLite, WAL mode, 6740 stops, 1609 routes)
Dependencies
- Node: express, better-sqlite3, node-fetch
- Python (MD Reader venv): flask, markdown, markupsafe, requests
Known Issues Fixed (2026-07-15)
- Express server died on VPS restart → watchdog wasn't effective because:
apps-watchdog.sh used wrong Python venv path for MDReader (/opt/hermes/.venv/ instead of /opt/data/venv/dashboard/)
requests module missing from dashboard venv → MDReader proxy returned 500
- Duplicate
kmb-watchdog cron job removed (already covered by apps-watchdog)
- Created
/opt/data/scripts/requirements-dashboard.txt to track dashboard venv deps
Why It Matters
- Open data experiment — Proving HK gov data (KMB, potentially MTR, minibuses) can power useful tools
- Family utility — Henry uses it daily for commute (華明→沙田)
- Extensible pattern — Same architecture can add MTR, minibus, taxi estimates
Tech Stack
- Backend: Express + SQLite
- Frontend: HTML/CSS/JS
- Data: KMB real-time API
- Dependencies: express, better-sqlite3, node-fetch
Open Questions
- [ ] Add MTR data integration?
- [ ] Add minibus routes?
- [ ] Multi-modal journey planner (bus + MTR combined)?
- [ ] Share with family beyond Henry?
Notes
- Filter out routes with no upcoming buses (reduces noise)
- Correct transfer station info is critical for usability
- Henry sends mobile screenshots for iteration — quick feedback loop
- DB: kmb.db (WAL mode)