Cafe / Restaurant Scenario

A scenario exploring frontend (FOH) and backend (BOH) workflows using DDD, CQRS, and Event Sourcing.

Context

Customer visits cafe, sits at a table, orders drinks and food, kitchen/back-of-house fulfills the order, and payment is processed. The model tracks tabs, orders, kitchen tickets, and payments.

Building Blocks

  • Aggregates: Tab, Order
  • Entities: Customer, Server, Table, MenuItem, Dish, Drink, KitchenTicket, Payment
  • Domain Events: TabOpened, TableSeated, OrderPlaced, ItemAddedToOrder, OrderPrepared, DishReady, DishServed, PaymentProcessed, TabClosed
  • Commands: OpenTab, SeatCustomer, PlaceOrder, AddItemToOrder, StartPreparation, EndPreparation, ServeItem, CloseTab, ProcessPayment

Lifecycle

  1. Open a tab for a table.
  2. Place drinks and meals on the order.
  3. BOH starts preparation; orders progress to ready.
  4. FOH serves dishes; customer finishes tabs and pays.
  5. Tab closes; revenue recorded.

Policy Examples

  • Wait-time SLA: if ETA > 15 minutes, trigger table offer for refills or alternative items.
  • Over-queue policy for kitchen: cap concurrent orders per station.