Real-Time Bus Management System

Distributed transit platform engineered with an autonomous 4-microservice Spring Boot architecture, Vue.js PWA with offline capabilities, Redis Pub/Sub telemetry, and PostgreSQL, orchestrated on Google Cloud GKE.

Applications EngineeringMicroservicesSpring BootVue.jsRedisPostgreSQLGoogle CloudKubernetesAnsible
View on GitHub

Introduction

A real-time public transit platform built on a distributed microservices architecture. The system handles live vehicle tracking, route planning, QR-based digital ticketing, driver operations, and administrator analytics.

  • Tech Stack: Spring Boot (Java 17/21), Vue 3, Tailwind CSS, PostgreSQL 18, Redis 8, GKE, Ansible, Docker Compose, JMeter, Playwright.

Microservices Architecture

The backend is decomposed into four autonomous microservices communicating via REST and event-driven Redis Pub/Sub channels:

  • transports-core: The operational backbone managing road networks, stops, schedules, driver QR check-ins, and ticket validation (Strategy Pattern). Integrates Firebase Cloud Messaging (FCM) for push notifications and renewal alerts.
  • catalog-microservice: Manages fares, catalog items, and purchases using the Transactional Outbox Pattern with a background retry service to ensure eventual consistency during network or core failures.
  • location-microservice: Handles high-frequency telemetry without relational database bottlenecking, publishing coordinates via Redis Pub/Sub and streaming live updates to clients via lightweight Server-Sent Events (SSE).
  • external-bus-simulator: Ingests production GTFS data from the TUB/Mobibus API, simulates passenger occupancy, and feeds real-time telemetry into the system.

Frontend & Offline Resilience (PWA)

Built as a Single Page Application with Vue 3, Vite, and Tailwind CSS, packaged as an installable Progressive Web App (PWA):

Driver and Operations Portal

  • Stakeholder Portals: Dedicated interfaces for passengers (interactive Leaflet maps, route planning, digital wallet), drivers (QR validation, onboard ticketing, incident reporting), and administrators (fleet monitoring and analytics).
  • Offline-First with IndexedDB: Syncs digital wallet tickets and QR passes to client-side IndexedDB, allowing passengers to present valid boarding passes even during network dropouts.

Data Layer & Storage

Adopts a Schema-per-Microservice model on PostgreSQL 18 to preserve service autonomy while optimizing infrastructure costs:

  • Schema Isolation: Dedicated schemas for transports-core and catalog-microservice eliminate cross-service joins and simplify migrations.
  • JPA Inheritance: Uses TABLE_PER_CLASS for strict credential/user isolation and SINGLE_TABLE with discriminators for high-performance title/catalog lookups.
  • Reliability: Continuous WAL archiving, scheduled pg_basebackup snapshots, and automated retention management.

Cloud Infrastructure (GKE)

Automated end-to-end with Ansible and deployed on Google Kubernetes Engine (GKE):

  • Cluster Topology: 5 worker nodes (e2-standard-2) segmented into namespaces: transports-app (microservices, PostgreSQL with retain PVCs, Redis), ingress-nginx (perimeter security & SSL termination), and monitoring (Prometheus & Grafana).
  • Elastic Scalability: Horizontal Pod Autoscalers (HPA) dynamically scale pods under traffic surges (e.g., scaling up to 5 replicas when CPU exceeds 80%).
  • Dev-Prod Parity: Synchronized Docker Compose environment for local multi-service development and testing.

Performance Benchmarking & Results

  • JMeter Load & Stress Testing: Maintained 0% error rate and 14.67 ms average latency under sustained load (50 virtual users). Absorbed sudden 250-user traffic spikes with a 99.97% success rate via automatic HPA pod scaling.
  • PostgreSQL Optimization: Tuned shared_buffers, disabled parallel query overhead for OLTP workloads, and enabled WAL compression—achieving an +18.3% boost in transactional throughput (up to 830 txn/s) and reducing latency to 20.02 ms.
  • Validation: Playwright E2E test suite achieved a 100% pass rate, and field testing yielded a System Usability Scale (SUS) score of 93.0 / 100 (Grade A - Exceptional).