java, system design, real-time systems, kafka,

Dashflow – Reactive Order Assignment System

Pritesh K Pritesh K Follow Jul 01, 2025 · 1 min read
Dashflow – Reactive Order Assignment System
Share this

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

  1. Orders are sent in real time via REST (/orders)
  2. Orders are streamed through Kafka
  3. Orders are buffered and batched by ZIP code (zone)
  4. Assignment logic runs on a schedule (e.g., every 60 seconds)
  5. 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

  1. Clone the repo
  2. 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}'

Join Newsletter
Get the latest news right in your inbox. We never spam!
Pritesh K
Written by Pritesh K Follow
AI Consultant