ADR-002: Preserve the checkout-time purchase snapshot
Each accepted Order records the book identifiers, quantities, and prices selected at checkout so later Catalog changes do not rewrite the purchase.
1. Context & Problem
When a customer places an order, the Ordering system reads items from the customer’s shopping basket and looks up current book pricing from the Catalog. Both of those upstream sources change continuously—customers clear or edit their baskets after checkout, and merchandisers update book prices or run promotions in the Catalog.
If an order relied on the basket or live Catalog prices to calculate its contents or total later on, a routine price change or basket edit would retroactively alter an already accepted purchase. Those upstream systems are authoritative for current baskets and current catalog offerings, not for what a customer agreed to pay at a past checkout.
2. Business Value
- Commercial accuracy and trust: Customers and finance teams see the exact quantities, unit prices, and totals agreed upon at checkout, regardless of later promotions or price increases.
- Dispute and audit readiness: Order history acts as a reliable record of accepted purchase terms without requiring manual price reconstruction.
- Clean domain boundaries: Merchandisers can freely update catalog prices and descriptions without worrying about breaking historical orders.
3. How It Works
Before accepting an order, Order APIServicev1.0.0Order APIAuthenticated Ordering service for Buyer profiles and the Order lifecycle, creating Orders from baskets, snapshotting pr...PublishesGetBasketGrpc, GetBookGrpc +5SubscribesCreateOrder, CompleteOrder +11APIsOpenAPI, AsyncAPI, Carrier Service LevelsOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs retrieves the customer’s current basket from Shopping and verifies each book and its price with Catalog. If any requested book cannot be resolved, order creation fails rather than saving an incomplete purchase record.
For every item in the checkout, Ordering captures a permanent purchase snapshot containing:
- The book’s unique identifier
- The quantity ordered
- The unit price active at checkout (using the sale price when available, otherwise the regular price)
The order total is calculated from these recorded values and stored with the order. Later catalog price changes only apply to new checkouts, and later basket edits never rewrite accepted order items. When an order is displayed back to a user, current book titles may be looked up from Catalog for display purposes, but that presentation enrichment never overwrites the stored checkout price or quantity.
4. Trade-offs & Lessons Learned
Alternatives Considered
- Resolve Order history from the current basket: Rejected because baskets are mutable and routinely cleared or modified after checkout.
- Re-read Catalog prices whenever an Order is displayed: Rejected because historical order totals would shift whenever catalog prices change.
- Store a complete copy of the Catalog book: Rejected because duplicating all book metadata creates unnecessary ownership overlap, update sync burden, and retention overhead.
Operational Trade-offs & Risks
- Pre-checkout dependency on Shopping and Catalog: Because a complete snapshot is mandatory, temporary unavailability of basket or catalog lookups—or missing book data—blocks new order creation.
- Display names can evolve: Book names enriched at read time reflect current Catalog naming while prices and quantities remain frozen at checkout time; teams should not expect historical titles to stay frozen if Catalog renames a book.
- Snapshot is not payment or fulfillment proof: Recording an accepted purchase snapshot does not mean payment has settled, fulfillment occurred, or the order reached a final status.
5. Technical Reference
- Service & Entities: Implemented by Order APIServicev1.0.0Order APIAuthenticated Ordering service for Buyer profiles and the Order lifecycle, creating Orders from baskets, snapshotting pr...PublishesGetBasketGrpc, GetBookGrpc +5SubscribesCreateOrder, CompleteOrder +11APIsOpenAPI, AsyncAPI, Carrier Service LevelsOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs, persisting Order and Order Item records in Order DatabaseContainerv1.0.0Order DatabaseAuthoritative PostgreSQL system of record owned by the Ordering bounded context for buyers, accepted orders, purchase-ti...Ownercommerce-fulfillment-teamDiagramOpen docs.
- Captured fields per Order Item: Book ID, quantity, and selected unit price (sale price when present, otherwise regular price).
- Validation rule: Basket contents are fetched from Shopping and resolved against Catalog prior to persisting the Order aggregate; unresolved books fail Order creation.
- Read-time enrichment: Current book names may be hydrated from Catalog during Order reads as presentation data without mutating persisted item price or quantity.
- Boundary reminder: Catalog remains authoritative for current book descriptions, availability, and prices; Shopping remains authoritative for mutable baskets; Ordering owns only the purchase-time item snapshot.