dine. a kitchen run by sagas Book a table
Log in with Google (coming soon)

One order, three services, no step left half-done.

dine is an ordering system for a restaurant. Each order needs a table held, the kitchen told and money collected, in three separate services. If one step fails, the steps already done undo themselves. The tickets below are orders running on the system.

Waiting for the first order…

{{ mineState === 'ok' ? T('Bạn chưa có đơn nào.') : T('Bạn chưa có đơn nào trong {n} đơn gần nhất.', { n: orders.length }) }} Press “Book a table” to book one.

✓ done ✕ failed ↺ undo … waiting

See the scenarios

Each card opens a sample order that takes exactly one branch of the saga, with a diagram of each service's reply. To try it yourself, press Book a table and turn on “Incident test”. Why a saga and not one shared transaction? Read the article.

What happens to an order

Three steps run at once

Holding the table, telling the kitchen and collecting the money don't wait for each other. The booking is confirmed only when all three report done.

One step fails, what was done is undone

If the payment is declined, the held table is released and the dishes sent to the kitchen are cancelled. No order is left half-done.

Late replies are still handled

A slow network can make a service report done after the order was cancelled. The system notices and undoes that step on its own instead of ignoring it.

A sudden crash does not lose orders

The order and the outgoing requests are written in the same transaction. If the sending machine stops halfway, another one picks up the work.

Architecture

Why dine exists, what each service does, and why microservices are more than splitting code into many repos: read the introduction.

Browserdinesaga.app
Gatewaylogin, CORS, routing
Ordercoordinates each order (saga)
own DB: orders, saga, outbox
Kafka order-events: commands out → ← saga-step-responses: replies
Tablesassigns 500 seats
own DB
Kitchentakes stock, Aerospike lock
own DB
Paymentscharges, refunds
own DB

One database per service

No service reads another service's data directly. To know something, it asks through messages.

They only talk through Kafka

Order sends commands to one topic and the services reply to another. Nobody calls anybody directly.

Order is the only one that knows the whole order

The other services only take work, do it and report the result. Decisions to cancel or undo all belong to order.

Break an order yourself

Log in with Google to book your own table and pick a failure: a declined card, or a service that replies so late the system thinks it has died. Then watch the system untangle itself.

Log in with Google (coming soon)