Clear responsibilities.
Durable decisions.
PostgreSQL owns durable order state. Redis supports short-lived coordination. Background work follows committed events.
The boundaries that matter.
- Clients request actions; the server validates identity, role, ownership and current state.
- Order creation stores its event and outbox work in the same database transaction.
- The worker claims durable jobs using leases. Retry and acknowledgement are separate from the original HTTP request.
- Payment confirmation is checked by the server. A client checkout callback alone is not payment proof.
- Provider acceptance and database acknowledgement cannot be one atomic transaction. Notification retries can repeat an external send.
Every transition has a boundary.
The normal journey advances from placed to delivered. Cancellation and expiry are explicit terminal states. These edges come directly from the server’s transition table.
Read the transition table
- PLACED
- CLAIMED, CANCELLED, EXPIRED
- CLAIMED
- ARRIVED, CANCELLED
- ARRIVED
- VERIFIED
- VERIFIED
- PAID
- PAID
- DELIVERED
- DELIVERED
- Terminal — no outgoing transitions
- CANCELLED
- Terminal — no outgoing transitions
- EXPIRED
- Terminal — no outgoing transitions
A guarded SQL update checks the previous state. The transition event is inserted in the same transaction. Claims also lock the order and vendor rows; a database constraint prevents multiple active orders for one vendor. QR and payment transitions use their dedicated services.