Skip to content

Cycl0o0/NVT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🚊 NVT - Next Vehicle TBM

Rust Platform

A powerful, real-time transit tracking application for Bordeaux MΓ©tropole's public transportation network (TBM). Monitor buses, trams, and BRT lines with live GPS tracking, service alerts, and comprehensive network information.

✨ Features

πŸš€ Real-Time Tracking

  • Live Vehicle Positions: GPS-based tracking of all TBM vehicles in real-time
  • Accurate Arrival Times: Precise ETAs using GTFS-RT data
  • Auto-Refresh Mode: Continuous 30-second updates for monitoring
  • Delay Indicators: Visual status indicators for on-time, delayed, or early arrivals

πŸ“Š Comprehensive Network Data

  • 700+ Stops: Complete coverage of all TBM network stops
  • 100+ Lines: All tram, bus, and BRT lines with route information
  • Service Alerts: Real-time notifications about disruptions and changes
  • Line Colors: Authentic TBM branding with official line colors

⚑ Smart Caching System

  • 15-Day GTFS Cache: Reduces bandwidth and speeds up loading
  • Intelligent Refresh: Automatic updates only when needed
  • Offline Fallback: Uses cached data when network is unavailable
  • Optimized Performance: Separate static and dynamic data management

🎨 User-Friendly Interface

  • Colorized Output: Line codes displayed in official TBM colors
  • Intuitive Navigation: Simple numbered menu system
  • Smart Search: Partial name matching for stops and lines
  • Rich Information Display: Detailed vehicle, stop, and line information

πŸ“‹ Table of Contents

πŸ”§ Installation

Prerequisites

  • Rust 1.70+: Install from rustup.rs
  • Internet Connection: Required for initial data download and real-time updates

Build from Source

# Clone the repository
git clone https://github.com/Cyclolysisss/NVT.git
cd NVT

# Build the project
cargo build --release

# Run the application
cargo run --release

Binary Installation

Download the latest pre-built binary from the Releases page.

# Linux/macOS
chmod +x nvt
./nvt

# Windows
nvt.exe

πŸš€ Usage

Quick Start

  1. Launch the application

    cargo run --release
  2. Select a line (Option 1)

    • Enter line code (e.g., A, C, 1, 23)
    • Or enter full name (e.g., Tram A)
  3. Select a stop (Option 2)

    • Enter partial or full stop name
    • Choose from multiple matches if needed
  4. View real-time arrivals (Option 3)

    • See next vehicles with live ETAs
    • Auto-refreshes every 30 seconds
    • Press Enter to exit refresh mode

Menu Options

πŸ“‹ MENU OPTIONS
  1️⃣  Select a line
  2️⃣  Select a stop
  3️⃣  Show next vehicles in real-time πŸ”„
  4️⃣  Browse all stops
  5️⃣  Browse all lines
  6️⃣  Show cache statistics πŸ“Š
  0️⃣  Quit application

Example Workflow

➜ Select Option: 1
🚌 Enter line name or code: A

βœ“ Line selected: A - Tram A
  🎯 Destinations:
     β†’ Outbound : La Gardette Bassens Carbon Blanc
     ← Inbound : Le Haillan Rostand

➜ Select Option: 2
πŸ“ Enter stop name: hotel de ville

βœ“ Stop selected: HΓ΄tel de Ville
  🚌 Lines serving this stop: A B

➜ Select Option: 3
πŸ”„ AUTO-REFRESH MODE - Update #1
πŸ“… Monday, October 21, 2025 at 15:34:28 CEST

  1. A Tram A
     🎯 Direction: La Gardette Bassens Carbon Blanc
     ⏰ Time: 15:37:30 (🟒 3 min)
     ⏱️  Status: 🟒 On time
     πŸ“Š Source: Real-time GPS tracking
     🚌 Vehicle ID: 1234

Advanced Features

Filtering by Line

Select a line first, then view only vehicles on that line at any stop.

Service Alerts

Automatically displays active and future alerts for selected stops and lines.

Cache Management

View cache statistics to monitor data freshness and performance.

πŸ“‘ Data Sources

Official TBM Open Data APIs

The application uses official TBM (Transports Bordeaux MΓ©tropole) data sources:

SIRI-Lite APIs

  • Stops Discovery: https://bdx.mecatran.com/utw/ws/siri/2.0/bordeaux/stoppoints-discovery.json
  • Lines Discovery: https://bdx.mecatran.com/utw/ws/siri/2.0/bordeaux/lines-discovery.json

GTFS-RT Feeds

  • Vehicle Positions: Real-time GPS locations
  • Trip Updates: Arrival/departure predictions
  • Service Alerts: Network disruptions and changes

GTFS Static Data

  • Routes: Line colors and route information
  • Stops: Comprehensive stop database

Data Update Frequency

Data Type Update Interval Cache Duration
Vehicle Positions 30 seconds N/A (real-time)
Trip Updates 30 seconds N/A (real-time)
Service Alerts 30 seconds N/A (real-time)
Stops/Lines Metadata 1 hour 1 hour
GTFS Static Data On-demand 15 days

πŸ—οΈ Architecture

Project Structure

NVT/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.rs              # Application entry point & error handling
β”‚   β”œβ”€β”€ nvt_models.rs        # Data models & API fetching
β”‚   β”œβ”€β”€ nvt_views.rs         # User interface & display logic
β”‚   └── nvt_controllers.rs   # Business logic & app flow
β”œβ”€β”€ Cargo.toml               # Dependencies & metadata
└── README.md

Module Overview

nvt_models.rs - Data Layer

  • API Integration: Fetches data from TBM endpoints
  • Data Structures: Stop, Line, RealTimeInfo, AlertInfo
  • Caching System: Intelligent cache management
  • GTFS Processing: Handles GTFS-RT protobuf decoding

nvt_views.rs - Presentation Layer

  • UI Components: Menus, prompts, and formatted output
  • Color Rendering: ANSI color codes for line branding
  • Information Display: Vehicle, stop, and line information
  • Error Messages: User-friendly error handling

nvt_controllers.rs - Business Logic

  • Application Flow: Main menu loop and navigation
  • Selection Handling: Line and stop selection logic
  • Auto-Refresh: Real-time update mechanism
  • Input Processing: User input validation and parsing

Design Patterns

  • MVC Architecture: Separation of concerns (Models, Views, Controllers)
  • Caching Strategy: Two-tier cache (static + dynamic)
  • Error Handling: Custom Result type with NVTError enum
  • Lazy Loading: Data fetched only when needed

βš™οΈ Configuration

Cache Location

The GTFS cache is stored in the system cache directory:

  • Linux: ~/.cache/tbm_nvt/gtfs_cache.json
  • macOS: ~/Library/Caches/tbm_nvt/gtfs_cache.json
  • Windows: %LOCALAPPDATA%\tbm_nvt\gtfs_cache.json

API Configuration

API endpoints and keys are configured in nvt_models.rs:

const API_KEY: &'static str = "opendata-bordeaux-metropole-flux-gtfs-rt";
const BASE_URL: &'static str = "https://bdx.mecatran.com/utw/ws";

Timeouts

const REQUEST_TIMEOUT_SECS: u64 = 15;  // API request timeout
const STATIC_DATA_MAX_AGE: u64 = 3600; // 1 hour
const DYNAMIC_DATA_MAX_AGE: u64 = 30;  // 30 seconds

πŸ”§ Dependencies

Core Libraries

[dependencies]
reqwest = { version = "0.11", features = ["blocking"] }  # HTTP client
serde = { version = "1.0", features = ["derive"] }       # Serialization
serde_json = "1.0"                                        # JSON parsing
gtfs-rt = "0.4"                                          # GTFS-RT decoder
prost = "0.12"                                           # Protobuf support
chrono = "0.4"                                           # Date/time handling
chrono-tz = "0.8"                                        # Timezone support
csv = "1.3"                                              # CSV parsing
zip = "0.6"                                              # GTFS archive extraction
dirs = "5.0"                                             # System directories

🀝 Contributing

Contributions are welcome! Please follow these guidelines:

Reporting Issues

  1. Check existing issues first
  2. Provide detailed error messages
  3. Include steps to reproduce
  4. Mention your OS and Rust version

Pull Requests

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Code Style

  • Follow Rust standard conventions
  • Run cargo fmt before committing
  • Ensure cargo clippy passes
  • Add documentation for public functions

πŸ™ Acknowledgments

  • TBM (Transports Bordeaux MΓ©tropole): For providing open data APIs
  • Bordeaux MΓ©tropole: For supporting open data initiatives
  • Mecatran: For hosting and maintaining the TBM data feeds
  • Rust Community: For excellent libraries and documentation

πŸ“ž Contact & Support

πŸ—ΊοΈ Roadmap

Planned Features

  • Offline mode with cached data and schedulded trips
  • Trip planning functionality
  • Favorite stops/lines
  • Notifications for specific arrivals
  • Export data to CSV/JSON
  • Historical data analysis
  • Multi-city support

Known Limitations

  • Requires internet connection for real-time updates
  • French language data (stop/line names)
  • Limited to TBM network (Bordeaux area)

πŸ“Š Statistics

  • Lines Supported: 100+
  • Stops Covered: 700+
  • Update Frequency: Every 30 seconds
  • Cache Duration: 15 days (GTFS static)
  • API Response Time: ~1-3 seconds

🌟 Star History

If you find this project useful, please consider giving it a star! ⭐


Made with ❀️ by Cyclolysisss

This project is NOT affiliated with TBM or Bordeaux MΓ©tropole in ANY WAY.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages