Skip to content

A Vue 3 web application for Hong Kong MTR (Mass Transit Railway) real-time train information with mobile-first design.

License

Notifications You must be signed in to change notification settings

HugoLi0213/hkmtrvue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

40 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

HKMTRVUE - MTR & LRT Schedule & Real-time Arrivals

Use Google Maps for navigation β†’ Use HKMTRVUE for train schedules & real-time arrivals β†’ Complete your Hong Kong journey!

πŸš‡ The Google Maps Companion - While Google Maps gets you to MTR and LRT stations, HKMTRVUE provides schedules and real-time arrival times in a traditional timetable view design. A specialized frontend web app with official DATA.GOV.HK data updated every 10 seconds - no GPS or location services required.

πŸ—ΊοΈ How to Use with Google Maps

Step 1: Navigate with Google Maps

  • Use Google Maps to find directions to any MTR or Light Rail station
  • Get walking/driving routes to station entrances
  • See estimated travel time to reach the station

Step 2: Check Real-time Arrivals with HKMTRVUE

  • Open HKMTRVUE web app on your phone
  • Select your destination station (no GPS location required)
  • See live schedules & arrival times in traditional timetable view updated every 10 seconds
  • Check which platform and direction to take

Step 3: Complete Your Journey

  • Board the train with confidence knowing exact arrival times
  • Use Google Maps again for final walking directions from destination station
  • Bookmark frequently used stations for faster access

🌟 Why This Combination Works Perfectly for Hong Kong

For Daily Commuters

  • Google Maps Navigation: Get the fastest route to your nearest MTR/LRT station
  • Real-time Train Data: Check exact arrival times so you don't rush unnecessarily
  • Platform Information: Know which platform and direction before you arrive
  • Transfer Planning: See connections and timing for multi-line journeys

For Tourists & Visitors

  • Familiar Interface: Use Google Maps (which you already know) for navigation
  • No App Downloads: HKMTRVUE works in any web browser - frontend web app only
  • No Location Required: Manual station selection - no GPS or location services needed
  • Traditional Timetable View: Easy-to-read scheduled timetables and real-time arrival information
  • Complete Journey Planning: From hotel to attraction using both apps together
  • Language Support: English and Traditional Chinese in both Google Maps and HKMTRVUE

For All Hong Kong Transit Users

  • Perfect Timing: Arrive at station just as your train is coming
  • Avoid Crowds: Choose less crowded trains by seeing multiple arrival times
  • Weather Protection: Minimize waiting time on outdoor platforms (especially LRT)
  • Data Efficiency: Only use data when you need real-time information

πŸ—ΊοΈ Google Maps + HKMTRVUE: The Perfect Transit Solution

Why Use Both Apps Together?

Google Maps Strengths:

  • πŸšΆβ€β™‚οΈ Walking/driving directions to stations
  • πŸ—ΊοΈ Overview of entire Hong Kong transit network
  • πŸ“ Station locations and nearby landmarks
  • 🏒 Integration with restaurants, hotels, attractions

HKMTRVUE Strengths:

  • πŸš‡ Real-time train schedules & arrival times in traditional timetable view (updated every 10 seconds)
  • πŸš‰ Platform and direction information
  • ⏱️ Exact waiting times and train frequencies
  • πŸ“± Lightweight frontend web app - no installation or GPS required

Combined Workflow Examples

Combined Workflow Examples

Tourist Journey: Airport to Tsim Sha Tsui

Step 1: Use Google Maps
πŸ—ΊοΈ Search "Hong Kong Airport to Tsim Sha Tsui"
πŸšΆβ€β™‚οΈ Follow walking directions to Airport Express platform

Step 2: Use HKMTRVUE  
πŸš‡ Check Airport Express real-time arrivals
⏱️ See next train in 8 minutes, then 18 minutes
πŸš‰ Confirm Platform 1 for Hong Kong/Kowloon direction

Step 3: During Journey
πŸ“± Use HKMTRVUE to check Kowloon Station arrival time
πŸ”„ Plan transfer to Tsuen Wan Line

Step 4: Final Destination
πŸ—ΊοΈ Use Google Maps for walking directions from Tsim Sha Tsui Station to hotel

Daily Commute: Sha Tin to Central

Step 1: Check Schedule
πŸ“± Open HKMTRVUE β†’ Select Sha Tin Station (East Rail Line)
⏰ Next train: 3 minutes, then 6 minutes, then 9 minutes

Step 2: Navigate to Station  
πŸ—ΊοΈ Google Maps β†’ "Directions to Sha Tin MTR Station"
πŸšΆβ€β™‚οΈ 5-minute walk β†’ Perfect timing to catch the 6-minute train

Step 3: Monitor Journey
πŸ“± HKMTRVUE β†’ Check real-time arrival at Admiralty for transfer
πŸ”„ Transfer to Island Line for Central

Light Rail Journey: Tuen Mun to Yuen Long

Step 1: Route Planning
πŸ—ΊοΈ Google Maps β†’ Overview of LRT network and stations
πŸ“ Find nearest LRT stop to your current location

Step 2: Real-time Information
πŸ“± HKMTRVUE β†’ Select LRT station (e.g., Tuen Mun Town Centre)  
🚊 Route 610: 4 minutes | Route 615: 7 minutes | Route 614: 12 minutes
βœ… Choose Route 610 for fastest journey

Step 3: Destination Navigation
πŸ—ΊοΈ Google Maps β†’ Walking directions from Yuen Long LRT station

✨ Key Features

✨ HKMTRVUE Features

  • πŸš‡ Real-time MTR & LRT schedules & arrival times in traditional timetable view for all Hong Kong lines (updated every 10 seconds)
  • πŸ• Live train schedules showing next 3-4 arrivals with exact timing
  • πŸš‰ Platform and direction information so you know exactly where to go
  • πŸ“± Mobile-optimized frontend web app - no installation, GPS, or location services required, works in any browser
  • ⚑ 10-second refresh rate - fastest real-time data in Hong Kong
  • 🌐 Bilingual support (English/Traditional Chinese) for all users
  • πŸ’Ύ Bookmark favorite stations for quick access to frequently used routes
  • πŸŒ™ Dark mode support for comfortable viewing day and night
  • πŸ“³ Haptic feedback for enhanced mobile experience
  • πŸ”„ Auto-refresh technology with smart caching to save your data

πŸš€ Technical Excellence & Hong Kong-Specific Optimizations

Data Sources & Reliability

  • Official Government APIs: Direct integration with DATA.GOV.HK transport endpoints
  • MTR Corporation Data: Real-time train schedules from MTR's official systems
  • 10-Second Refresh Cycle: Perfectly tuned for Hong Kong's high-frequency train service
  • Resilient Error Handling: Exponential backoff and retry mechanisms for Hong Kong's mobile network conditions

Hong Kong Transit System Coverage

MTR Lines Supported:

  • πŸ”΅ Island Line (ζΈ―ε³ΆηΆ«): Chai Wan ↔ Kennedy Town
  • πŸ”΄ Tsuen Wan Line (荃灣碫): Tsuen Wan ↔ Central
  • 🟒 Kwun Tong Line (θ§€ε‘˜ηΆ«): Tiu Keng Leng ↔ Whampoa
  • 🟣 Tseung Kwan O Line (將軍澳碫): Po Lam/LOHAS Park ↔ North Point
  • 🟀 Tuen Ma Line (屯馬碫): Tuen Mun ↔ Wu Kai Sha
  • πŸ”΅ East Rail Line (東鐡碫): Lo Wu/Lok Ma Chau ↔ Admiralty
  • 🟑 South Island Line (南港峢碫): South Horizons ↔ Admiralty
  • 🟒 Airport Express (機場快碫): AsiaWorld Expo ↔ Hong Kong
  • 🟠 Tung Chung Line (東梌碫): Tung Chung ↔ Hong Kong

Light Rail Transit (LRT) Coverage:

  • πŸ”΄ Complete LRT Network in Tuen Mun and Yuen Long districts
  • 68 LRT Stations across New Territories West
  • 12 LRT Route Numbers (505, 507, 610, 614, 614P, 615, 615P, 705, 706, 751, 751P, 761P)

Integration with Hong Kong's Digital Ecosystem

Google Maps Connectivity

// Seamless integration flow:
1. πŸ—ΊοΈ Google Maps β†’ Find directions to nearest MTR/LRT stations  
2. πŸš‡ HKMTRVUE App β†’ Manual station selection (no GPS required) for real-time timetable view
3. ⏰ Traditional Timetable Design β†’ Clear scheduled times and live arrival information
4. πŸ• Smart Timing β†’ Combine walking time + wait time + travel time
5. πŸ“± Browser-based β†’ Direct handoff between Google Maps and HKMTRVUE web app

Why This Matters for Hong Kong Users

  • Density-Optimized: Hong Kong has the world's highest concentration of MTR stations - this app helps navigate the complexity
  • Transfer Intelligence: Multi-line journeys are common in HK - smart transfer suggestions save time
  • Rush Hour Optimization: Real-time data crucial during Hong Kong's intense peak hours (7-9 AM, 6-8 PM)
  • Tourist-Friendly: Essential for visitors navigating Hong Kong's extensive transit network
  • Weather-Aware Planning: Indoor connections mapped for Hong Kong's rainy season and summer heat

Real-World Use Cases in Hong Kong

Scenario 1: Daily Commuter (Sha Tin β†’ Central)

Morning Routine with HKMTRVUE:
1. Check app at home β†’ See East Rail delays/normal service
2. Google Maps integration β†’ Walking route to Sha Tin Station  
3. Real-time platform info β†’ Platform 1 or 2 for southbound trains
4. Transfer optimization β†’ Best route via Admiralty or direct to Central
5. Arrival prediction β†’ Exact ETA at Central for meeting planning

Scenario 2: Tourist Journey (Airport β†’ Tsim Sha Tsui)

Visitor Experience:
1. Land at Hong Kong Airport β†’ Open HKMTRVUE web app (no download needed)
2. Airport Express timing β†’ Real-time departures every 10-15 minutes
3. Kowloon Station arrival β†’ Transfer guidance to Tsuen Wan Line
4. Google Maps handoff β†’ Walking directions in Tsim Sha Tsui
5. Return journey planning β†’ Bookmark favorite stations for later

Scenario 3: Light Rail User (Tuen Mun β†’ Yuen Long)

New Territories Navigation:
1. Complex LRT network β†’ 12 different route numbers, multiple platforms
2. Real-time platform display β†’ Which route arrives first
3. Transfer optimization β†’ Direct route vs. faster connection
4. Google Maps integration β†’ Last-mile connection to final destination
5. Service disruption alerts β†’ Alternative routing during maintenance

πŸ”„ Technical Architecture & Performance

Real-Time Data Pipeline

// Optimized for Hong Kong's mobile network conditions
const CACHE_DURATION = 10000 // 10 seconds - matches MTR frequency
const MAX_RETRIES = 3        // Handles network congestion
const API_ENDPOINTS = {
  MTR: 'https://rt.data.gov.hk/v1/transport/mtr/getSchedule.php',
  LRT: 'https://rt.data.gov.hk/v1/transport/mtr/lrt/getSchedule'
}

Hong Kong-Specific Optimizations

  • Network Resilience: Handles Hong Kong's underground mobile coverage gaps
  • Bilingual Data Processing: Seamless Chinese/English station name handling
  • Local Time Accuracy: Hong Kong timezone (UTC+8) precision for arrival predictions
  • Mobile Data Efficiency: Minimized API calls for Hong Kong's expensive mobile data plans

Project Structure

src/
β”œβ”€β”€ App.vue                          # Main app component with routing logic
β”œβ”€β”€ main.ts                          # Vue app entry point
β”œβ”€β”€ pages/                           # Page components
β”‚   β”œβ”€β”€ MtrTrain/
β”‚   β”‚   └── MtrTrain.vue            # Main MTR train page with real-time data
β”‚   β”œβ”€β”€ LightRail/
β”‚   β”‚   └── LightRail.vue           # Light Rail transit page
β”‚   β”œβ”€β”€ Home/
β”‚   β”‚   └── Home.vue                # Home page component
β”‚   └── BusEta/
β”‚       └── BusEta.vue              # Bus ETA page (placeholder)
β”œβ”€β”€ components/                      # Reusable UI components
β”‚   β”œβ”€β”€ settings/
β”‚   β”‚   β”œβ”€β”€ PersonalizeDialog.vue   # Settings modal dialog
β”‚   β”‚   └── OptionsList.vue         # Simplified settings buttons
β”‚   β”œβ”€β”€ icons/                      # SVG icon components
β”‚   β”‚   β”œβ”€β”€ BackspaceIcon.vue
β”‚   β”‚   β”œβ”€β”€ ClearIcon.vue
β”‚   β”‚   └── CloseIcon.vue
β”‚   β”œβ”€β”€ route-board/                # Route selection components
β”‚   β”‚   β”œβ”€β”€ BoardTabbar.vue         # Tab navigation
β”‚   β”‚   β”œβ”€β”€ RouteInputPad.vue       # Route input interface
β”‚   β”‚   └── SwipeableRoutesBoard.vue # Swipeable route board
β”‚   └── route-eta/                  # ETA display components
β”‚       β”œβ”€β”€ RouteHeader.vue         # Route information header
β”‚       β”œβ”€β”€ StopAccordionList.vue   # Expandable stop list
β”‚       └── TimeTableButton.vue     # Timetable access button
β”œβ”€β”€ composables/                     # Vue 3 composable functions
β”‚   β”œβ”€β”€ useMtrData.ts               # MTR API data fetching logic
β”‚   β”œβ”€β”€ useFavoriteStations.ts      # Bookmark management
β”‚   β”œβ”€β”€ useTheme.ts                 # Dark/light theme handling
β”‚   └── useNetworkStatus.ts         # Network connectivity monitoring
β”œβ”€β”€ constants/
β”‚   └── mtrLines.ts                 # MTR line configurations and station data
β”œβ”€β”€ types/
β”‚   └── train.ts                    # TypeScript interfaces for train data
└── utils/
    β”œβ”€β”€ index.ts                    # Utility functions (distance, formatting)
    └── tests/
        └── searchRouteHelpers.ts   # Helper functions for route search

Key Dependencies and Data Flow

Data Fetching (useMtrData.ts)

  • Used by: MtrTrain.vue, LightRail.vue
  • Purpose: Fetches real-time train arrival data from DATA.GOV.HK APIs
  • Features: 10-second caching, retry logic, error handling
  • APIs:
    • MTR: https://rt.data.gov.hk/v1/transport/mtr/getSchedule.php
    • LRT: https://rt.data.gov.hk/v1/transport/mtr/lrt/getSchedule

Theme Management (useTheme.ts)

  • Used by: App.vue (global), all components inherit
  • Purpose: Manages dark/light mode, font sizes, color schemes
  • Features: System preference detection, localStorage persistence
  • CSS Variables: Dynamically sets CSS custom properties for theming

Favorite Stations (useFavoriteStations.ts)

  • Used by: Station selection components, route displays
  • Purpose: Manages user's bookmarked stations
  • Storage: localStorage with JSON serialization

Network Status (useNetworkStatus.ts)

  • Used by: Data fetching components for connection monitoring
  • Purpose: Monitors online/offline status and connection quality
  • Features: Connection type detection (2G, 3G, 4G, etc.)

Station Configuration (mtrLines.ts)

  • Used by: All MTR-related components
  • Purpose: Central configuration for all MTR lines and stations
  • Data: Line colors, station names (Chinese/English), terminus information

Type Definitions (train.ts)

  • Used by: All components handling train data
  • Purpose: TypeScript interfaces for type safety
  • Interfaces: TrainArrival, StationData, LineConfig, etc.

Development Notes

  • Clean Architecture: Removed all legacy React components and unnecessary files
  • Mobile-First Design: Container max-width of 480px, centered layout like HKBUS.APP
  • Simplified Settings: Converted complex React settings to simple button-based interface
  • TypeScript Support: Full type safety with proper interfaces and type definitions

Installation

  1. Clone the repository:
git clone https://github.com/HugoLi0213/HKMTRVUE.git
cd HKMTRVUE
  1. Install dependencies:
npm install
  1. Start development server:
npm run dev
  1. Build for production:
npm run build

API Data Source

This app uses real-time data from:

  • DATA.GOV.HK - Hong Kong Government's open data platform
  • MTR real-time arrival API endpoints

Mobile UI Design

The app features a mobile-centered design similar to HKBUS.APP:

  • Maximum container width of 480px
  • Centered layout on larger screens
  • Touch-friendly button sizes
  • Smooth animations and transitions
  • Card-based design with subtle shadows

Settings Features

  • πŸ”„ App Updates: Force refresh service worker
  • πŸ› οΈ Database Updates: Renew route database
  • πŸŒ™ Dark Mode: Switch between light/dark themes
  • πŸ“³ Vibration: Enable/disable haptic feedback
  • πŸ“‹ Bookmark Management: Save and organize favorite stations
  • 🎨 Traditional Timetable View: Classic scheduled timetable design for easy reading

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

Author

Hugo
πŸ“§ Email: s12332146@gmail.com
πŸ™ GitHub: HugoLi0213

License

This project is open source and available under the Apache License Version 2.0

Acknowledgments

About

A Vue 3 web application for Hong Kong MTR (Mass Transit Railway) real-time train information with mobile-first design.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published