Skip to content

Kitchen — version 1

Kitchen bounded context — turning a placed order into a cooked pizza. It watches the orders Ordering publishes and runs each one through the kitchen workflow: a ticket is queued, prepped, baked, and put up on the pass. Kept in its own context so “how the kitchen cooks” evolves independently of “how an order is taken”.

classDiagram
    class Station {
        <<enumeration>>
        OvenA
        OvenB
        Cold
    }
    class TicketStage {
        <<enumeration>>
        Queued
        Prepping
        Baking
        Ready
        Served
        Scrapped
    }
    class TicketOpened {
        <<event>>
        +TicketId ticketId
        +OrderId order
    }
    class TicketStartedBaking {
        <<event>>
        +TicketId ticketId
        +Station station
    }
    class KitchenTicket {
        <<aggregate root>>
        +TicketId id
        +OrderId order
        +Station station
        +TicketStage stage
        +Int pizzas
        +List~Topping~ toppings
        +Instant startedAt
        +Bool /isCooking
        +Bool /isDone
        +Bool /started
        +open(OrderId order, Station station, Int pizzas, List~Topping~ toppings) KitchenTicket
        +prep()
        +bake()
        +putUp()
        +serve()
    }
    TicketOpened --> KitchenTicket
    TicketStartedBaking --> KitchenTicket
    TicketStartedBaking *-- Station
    KitchenTicket *-- Station
    KitchenTicket *-- TicketStage

The kitchen-ticket aggregate: one ticket per order on the line. Being an aggregate root it gains an IKitchenTicketRepository and joins the context UoW; the repository block adds intention-revealing finders.

Root entity: KitchenTicket (identified by TicketId)

Repository finders:

  • atStation(station: Station): List<KitchenTicket>
  • inProgress(): List<KitchenTicket>

Repository operations: getById, add, update

TicketOpened

Raised inside the aggregate when a ticket is opened by the factory.

FieldTypeDescription
ticketIdTicketId
orderOrderId

TicketStartedBaking

Raised when a ticket goes into the oven.

FieldTypeDescription
ticketIdTicketId
stationStation
stateDiagram-v2
    [*] --> Queued
    Queued --> Prepping
    Queued --> Scrapped
    Prepping --> Baking
    Prepping --> Scrapped
    Baking --> Ready
    Baking --> Scrapped
    Ready --> Served
    Ready --> Scrapped
    Served --> [*]
    Scrapped --> [*]
FromToGuard
QueuedPrepping
QueuedScrapped
PreppingBaking
PreppingScrapped
BakingReady
BakingScrapped
ReadyServed
ReadyScrapped
Served(terminal)
Scrapped(terminal)

Start prepping a queued ticket.

Preconditions:

  • only a queued ticket can be prepped

Effects:

  • stage -> Prepping

Put a prepped ticket into the oven, stamping the time.

Preconditions:

  • only a prepped ticket can be baked

Effects:

  • stage -> Baking
  • startedAt -> now

Events:

  • TicketStartedBaking(ticketId: id, station: station)

Pull a baked ticket out and put it up on the pass.

Preconditions:

  • only a baking ticket can be put up

Effects:

  • stage -> Ready

Hand a ready ticket off to the front of house or the driver.

Preconditions:

  • only a ready ticket can be served

Effects:

  • stage -> Served
open(order: OrderId, station: Station, pizzas: Int, toppings: List<Topping>)
Section titled “open(order: OrderId, station: Station, pizzas: Int, toppings: List<Topping>)”

Open a ticket for a placed order. The same-named parameters auto-bind the required fields (order, station, pizzas, toppings); stage defaults to Queued.

Preconditions:

  • a ticket must cook at least one pizza

Events:

  • TicketOpened(ticketId: id, order: order)

Business rules

  • a ticket must cook at least one pizza

The station a ticket is routed to. A plain enum used for load-balancing.

Values: OvenA, OvenB, Cold

The lifecycle state of a kitchen ticket. Drives the states stage { … } machine on the entity, so only the declared transitions are legal at runtime.

Values: Queued, Prepping, Baking, Ready, Served, Scrapped

Raised when a ticket is finished and put up on the pass. A delivery / dine-in handler reacts to it; kept primitive as a published fact.

FieldTypeDescription
ticketIdTicketId
orderOrderId
readyAtInstant

Published by this context.

KindCoveredTotal
aggregate11
entity11
enum22
event22
integrationEvent11
query01
readModel01

⚠️ 2 not documented