Preparing your design workspace

Loading the problem and your latest saved attempt…

Meal Delivery to Train Passengers

Help passengers order from restaurants near an upcoming station and receive a meal at their coach and seat during the stop.

Problem statement

Design a service that delivers restaurant meals to passengers on a moving train. Passengers choose a restaurant near an upcoming station, order food, and receive it at their coach and seat while the train is stopped.

For this exercise, assume the passenger already has a confirmed trip. A train-run ID identifies one dated journey; a station ID alone does not identify the delivery stop. The service lists restaurants that can prepare and deliver to a selected upcoming stop before its cutoff.

It accepts an order with the trip, station, coach, seat, and items, then coordinates restaurant acceptance, courier assignment, and a confirmed handoff.

Assume payment authorization already exists and payment processing is outside scope. An order is either accepted durably or rejected with a clear reason. Retrying the same placement must not create another order. Train updates may arrive late or out of order.

Explain what happens when an ETA changes, a restaurant or courier fails, a passenger changes their seat, or the train leaves before delivery can be confirmed. Do not mark an order delivered from its location or ETA alone.

For this exercise, order changes are allowed only before the restaurant accepts the order. After acceptance, keep the delivery details fixed and use an explicit cancellation or exception process. Focus on one country, a trusted train-location provider, and one delivery station per order.

Restaurant inventory management, rail ticketing, restaurant recommendations, and payment settlement are outside scope.

What to build

  1. Show restaurants and items that can be delivered to a chosen upcoming stop on the passenger’s dated train run.
  2. Accept or reject an order with its station, coach, seat, and items, and let the passenger inspect its current state.
  3. Coordinate restaurant acceptance and courier delivery, and record an actual passenger handoff or a clear failure outcome.
  4. Update delivery eligibility and notify affected passengers when train timing or delivery progress makes the order at risk.

At scale

  • For this exercise, assume one million orders per day, peaks of 1,000 placement requests per second, and 5,000 restaurant-search requests per second.
  • Assume a typical station stop lasts 2–5 minutes. The train provider sends updates about every 15 seconds, but updates may be 30 seconds late or out of order.
  • An accepted order must survive one application-node failure. Duplicate client retries and repeated provider or courier messages must not create a second order, acceptance, or delivery.
  • Target search p95 below 300 ms and order acceptance p95 below 1 second without waiting for a restaurant or courier. Show valid delivery-status updates within 5 seconds under normal operation.