Question
Design a batched delivery-dispatch system for an on-demand grocery platform. Orders arrive continuously; couriers are moving around the city. Instead of assigning each order to the nearest courier instantly, you want to batch nearby orders that can share a route and assign each batch to the best courier, re-solving every ~30 seconds over a metro of ~20k live orders and ~5k couriers. Goals: minimize total courier travel and delivery lateness while keeping food fresh. Describe the batching, the assignment formulation, how you keep the solve tractable at this scale, and how you handle orders that keep losing out.
Clarify scale and constraints first. Propose a clean component breakdown, then go deep on the hard parts — data model, bottlenecks, consistency, failure modes — and name the trade-offs you are making.