Storefront has been decoupled into micro-frontends with a dedicated commerce app and shared shell.

Read the architecture guide →

Order consistency and data ownership

Authoritative stores, checkout price snapshotting, Redis coordination, and Ordering vs. Finance boundaries.

Architecture

Purpose & Scope

This document defines data ownership, transactional outbox guarantees, checkout snapshotting, and Redis coordination rules for 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 and Order OrchestrationServicev1.0.0Order OrchestrationMessage-driven Finance workflow service that coordinates post-checkout basket cleanup and order notifications using Dura...PublishesPlaceOrderCommand, DeleteBasketCompleteCommand +3SubscribesUserCheckedOutIntegrationEvent, OrderStatusChangedToCompleteIntegrationEvent +3APIsAsyncAPIOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs in the OrderingDomainv1.0.0OrderingCreates durable Orders from a buyer's current basket, locks purchase-time pricing, and owns order lifecycle transitions ...Ownercommerce-fulfillment-teamDiagramOpen docs subdomain. Use it when modifying order creation, Marten projections, Redis locks/idempotency, or cross-service checkout orchestration.

Visual Reference

The visual below illustrates how 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 and Order OrchestrationServicev1.0.0Order OrchestrationMessage-driven Finance workflow service that coordinates post-checkout basket cleanup and order notifications using Dura...PublishesPlaceOrderCommand, DeleteBasketCompleteCommand +3SubscribesUserCheckedOutIntegrationEvent, OrderStatusChangedToCompleteIntegrationEvent +3APIsAsyncAPIOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs isolate backing stores while coordinating via gRPC queries and Kafka messages.

Loading graph...

Ordering and Finance Data Ownership and Messaging Boundaries

Core Invariants & Design Rules

Warning

Never flush Redis broadly during incidents. Order Cache and Distributed LocksContainerv1.0.0Order Cache and Distributed LocksRedis-backed coordination and caching slice owned by the Ordering bounded context for buyer-scoped creation locks, HTTP ...Ownercommerce-fulfillment-teamDiagramOpen docs holds active HTTP idempotency markers ({METHOD}:{PATH}:{x-request-id}, 3600s TTL) and buyer creation locks (order-create:{userId}, 60s TTL) alongside FusionCache read entries. Broadly flushing Redis exposes concurrent checkouts to duplicate order creation.

Boundaries & Guarantees

ConcernStrategy & GuaranteeFailure / Edge-Case BehaviorRelated Resources
Persistenceorder-database commits Order aggregates, Marten event streams, and Wolverine outbox messages in a single ACID transaction; order-orchestration persists saga state in finance-taskhub (no PostgreSQL).Uncommitted writes never publish Kafka events; Marten async projections recover automatically from the authoritative event stream.order-database, order, order-item, adr-001-postgresql-order-system-of-record, adr-001-finance-persisted-order-saga
Cachingorder-cache provides FusionCache L1/L2 (2h fail-safe) for Catalog lookups and dashboard reads.Safe to invalidate individual cache keys without losing order or buyer state.order-cache, adr-002-preserve-checkout-purchase-snapshot
Messagingorder-api emits UserCheckedOutIntegrationEvent, OrderStatusChangedToCompleteIntegrationEvent, and OrderStatusChangedToCancelIntegrationEvent partitioned by OrderId; consumes DeleteBasketCompleteCommand and DeleteBasketFailedCommand.Exhausted retries route to <code>bookworm.{env}.ordering.dead-letter-queue</code>; notification-api delivery never proves authoritative order status.<code>bookworm.{env}.ordering.user-checked-out</code>, <code>bookworm.{env}.finance.delete-basket-complete</code>, <code>bookworm.{env}.finance.delete-basket-failed</code>, <code>bookworm.{env}.ordering.dead-letter-queue</code>
Concurrency & IdempotencyPOST/PATCH endpoints require x-request-id ({METHOD}:{PATH}:{x-request-id}, 3600s TTL, returns 409 Conflict on duplicate, cleared on exception or >= 500); order-create:{userId} (60s TTL) serializes buyer writes after gRPC lookups; inbound Kafka handlers use a 24h Redis idempotency guard.Concurrent checkout attempts for the same buyer fail fast with conflict/lock error; duplicate x-request-id does not replay a cached response body.CreateOrder, user-checkout, adr-003-separate-order-status-from-finance-saga, adr-005-finance-separate-workflow-and-order-status

Safe Change & Verification Checklist

  • Keep Order ItemEntityv1.0.0Order ItemChild entity within an Order capturing a purchased book identifier, positive quantity, and locked checkout-time unit pri...Ownercommerce-fulfillment-teamOpen docs purchase prices (PriceSale ?? Price) immutable after checkout; allow read-time Catalog enrichment for display titles only.
  • Preserve x-request-id idempotency, order-create:{userId} buyer write locking, and 24h integration-event idempotency guards.
  • Keep Order.Status transitions (New → Completed | Cancelled), soft deletion (IsDeleted), and finance-taskhub orchestration states strictly decoupled.
  • Verify Pact contracts (Ordering-Finance, Finance-Ordering) and run mise run format, mise run build, and mise run test.