System Architecture & Rules
Clicking the map triggers an instant distributed pipeline:
- The Trigger: Spam-click the map to publish Ride Events to Aiven Apache Kafka via a REST API.
- 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!
- Instant UI (SSE): The math is instantly pushed to this browser via Server-Sent Events.
- Auto-Decay: After 8 seconds, the backend automatically dispatches a "COMPLETE" event to mimic a driver arriving, naturally cooling down the surge!
- Batch Upsert: An async worker flushes the exact state to MySQL every 1 second to prevent DB crashing!