Architecture — Reusable Product-to-Order Orchestration
| Metadata | Details |
|---|---|
| System | Reusable Product/Checkout Orchestration |
| Document ID | ARCH-2026-CHO-001 |
| Author | Engineering Team |
| Status | Approved |
Implements SR-012, per the decisions in ADR-00024 and ADR-00025.
Diagram

Note on the diagram’s “Get product info by product id” node: it is labeled
[shipment-service]. The real call wiring (shop-service’sinternal/repository/product/product_imp_rep.go:146,detailClient.GetProductFullDetail) is a gRPC client call toproduct-catalog, notshipment-service— product descriptive data has never been served byshipment-service. This is a diagram-labeling issue only; the flow sections below describe the correct attribution. Tracked as TD-01 — only the exported.pngwas available for this review, not the editable.drawiosource, so the correction is documented here rather than made in the image itself.
Components
| Component | Language / Runtime | Role in this journey |
|---|---|---|
shop-service |
Go, Echo (REST/GraphQL) + MongoDB | Owns product-detail shipment preview, cart, checkout (GetCheckoutDetails, RecalculateCheckoutPricing), and the checkout_session cache. The orchestration hub for this entire journey — SR-012 FR-01, FR-02, FR-04 through FR-10. |
product-catalog |
Go, gRPC server | Source of product descriptive data (GetProductFullDetail) — name, images, description, category. Not involved in pricing or shipment resolution. |
inventory-service |
Go, gRPC server | Owns GetCheckoutInfo — the single consolidated resolution of per-SKU price, discount price, stock, tax, warehouse, and weight, reused identically by the product-detail preview and real checkout — SR-012 FR-01. |
shipment-service |
Go, gRPC server | Owns GetServiceability (shipment tier/fee/ETA resolution by zipcode and weight), consumed identically by the product-detail preview and checkout — SR-012 FR-02. |
payment-service |
Rust, gRPC server | Supplies allowed payment methods per tenant, consulted during checkout resolution and re-quote. |
pii-service |
Rust, gRPC server | Encrypted address store. Checkout snapshots shipping/billing addresses by reference only; order creation resolves the actual address content server-side at order time — SR-012 FR-14. |
order-service |
Go, MongoDB, gRPC server/client | Creates the order from the cached checkout session exactly once, enforces idempotency, and drives the Temporal checkout saga — SR-012 FR-11 through FR-14. |
checkout_session (MongoDB collection, owned by shop-service) |
— | The cached, full-aggregate checkout quote — addresses (by reference), order items, tax summary, warehouse, weight, shipment tier options, allowed payment methods, and price summary — keyed by a freshly minted token, insert-only except for one scoped re-quote update — SR-012 FR-07, FR-08. |
What the customer sees, screen by screen
Before tracing the data flow below, here’s the actual UI this journey produces — a real, screenshot-backed walkthrough of each screen the flows below describe:
- Product Detail — the screen flow (A) describes, ending in Add to Cart or Buy Now.
- Cart — persisted cart lines, feeding flow (B)‘s cart-based path.
- Checkout — the checkout review flows (B) and (C) build and re-quote.
- Buy Now Checkout — the same checkout review, reached via flow (B)‘s Buy-Now path.
End-to-end flow (A) — Viewing a product and its shared shipment/price estimate
- The customer opens a product-detail screen.
shop-service’sproduct_full_section.gocallsproduct-catalog’sGetProductFullDetailfor descriptive content (name, images, category). - For the shipment/price estimate shown on the same screen,
getProductShipmentEstimatebuilds a single synthetic order line (the one SKU being viewed, quantity 1) and calls the exact sameinventory-service.GetCheckoutInfoandshipment.IShipmentService.GetServiceabilitythat real checkout uses — SR-012 FR-01, FR-02. - If the shipment-serviceability lookup fails, the preview degrades to an empty shipment-estimate field rather than failing the whole product page — the product page’s content is still useful without a delivery estimate — SR-012 FR-03.
This is the architectural guarantee behind BRD-011’s BR-01: because the exact same resolution call backs both the preview and real checkout, the price and delivery estimate a customer sees while browsing can never structurally diverge from what checkout later confirms.
End-to-end flow (B) — Cart or Buy Now → checkout quote → session caching
- The customer either has items in their persisted cart, or chooses Buy Now on a single product. Both paths call the same
GetCheckoutDetailsentry point with one input DTO (ProductID,VariantID,Quantity) — an emptyVariantIDresolves the persisted cart’s lines; a non-emptyVariantIDbuilds a single synthetic line directly, without writing it into the cart first — SR-012 FR-04. shop-serviceresolves the customer’s saved addresses, then resolves each order line’s source (cart row vs. synthetic Buy-Now line).resolveCheckoutInfocallsinventory-service.GetCheckoutInfoonce for the full line set — the same consolidated call flow (A) uses — returning price, discount, stock, tax, warehouse, and weight for every line in one round trip. A cart line that no longer resolves is skipped with a warning; the identical miss on a Buy-Now line is a hard not-found error, since there’s no persisted cart row to fall back to — SR-012 FR-05.buildOrderItemsjoins the resolved pricing againstproduct-catalogfor display fields (name, image), reusing the same per-item effective-price/savings calculation the cart screen’s own listing already uses — SR-012 FR-06.shop-serviceresolves the delivery location and calls the sharedshipment.IShipmentService.GetServiceability— the same shared service flow (A) uses — to get shipment tier options (fee, ETA, courier). Unlike the product-detail preview, a lookup failure here hard-fails the request, since a price summary cannot be computed without a shipping fee — SR-012 FR-02, FR-03.shop-servicecallspayment-servicefor the tenant’s allowed payment methods, thenbuildPriceSummarycomputes the final subtotal/tax/shipping-fee/cash-on-delivery-surcharge/round-off/grand-total for the default (cheapest) shipment tier.- The full resolved aggregate — addresses by reference, order items, tax summary, warehouse, weight, shipment tier options, allowed payment methods, and the price summary — is inserted into
checkout_sessionunder a freshly minted token, scoped by(tenant_id, created_user_id)in addition to the token itself — SR-012 FR-07, NFR-04. - The token and the full checkout review are returned to the customer. The session expires automatically after 1 hour (
CheckoutSessionTTL) — SR-012 FR-10.
This is the architectural answer to BRD-011’s BR-02 and BR-04: cart checkout and Buy-Now checkout are the same code path from step 2 onward, and every downstream screen that needs price/stock/tax/shipment resolution reuses the same two calls (GetCheckoutInfo, GetServiceability) rather than each growing its own copy — see ADR-00024 for why this consolidation was chosen over per-screen enrichment.
End-to-end flow (C) — Re-quoting after a payment-method or courier change
- The customer changes their delivery option or payment method after reviewing checkout.
RecalculateCheckoutPricingis called with the session’s token plus the new selection. shop-servicefetches the cached session by token, then live re-resolves the customer’s addresses and live re-quotes shipment againstshipment-service— never from the cache — because both available tiers and their cash-on-delivery surcharge can differ by payment method — SR-012 FR-09.- Order items, tax summary, and warehouse information are read from the cached session rather than re-resolved, since none of those depend on payment method or courier.
buildPriceSummaryis reused (the same function from flow B, step 6) to recompute the price summary against the newly selected tier.- The session’s shipment-tier and price-summary fields are updated in place, by token — the one scoped exception to the collection’s otherwise insert-only nature. The session’s tenant/owner/creation fields are never touched by this update — SR-012 FR-08.
This is the architectural answer to BRD-011’s BR-06: a re-quote only re-does the two things that can actually change (addresses, shipment), reusing everything else already cached — cheap, and without restarting checkout from scratch.
End-to-end flow (D) — Order creation from the cached session
- The customer submits the order with the checkout-session token and a client-supplied idempotency key.
order-servicereadsshop-service’scheckout_sessioncollection directly via its own already-injected MongoDB connection — both services point at the same physical MongoDB server; this is a flagged, temporary exception to the normal cross-service-read-via-RPC rule, not a precedent for any other read — SR-012 NFR-05.- The resolved session is mapped exactly once into a single in-memory
CheckoutSessionSnapshot— SR-012 FR-11. order-serviceresolves the actual shipping/billing address content frompii-serviceusing the session’s stored address reference — never trusting address content from the request body, and never persisting raw address content into the cache itself — SR-012 FR-14. The address snapshot inpii-serviceis created before the order record is inserted, so a failed insert after a successful snapshot leaves only a harmless, already-deduplicated orphan rather than an order with no resolvable address — SR-012 NFR-07.- The persisted order’s price fields — subtotal, savings, tax, shipping fee, cash-on-delivery charge, round-off, grand total, currency — are copied verbatim from the snapshot’s price summary. Nothing is recalculated — SR-012 FR-12.
- The same snapshot also feeds the Temporal checkout-saga input (the fulfillment/payment workflow) and the payment amount — one mapped value, reused for every destination that needs it.
- The insert is protected by a unique, sparse index on the idempotency key. A duplicate-key error is handled by re-fetching and returning the already-created order, rather than failing the retried request — SR-012 FR-13, NFR-06.
This is the architectural answer to the user’s core question — why cache the checkout session and reuse it verbatim at order creation, instead of recomputing: see ADR-00025 for the full trade-off analysis. In short — recomputing at order time would mean re-implementing the same free-delivery-threshold, cash-on-delivery-surcharge, and rounding rules a second time in order-service, with a real risk of the two implementations silently drifting apart and charging the customer a different total than the one they reviewed. Reusing the cached snapshot verbatim makes that mismatch structurally impossible, at the accepted cost of a bounded 1-hour staleness window — tracked as TD-05.
Why this is scalable, reusable, and maintainable
- One resolution path, every caller.
GetCheckoutInfoandGetServiceabilityare each a single method with exactly one implementation, consumed identically by the product-detail preview, cart-based checkout, Buy-Now checkout, and re-quote. A future screen needing the same information (e.g. a wishlist page showing live pricing) reuses the existing call rather than writing a fourth independent implementation — the maintenance cost of pricing/shipment logic does not grow with the number of screens that need it (BRD-011 BR-04). - Cart and Buy Now are one code path, not two. From
GetCheckoutDetailsstep 2 onward, there is no branch between “checking out a cart” and “checking out one product” — only the line-resolution step at the very start differs. A change to pricing, tax, or shipment logic automatically applies to both without a second implementation to keep in sync (BRD-011 BR-02). - The cache turns a multi-service aggregation into a single read at the point it matters most. Order creation — the step on the critical path of every single purchase — resolves one cached document instead of re-querying
inventory-service,shipment-service, andpayment-serviceall over again. As order volume grows, this keeps the most frequently executed step cheap and fast rather than scaling its downstream call count with every order. - Business rules live in exactly one place. Free-delivery thresholds, cash-on-delivery surcharges, and rounding are computed once, in
shop-service’sbuildPriceSummary, and reused verbatim everywhere that total is needed — on the checkout screen, after a re-quote, and at order creation. There is no second implementation of these rules anywhere else in the journey to drift out of sync (BRD-011 BR-03).
Related Documents
- BRD-011 — Reusable Product-to-Order Journey With Trustworthy Totals
- SR-012 — Reusable Checkout Orchestration: System Requirements
- ADR-00024 — Shared Checkout-Info Resolution vs. Per-Screen Enrichment
- ADR-00025 — Cached Checkout-Session Snapshot vs. Recompute at Order Creation
- Architecture — Checkout Completion: Payment Capture and Fulfillment Handoff — detailed payment-capture flow once this journey’s order is placed
- Architecture — Multi-Courier Fulfillment via Shiprocket — detailed shipment/courier flow once this journey’s order is placed
- Technical Debt — Reusable Checkout Orchestration Gaps
- Microservices: shop-service, inventory-service, product-catalog, shipment-service, pii-service, order-service