Dynamic Surge Engine

Leaflet Map Spring Boot Kafka MySQL Database

System Architecture & Rules

Clicking the map triggers an instant distributed pipeline:

  1. The Trigger: Spam-click the map to publish Ride Events to Aiven Apache Kafka via a REST API.
  2. Surge Math (Consumer): A Listener instantly consumes the event. If a zone exceeds 5 rides, it surges to 1.5x. If it exceeds 10 rides, it surges to 2.0x!
  3. Instant UI (SSE): The math is instantly pushed to this browser via Server-Sent Events.
  4. Auto-Decay: After 8 seconds, the backend automatically dispatches a "COMPLETE" event to mimic a driver arriving, naturally cooling down the surge!
  5. Batch Upsert: An async worker flushes the exact state to MySQL every 1 second to prevent DB crashing!

Live Surge Analytics