Dashflow – Reactive Order Assignment System
A DoorDash-style real-time backend for batching and assigning food delivery orders using Spring Boot WebFlux, Kafka, and Project Reactor.
🧩 Problem Statement
Food delivery platforms like DoorDash need to efficiently group and assign high volumes of incoming orders while minimizing delays and driver overhead.
However:
- Orders arrive continuously and unpredictably
- Naive one-order-per-runner logic creates inefficiencies
- Delays in assignment hurt both customers and restaurants
❓ Why Are We Solving This?
Let’s say:
- 🧍♂️ Person A (in ZIP 85719) orders from Domino’s
- 🧍♀️ One minute later, Person B (same ZIP) orders from Burger King — close to Domino’s
Instead of dispatching two drivers, we batch the orders and assign them to one runner, saving time and cost.
🎯 Goal
Design a backend system that simulates real-time:
- Order ingestion
- Batching by delivery zone
- Assignment to delivery runners
- Routing logic for efficient chunked dispatching
🛠 Tech Stack
Component | Tool/Framework |
---|---|
Reactive Backend | Spring Boot WebFlux |
Event Streaming | Apache Kafka |
Reactive Streams | Project Reactor |
Batching & Assignment | Custom Zone-Aware Logic |
Deployment | Localhost via Docker/Kafka |
🧪 Working
- Orders are sent in real time via REST (
/orders
) - Orders are streamed through Kafka
- Orders are buffered and batched by ZIP code (zone)
- Assignment logic runs on a schedule (e.g., every 60 seconds)
- Chunked orders are assigned to available runners
✅ Result
- Achieved 2× faster dispatch times by reducing latency
- Enabled zone-based batching for grouped deliveries
- Simulated real-world delivery routing scenarios
- Laid the foundation for a scalable food delivery backend
▶️ Running the Project
- Clone the repo
- Start Kafka with Docker:
docker-compose up -d
./gradlew bootRun
curl -X POST http://localhost:8080/orders \
-H "Content-Type: application/json" \
-d '{"restaurantId": "r1", "customerAddress": "123 Main St", "zone": "85719", "estimatedPrepTime": 10}'