System Design Atlas

Restaurant orders between service and kitchen

04 / 10Worked example

Change commands and retries

How does the kitchen ticket distinguish repetition and additional portion?

Scale alone does not ensure consistent retry behaviour. This proposed API binds the role, business object, change payload and expected state to each new intent. An idempotency key identifies the same intent after a response is lost.

Starting point Test 20 orders/min separately.

Assumptions for the example case

Our fictional example design covers one restaurant with table service, individual ordered portions, explicit kitchen acceptance, cancellation before preparation starts and recorded handover. Quantities and quality goals are illustrative test assumptions. Cash-register regulations, payment processing, automated allergen safety and delivery logistics are outside the scope.

Retries and new intent

Ticket envelope and stored acceptance

Ticket K-131P-131 · P-132 · Key
Ticket K-131 → AnnahmeregisterIdentical / changed / new
Acceptance registerHistorical response
Identical request → two portions+ another item → conflictHandover retry → one record

Retry K-131 with the same key and portion list; adding a third portion under the same key causes a conflict.

Send is retried after a timeout. Persist and compare K-131 and its content. Two portions remain two portions.

Proposed domain API contracts

  1. POST/table-orders

    Send concrete portions to the kitchen.

    Input
    Service staff, table, portion identities P-131/P-132, dishes, instructions and a stable key.
    Result
    T-131 and K-131 are durably recorded; kitchen acceptance remains separately visible.
    Retry behaviour
    An identical operation by the same authorised role on the same object, using the same key and canonical payload, returns the stored original result. A changed payload under that key is rejected. External result identifiers are durably deduplicated after authentication; new intents check the current version again.
  2. POST/portions/{id}/start

    Start preparing an accepted portion.

    Input
    Kitchen team,P-131, expected portion version and key.
    Result
    in_zubereitung only from angenommen; a prior cancellation causes a conflict.
    Retry behaviour
    An identical operation by the same authorised role on the same object, using the same key and canonical payload, returns the stored original result. A changed payload under that key is rejected. External result identifiers are durably deduplicated after authentication; new intents check the current version again.
  3. POST/portions/{id}/cancel

    Process the cancellation request.

    Input
    Service,P-131, expected version, reason and key.
    Result
    storniert before preparation starts; after preparation starts, a recorded investigation preserves the work.
    Retry behaviour
    An identical operation by the same authorised role on the same object, using the same key and canonical payload, returns the stored original result. A changed payload under that key is rejected. External result identifiers are durably deduplicated after authentication; new intents check the current version again.
  4. POST/portions/{id}/ready

    Report actual completion.

    Input
    Kitchen team,P-131, version and key.
    Result
    fertig only from a permitted preparation state.
    Retry behaviour
    An identical operation by the same authorised role on the same object, using the same key and canonical payload, returns the stored original result. A changed payload under that key is rejected. External result identifiers are durably deduplicated after authentication; new intents check the current version again.
  5. POST/portions/{id}/handover

    Confirm the handover once.

    Input
    Service staff, P-131, version and handover key.
    Result
    One handover record and state ausgegeben; a retry creates no second handover.
    Retry behaviour
    An identical operation by the same authorised role on the same object, using the same key and canonical payload, returns the stored original result. A changed payload under that key is rejected. External result identifiers are durably deduplicated after authentication; new intents check the current version again.
  6. GET/kitchen-tickets/{id}

    Reconcile acceptance and portion states.

    Input
    Service or kitchen team,K-131.
    Result
    Existing portions, acceptance status and clarification reasons; no new production on reading.
    Retry behaviour
    Repeating a read creates no business effect; the returned current state may change between requests.

Recognise the same kitchen ticket

Recognise the same kitchen ticket

Persist and compare K-131 and its content.

Send is repeated after Timeout.

Two portions remain two portions.

Alternative considered
A new ticket for each click duplicates the work.
Trade-off
Key must survive device change.
Reassess
Re-entering orders offline requires explicit conflict rules.

Terms in this step

Recognise the same kitchen ticket
Two portions remain two portions.

Try it yourself

K-131 is identical and then repeated with a third portion. Predict both outcomes.

A hint for your attempt

Use the specific entities and conditions from this step. The two solution parts distinguish the decision from its evidenced outcome.

Compare with a possible solution
First part of the solution
An identical retry returns the same two portions and the same acceptance state.
Second part of the solution
Adding a third portion under the same key causes a conflict; an additional order requires a distinct new intent.

Apply to your project

Which corresponding assumption in your project would you check first? Consider this trigger: Re-entering orders offline requires explicit conflict rules.

Step 5 serialises preparation starts and cancellations.