ADR-001: Use PostgreSQL as the Order system of record
PostgreSQL is the authoritative store for Buyer profiles and accepted Orders; Redis and read projections do not own this business data.
1. Context & Problem
The Ordering system manages two very different kinds of information: permanent business records (customer profiles, accepted orders, purchased line items, and order history) and short-lived operational data (temporary locks to stop duplicate checkouts, repeat-request markers, and cached responses for faster reading). It also produces read-optimized summaries that can be rebuilt or lag slightly behind live updates.
Without an explicit boundary between permanent records and temporary or derived data, teams risk treating a fast cache or a delayed summary view as the official truth. If temporary storage is cleared or a summary view is still catching up, customer orders or their true status could appear lost or inconsistent.
2. Business Value
- Financial and audit reliability: Accepted customer purchases and buyer profiles live in durable storage, ensuring business records survive temporary cache restarts or operational resets.
- Single source of truth: Customer service, downstream workflows, and reporting always have one authoritative place to verify an order’s real status.
- Clear service ownership: Ordering maintains its own dedicated data boundary, preventing schema changes or outages in other domains from corrupting order records.
- Predictable operations: Operations teams know exactly which store requires strict backup, availability, and recovery guarantees versus which store is safe to flush or rebuild.
3. How It Works
BookWorm designates 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 as the single authoritative system of record for buyer profiles, accepted orders, purchase-time item snapshots, order lifecycle history, and reliable outbound messaging records. Whenever the business needs to confirm an order’s true status or retrieve a customer’s purchase record, the authoritative order record—not a derived summary—is the final authority.
Meanwhile, 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 serves strictly as non-authoritative support infrastructure. It holds temporary buyer-level locks during order creation, short-lived markers to spot duplicate requests, and cached responses to speed up reads. Losing or clearing the cache never deletes a persisted order or buyer profile.
Read-optimized summaries are likewise treated as secondary views derived from the permanent records. Because they may update slightly after an order changes or be rebuilt from scratch, they are never allowed to override the authoritative order state.
4. Trade-offs & Lessons Learned
Alternatives Considered
- Treat the cache as the Order system of record: Rejected because placing accepted purchase data in transient coordination storage ties order durability to cache memory and availability.
- Use read projections as the authoritative status source: Rejected because derived summaries update asynchronously and could briefly report outdated status during high load or rebuilds.
- Share another system’s database: Rejected because coupling Ordering persistence to another domain’s storage blurs data ownership and complicates independent releases.
Operational Trade-offs & Risks
- Database availability dependency: Ordering cannot create or read authoritative buyer and order data if the primary relational database is unavailable or its schema is incompatible.
- Cache is still operationally important: Even though 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 does not own order data, an outage there disrupts concurrency locks and repeat-request detection.
- Non-atomic duplicate detection: Repeat-request markers are temporary safeguards rather than an exact-once guarantee—a marker can outlive a failed attempt, and a cache loss removes duplicate detection for that expiration window.
- Projection freshness discipline: Consumers and dashboards must remember that derived read summaries can lag behind the authoritative order record.
5. Technical Reference
- Authoritative store: 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 (PostgreSQL) owned by Ordering.
- EF Core: Persists Buyer profiles, accepted Orders, purchase-time Order Items, and the authoritative
Orderaggregate for current business status. - Marten: Stores Order event streams and maintains derived read projections; projection freshness and rebuild behavior must not be confused with the status or purchase snapshot stored by the EF Core
Orderaggregate. - Wolverine: Persists durable message envelopes against the Ordering database.
- EF Core: Persists Buyer profiles, accepted Orders, purchase-time Order Items, and the authoritative
- Non-authoritative coordination & cache: 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 (Redis).
- Supports Buyer-scoped Order creation locks, idempotency markers (subject to configured expiration), and cached responses.
- Redis loss can remove duplicate-request detection during the configured expiration period and affect lock acquisition, and an idempotency marker may outlive a failed request, but Redis loss does not remove persisted Orders or Buyer profiles.