Course map

Project 06

Shopping cart and order management

Transactions, business workflows

Start after Part 5

Key topics 46, 70

Architecture Modular monolith, single database (deliberate scope)

Brief

Cart (add, update, guest-to-user merge), checkout, order creation, and the order lifecycle (placed → paid → fulfilled → delivered, or cancelled/refunded), with catalog, inventory, and payment as module boundaries inside one deployable.

Scope rule: everything commits in one database with local transactions (→ 70). This is the point of the project — master the single-database solution before distributing it. The cross-service version of this workflow is Projects 8 and 15, where outbox (→ 118) and saga (→ 139) become necessary.

Targets

1k checkouts/min peak · zero lost or duplicated orders · order state visible within 2 s · 99.95% availability.

Must cover

  • Order state machine with legal transitions enforced (→ 46).
  • Transaction boundaries — one business operation, one transaction (→ 70).
  • Payment-pending and cancellation states — the unhappy paths modeled explicitly (P).

Design challenges

  1. Cart storage: database vs. cache with TTL for abandonment; guest-cart merge on login.
  2. Checkout as one transaction: reserve stock, record payment intent, create order — isolation level chosen and defended against write skew (→ 70).
  3. The order state machine (→ 46) enforced in the domain model (→ 55), including payment-pending, cancellation, and refund paths.
  4. Exactly one order from a double-clicked "Place order": idempotency-key design (→ 38).
  5. Price consistency: the price shown vs. the price charged when the catalog changed mid-checkout — decide and document the rule (→ 21).

Out of scope

Cross-service distribution, external payment integration (Project 8), multi-warehouse fulfillment. Step 21 must include: "what would force this to become distributed, and what it would cost."

Search the guide