Food Delivery

Food Delivery with catalogs, availability, pricing, and orders.

Architecture

High-level components and data flow

Data Model

Core entities and relationships

  • products (sku PK, name, price)
  • orders (order_id PK, user_id, status, total)
  • order_items (order_id, sku, qty, price)

APIs

  • GET /api/products
  • POST /api/orders { items }
  • GET /api/orders/:id

Scaling

  • Cache catalog
  • Shard orders
  • Async stock updates

Trade-offs

  • Strong order consistency vs throughput
  • Inventory reservation vs oversell
  • Promo complexity vs performance

Failure Modes & Mitigations

  • Payment timeouts → retry
  • Stock race → reservation
  • Order partial failure → compensation

Observability

  • Order success rate
  • payment auth rate
  • stockout events