This project is an end-to-end, high-throughput, real-time spatial event processing architecture. It mimics the backend telemetry systems of modern gig-economy delivery platforms (like UberEats, Zomato, or Swiggy). By offloading complex geospatial calculations and Machine Learning (ML) inference from traditional REST APIs to a streaming layer (Apache Kafka + PySpark), the system achieves sub-second latency for live tracking, routing ETA predictions, and fraud detection.
The platform decouples data ingestion, processing, and visualization into independent, highly scalable microservices:
- Ingestion (Apache Kafka in KRaft mode): Brokers high-throughput GPS location pings asynchronously across multiple topics (
rider-location,rider-predictions,traffic-density,rider-alerts). - Processing Engine (PySpark Structured Streaming): Consumes raw telemetry, processes stateful sliding windows (10-second intervals), performs real-time Machine Learning inferences, and executes spatial calculations.
- Backend / Router (Node.js/Express): Acts as a Kafka Consumer to parse enriched payloads and broadcast updates via WebSockets (Socket.io). Data is persisted to MongoDB (Mongoose).
- Frontend (Leaflet.js & HTML5): Listens to WebSocket events for sub-second map updates. Renders active scooter markers and calculates spatial heatmaps dynamically.
- Scalable Event Streaming: Python-based producers (simulating real-world routes via OSRM) push GPS coordinates to Kafka topics.
- Serverless Spatial Indexing (Uber H3 Indexing): Instead of executing heavy spatial database queries, PySpark uses the Uber wrapper (
h3-js/python-h3) to snap(Latitude, Longitude)coordinates to standardized hexagonal spatial bins (Resolution 9) directly inside the data stream, generating clustered density heatmaps. - Dynamic Geofencing: Employs spatial UDF checks in the streaming layer to detect when riders fall within bounded polygons (e.g., restricted "HITEC City" boundaries) and instantaneously routes these to a priority
rider-alertstopic. - Internet Access Tunneling: Integrates NGrok tunneling and Vercel static hosting to ingest real-world GPS streams from mobile phone HTML5 Geolocation sensors.
Instead of relying on remote endpoints, pre-trained Scikit-Learn models are embedded directly into PySpark User-Defined Functions (UDFs) to execute inferences natively over the streaming window.
- AI ETA Prediction (Random Forest Regressor):
- Features: Latitude, Longitude, Hour of Day, Day of Week.
- Operation: Predicts spatial "time-to-completion" dynamically based on traffic and time-of-day features.
- Ghost Rider / Fraud Detection (Isolation Forest):
- Operation: An unsupervised anomaly detection model that isolates spoofed GPS coordinates, unrealistic speeds (> 150km/h), or erratic routes.
- Impact: Flags anomalies instantly (
anomaly_score,is_anomaly), triggering an automated red pulsating visual alert directly on the web frontend.
An automated stress-testing suite (benchmark.py) was executed to push Kafka and PySpark to high concurrency thresholds locally.
Load Test Parameters: Emitting continuous payloads over a 30-second window.
- 10 Concurrent Riders: Processed 300 events (~9.94 msgs/sec).
- 100 Concurrent Riders: Processed 3,000 events (~99.23 msgs/sec).
- 1,000 Concurrent Riders: Processed 27,000 events (~883.68 msgs/sec).
- 10,000 Concurrent Riders: Processed 120,000 events (~3,846.16 msgs/sec).
Result: The architecture scaled linearly, demonstrating no bottlenecks at nearly 4,000 GPS messages per second, proving production-viability for urban-scale fleets.
Real-Time AI Delivery Tracking Platform | Apache Kafka, PySpark, Node.js, Scikit-learn, WebSockets, MongoDB
- Architected a real-time event-streaming platform using Apache Kafka (KRaft) and Node.js to ingest and process live GPS telemetry, successfully benchmarked to handle 10,000 concurrent geographic simulators emitting ~4,000 events/second.
- Engineered a PySpark Structured Streaming pipeline utilizing a 10-second sliding window to map coordinate streams into Uber H3 spatial indexes, replacing heavy database queries with sub-millisecond in-stream spatial aggregation.
- Deployed Scikit-Learn Machine Learning models (Random Forest, Isolation Forest) directly as PySpark User-Defined Functions (UDFs) to perform real-time ETA predictions and instantly flag simulated GPS spoofing ("Ghost Riders").
- Decoupled backend processing from UI via a WebSockets (Socket.io) router, broadcasting dynamic AI geofence alerts and hexagonal traffic-density heatmaps to a Leaflet.js frontend with sub-second latency.
Real-Time Urban Delivery Tracker System | Node.js, Express, Kafka, PySpark, Leaflet.js, Spatial Data
- Built an end-to-end, event-driven geospatial tracking architecture simulating large-scale gig-economy fleets (like UberEats/Swiggy).
- Utilized standalone Apache Kafka and Python producers pulling from the OSRM API to simulate vehicle routing scenarios and transmit large-scale telemetry data reliably.
- Offloaded complex logic to a PySpark processing layer capable of running Uber H3 Hexagon indexing and live Geofencing point-in-polygon checks natively on data streams.
- Constructed a live monitoring dashboard using Leaflet.js, which consumes WebSocket events from a Node.js/MongoDB microservice to render map animations, AI predictions, and color-coded traffic clusters at <100ms latency.
- Evaluated architecture reliability by developing a Python stress-testing suite, validating linear scaling throughput up to 120,000 ingestions per 30-second window.