ADR-00024 — Shared Checkout-Info Resolution vs. Per-Screen Enrichment
- Status: Approved / Implemented
- Date: 2026-10-02
- Authors: Engineering Team
Context
shop-service has at least two places that need the same kind of per-SKU information — current selling price, discount price, stock, tax, warehouse, and shipping weight: the product-detail screen’s single-item shipment/price estimate, and the real multi-line checkout flow (cart-based or a single Buy Now item). Before consolidation, checkout resolved this by calling the cart service’s own pricing join (GetCart, which internally enriched lines via a product-variant lookup) and a separate, standalone tax-calculation call. As checkout’s requirements grew (it needed tax, warehouse, and weight data the cart join didn’t already carry), the question was whether to keep extending that per-caller enrichment path independently for each screen that needs it, or to consolidate the whole per-SKU resolution — pricing, stock, tax, warehouse, and weight together — behind one shared call that every caller uses identically.
Decision Drivers (FRs & NFRs)
See SR-012 for the full requirement list.
- BR-01 (BRD-011): price, stock, and delivery-estimate figures must never disagree between the product-detail screen, the cart, and checkout.
- BR-04 (BRD-011): the cost of maintaining pricing/availability/delivery logic must not grow with every new screen that needs it.
- FR-01 / FR-02 (SR-012): a single consolidated checkout-info call and a single shared shipment-serviceability service, both reused identically by the product-detail preview and by checkout.
- NFR-01 (SR-012): a caller may map a shared result into its own local output shape, but must not reimplement the underlying resolution logic.
Options Evaluated
Option 1 — Single consolidated GetCheckoutInfo/GetServiceability, reused identically by every caller (CHOSEN)
Resolve price, discount, stock, tax, warehouse, and weight for a set of SKU lines through one inventory-service call (GetCheckoutInfo), and resolve shipment tiers through one shared shipment.IShipmentService.GetServiceability service method — both called the same way whether the caller is the product-detail preview (a single synthetic line) or real checkout (the full cart/Buy-Now line set).
- Pros:
- One source of truth for price/tax/stock. Because the product-detail preview and checkout call the exact same method, the figures shown while browsing can never diverge from the figures charged at checkout — directly satisfying BR-01.
inventory-serviceis now the sole authority on SKU price/tax/weight for checkout;shop-serviceno longer computes or hands over a taxable value itself. - Replaces what used to be two separate round trips with one. The consolidated call replaced the cart’s own pricing join (
GetCart→GetProductVariantsBySkuIDs) plus a standalone tax-calculation call — fewer round trips per checkout read, and one less place for the two to disagree with each other. - New callers get the computation for free. A future screen needing the same per-SKU information reuses the existing call rather than writing a third independent implementation of the same pricing/tax logic — directly satisfying BR-04.
- Caller-specific behavior stays local, where it belongs. The two existing callers still differ in how they react to a failure — the product-detail preview degrades to an empty shipment estimate on a lookup failure, while checkout hard-fails, since a price summary cannot be computed without a shipping fee. That differentiation lives at the call site, not inside the shared method, keeping the shared method itself free of per-caller special cases.
- One source of truth for price/tax/stock. Because the product-detail preview and checkout call the exact same method, the figures shown while browsing can never diverge from the figures charged at checkout — directly satisfying BR-01.
- Cons & Accepted Trade-offs:
- A change to the shared call’s output shape affects every caller. Adding a new field or changing a computation inside
GetCheckoutInfonow has to be considered against both the product-detail preview’s and checkout’s use of it, rather than being scoped to one caller. - Each caller still owns a small amount of local orchestration. The shared call resolves the data, but each caller still does its own entity-to-domain mapping and failure-handling — checkout maps into its own
ShippingTierOption, the product page maps into its ownShipmentEstimate, deliberately kept as separate output types rather than forced into one shared shape.
- A change to the shared call’s output shape affects every caller. Adding a new field or changing a computation inside
Option 2 — Each caller resolves its own pricing/tax/stock independently
Keep (or re-introduce) a per-caller enrichment path — the product-detail preview calling one set of repository methods, checkout calling its own pricing join plus a separate tax call, and any future screen building a third independent path.
- Pros:
- A caller’s enrichment logic is fully local — no shared contract to coordinate changes around.
- A caller can shape its own query exactly to what it needs, with no risk of a shared method’s behavior changing underneath it.
- Cons (Why Rejected For This Stage):
- This was the actual prior state, and it already needed consolidating. Checkout’s own pricing join and tax call were two separate round trips against the same SKU set, carried over from before checkout needed warehouse/weight data the join didn’t provide — the first real instance of this pattern already produced duplicated logic that had to be unified.
- The number of independent implementations of the same business rule grows with every new screen. Each one is a separate opportunity for the pricing/tax/stock figures to drift, directly working against BR-01 and BR-04.
- No single shared point to add a future consumer’s needs to — a new requirement (e.g. a new discount rule) would need to be threaded through N separate implementations rather than one.
Final Decision
Option 1 is selected and implemented. inventory-service’s GetCheckoutInfo and the shared shipment.IShipmentService.GetServiceability are the sole resolution points for per-SKU pricing/tax/stock/warehouse/weight and shipment tiers respectively, consumed identically by shop-service’s product-detail preview and its real checkout path — satisfying BRD-011’s BR-01 and BR-04, and SR-012’s FR-01, FR-02, and NFR-01.
This decision is revisited, not fixed. If a future caller’s needs diverge from the shared call’s shape so substantially that forcing it through GetCheckoutInfo/GetServiceability creates more complexity than a scoped, caller-local implementation would, that caller’s fit should be re-evaluated on its own merits rather than stretching the shared contract to cover it — no such divergence has been observed yet.
Related Documents
- BRD-011 — Reusable Product-to-Order Journey With Trustworthy Totals
- SR-012 — Reusable Checkout Orchestration: System Requirements
- ADR-00025 — Cached Checkout-Session Snapshot vs. Recompute at Order Creation
- Architecture: Reusable Product-to-Order Orchestration
- Architecture — Checkout Completion: Payment Capture and Fulfillment Handoff — detailed payment-capture flow downstream of this decision
- Architecture — Multi-Courier Fulfillment via Shiprocket — detailed shipment/courier flow downstream of this decision
- Technical Debt — Reusable Checkout Orchestration Gaps
- Microservices: shop-service, inventory-service, shipment-service