Two kinds of state
- A cart is long lived and forgiving. It can be lost without much harm and is often stored per user or per session.
- A checkout is short lived and strict. It captures address, shipping, payment, and must move through clear steps.
Where the cart lives
- Client only: fast but lost across devices.
- Server keyed by user: survives device switches and powers reminders.
- Hybrid: a guest cart in the browser that merges into the server cart on sign in.
Checkout as a state machine
Checkout moves through states such as started, address set, payment authorized, and confirmed. Each transition is explicit so you can resume an interrupted checkout and avoid charging without an order.
Key idea
Keep the cart durable and forgiving, and model checkout as an explicit state machine so each step is resumable and no payment happens without a confirmed order.