Spaces:
Sleeping
title: TransitPulse
emoji: π
colorFrom: indigo
colorTo: blue
sdk: docker
app_port: 7860
pinned: false
TransitPulse β GPU-Accelerated Bus Reliability Decision Engine
π Live Deployment: Hugging Face Space
TransitPulse is a high-performance operations intelligence dashboard built for the Google Cloud Γ NVIDIA data intelligence challenge. It ingests large-scale bus GPS telemetry (GTFS-Realtime format), accelerates time-series headway and anomaly metrics on NVIDIA GPUs using RAPIDS (cudf.pandas), and delivers interactive scheduling insights through a responsive control dashboard and a Gemini-powered natural-language analyst agent.
The Problem & Decision Loop
Public transit agencies suffer from bus bunching and schedule decay due to traffic fluctuations. Depot managers need weekly intervention decisions (adjust dispatched headways, insert helper shuttles, etc.), but analyzing millions of daily GPS pings to extract rolling headways and anomalies is computationally expensive:
- CPU bottleneck: Traditional pandas loops on sorting, grouping, and shifting time-series records make daily analysis slow and prevent ad-hoc operations planning.
- GPU acceleration:
cudf.pandasconverts minutes of compute into seconds, enabling near-real-time operations simulation and system-wide reliability queries on the fly.
System Architecture
graph TD
subgraph Data Layer
A[GTFS-RT / Delhi Feed] -->|Ingestion| B[Raw GPS Parquet / partitioned]
C[generate_pings.py] -->|Synthetic Generator Fallback| B
end
subgraph GPU Acceleration Layer
B -->|Read| D[pipeline.py - cudf.pandas]
D -->|Groupby Headway / Anomaly Scan| E[Aggregated Parquet Outputs]
end
subgraph Serving Layer
E -->|loader.py| F[Google Cloud Storage]
F -->|Schema Load| G[BigQuery Warehouse]
E -->|Local Mode fallback| H[DuckDB OLAP View]
end
subgraph User Experience Layer
H -->|FastAPI Endpoints| I[FastAPI backend]
G -->|BigQuery client| I
I -->|SPA UI| J[Dark Operations Dashboard]
I -->|function-calling| K[Gemini 2.5 Analyst Agent]
K -->|NLP Chat UI| J
end
Key Features
| Feature | Description |
|---|---|
| Route Reliability Leaderboard | 20 routes ranked by composite reliability score (0β100). Sortable by score, headway, dwell, WoW trend. Worst-first default. |
| 30-Day Timeline Chart | Interactive Chart.js visualization of daily reliability score + actual vs. scheduled headway per route. Bunching episodes highlighted in red. |
| 8 Decision Cards | Auto-generated intervention recommendations: bunching hotspots, service gaps, dwell congestion, WoW-degrading routes. All grounded in DB. |
| Gemini Decision Copilot | Natural-language analyst powered by Gemini 2.5 with function-calling. Answers grounded in live DuckDB metrics. Cached answers auto-regenerated on each build. |
| GPU Benchmark Panel | Side-by-side CPU vs GPU timing comparison. "Pending" state shown until benchmark_colab.ipynb is run on a T4 GPU. |
Data Integrity Guarantees
- Zero hardcoded numbers: Every displayed metric is computed from the DuckDB database or
benchmark_results.jsonat render time. - Copilot answers cache: Regenerated automatically as the last step of
make demoby querying the freshly built DB β cited numbers always match the live dataset. - Cross-consistency tests:
tests/test_cross_consistency.pyparses every number in copilot answers and decision cards, re-queries the DB, and asserts they match within rounding limits. - Data sanity tests:
test_data_sanity.pyverifies dwell spread (23β72s), headway realism (median ~12 min), bunching rate bounds, WoW trend activity, and no clean fraction artifacts.
Performance & Acceleration Benchmarks
| Scale | Data Rows | Stage | CPU Time (s) | GPU Time (s) | Speedup |
|---|---|---|---|---|---|
| Small | ~2.2M | load | 0.170s | 0.055s | 3.09x |
| groupby_headway | 0.082s | 0.012s | 6.83x | ||
| anomaly_scan | 0.015s | 0.003s | 5.00x | ||
| scoring | 0.525s | 0.045s | 11.67x | ||
| Total Insight Time | 0.792s | 0.115s | 6.89x | ||
| Medium | ~25M | Total Insight Time | 118.42s | 5.21s | 22.73x |
| Full | ~150M | Total Insight Time | 745.31s | 18.92s | 39.39x |
GPU acceleration turns what would be an off-line nightly batch ETL pipeline (12+ minutes on CPU) into a near-realtime interactive loop (18.9 seconds on GPU). Pipeline benchmarked at 150M synthetic pings (~70Γ demo scale) to demonstrate production headroom; identical code path.
Setup & Running Instructions
Prerequisites
- Python 3.10+
- (Optional) NVIDIA GPU with CUDA drivers installed (for RAPIDS acceleration)
- (Optional) Google Cloud Service Account with storage/bigquery permissions (for cloud mode)
- (Optional) Gemini API Key (for live NL queries; cached answers work without it)
Local Execution (No Cloud Credentials Needed)
Install dependencies:
pip install -r requirements.txtRun the end-to-end demo using the Makefile:
make demoThis generates synthetic pings, runs the analytics pipeline, regenerates the copilot answers cache, and launches the FastAPI server at
http://localhost:8000.Run verification tests:
python test_data_sanity.py python tests/test_cross_consistency.py
Google Cloud Deployment
- Set environment variables:
export GCP_PROJECT="your-gcp-project-id" export GCS_BUCKET="your-gcs-bucket-name" export BQ_DATASET="transitpulse" export GEMINI_API_KEY="your-gemini-api-key" - Run cloud initialization:
make cloud
GPU Benchmark (Google Colab T4)
If you do not have a local NVIDIA GPU, run the benchmark on a free Google Colab T4 instance:
- Open
benchmark_colab.ipynband set Runtime type to T4 GPU. - Run all cells. The benchmark harness runs CPU vs GPU at small, medium, and full scale.
- Results are exported to
results/benchmark_results.jsonandresults/speedup_chart.png.
Project Structure
transitpulse/
βββ generate_pings.py # Synthetic GTFS-RT data generator with route personalities
βββ pipeline.py # GPU-accelerated analytics pipeline (cudf.pandas compatible)
βββ server.py # FastAPI backend serving DuckDB/BigQuery endpoints
βββ agent.py # Gemini 2.5 function-calling agent for NL queries
βββ benchmark.py # CPU vs GPU benchmark harness
βββ benchmark_colab.ipynb # Colab-ready notebook for T4 GPU benchmarking
βββ config.py # Centralized configuration
βββ db.py # DuckDB/BigQuery database abstraction layer
βββ loader.py # GCS + BigQuery data loader
βββ scripts/
β βββ generate_copilot_cache.py # Auto-regenerates copilot answers from live DB
βββ tests/
β βββ test_cross_consistency.py # Cross-consistency verification tests
βββ test_data_sanity.py # Data realism and quality assertions
βββ frontend/
β βββ index.html # Dashboard HTML (dark operations theme)
β βββ styles.css # CSS design system
β βββ app.js # Frontend controller (Chart.js, API integrations)
βββ Makefile # Build automation (data β pipeline β cache β serve)
βββ Dockerfile # Container deployment
βββ requirements.txt # Python dependencies
βββ DEMO.md # 3-minute demo walkthrough script
License
Built for the Google Cloud Γ NVIDIA Data Intelligence Challenge 2026.