Order Database
Authoritative PostgreSQL system of record owned by the Ordering bounded context for buyers, accepted orders, purchase-time line items, and order lifecycle event streams.
Purpose & Ownership Boundary
Order Database (orderingdb) is the authoritative PostgreSQL system of record owned exclusively 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 in the Ordering bounded context. PostgreSQL was chosen to combine ACID relational persistence for buyer profiles and immutable checkout snapshots with append-only order lifecycle event streams, read projections, and a transactional outbox over a single connection.
Data Store Profile
| Property | Value |
|---|---|
| Bounded Context / Owner | Ordering — Commerce Fulfillment TeamTeamCommerce Fulfillment TeamStream-Aligned team owning customer shopping baskets, checkout coordination, order lifecycle, and financial saga orchest...Open docs |
| Engine / Technology | PostgreSQL 18 (Azure Database for PostgreSQL Flexible Server) |
| Store Type | Database |
| Primary Writer(s) | 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 |
| Primary Reader(s) | 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 |
| Authoritative / Source of Truth | Yes |
| Data Classification | Confidential (contains customer names and shipping addresses) |
| Retention / TTL Policy | Indefinite (soft-delete on orders; subject to environment data-governance policy) |
Logical Data Layout & Key Patterns
| Table / Schema | Owned Entity | Partition / Primary Key | Purpose & Concurrency |
|---|---|---|---|
buyers | BuyerEntityv1.0.0BuyerRepresents a customer's ordering profile and delivery address within the Ordering bounded context.Ownercommerce-fulfillment-teamOpen docs | id (uuidv7()) | Customer profiles including name and shipping address (street, city, province). |
orders | OrderEntityv1.0.0OrderDurable purchase record owned by a Buyer, capturing immutable purchase-time line items and governing order lifecycle tra...Ownercommerce-fulfillment-teamOpen docs | id (uuidv7()) | Accepted orders with status (New, Cancelled, Completed), order note, timestamps, and soft-delete flag; optimistic concurrency via row-version token. |
order_items | 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 | id (uuidv7()), unique (book_id, order_id) | Immutable checkout-time line item snapshots locking book_id, quantity, and unit price at purchase time. |
Event store (public) | OrderEntityv1.0.0OrderDurable purchase record owned by a Buyer, capturing immutable purchase-time line items and governing order lifecycle tra...Ownercommerce-fulfillment-teamOpen docs | Stream ID (order_id) | Append-only order placement, completion, and cancellation events; live stream aggregation and asynchronous summary projection (DaemonLockId = 44444). |
wolverine schema | — | Envelope ID | Transactional outbox and inbox tables sharing the domain write transaction; partitions Kafka events (User checked outEventv1.0.0User checked outReports that an Order was placed and its checkout details are ready for
Finance coordination.
Ownercommerce-fulfillment-teamSchemaDiagramOpen docs, Order completedEventv1.0.0Order completedReports that an Order transitioned from New to Completed.
Ownercommerce-fulfillment-teamSchemaDiagramOpen docs, Order cancelledEventv1.0.0Order cancelledReports that an Order transitioned from New to Cancelled.
Ownercommerce-fulfillment-teamSchemaDiagramOpen docs) by OrderId. |
Consistency, Isolation & Security Guardrails
- Checkout price immutability:
order_itemspersists the unit price resolved at checkout so subsequent price edits in Catalog DatabaseContainerv1.0.0Catalog DatabaseAuthoritative PostgreSQL system of record owned by the Catalog bounded context for books, authors, categories, publisher...Ownercatalog-experience-teamDiagramOpen docs never alter historical purchases. - Soft-delete audit preservation: Administrative cleanup and failed basket-cleanup compensation mark orders as soft-deleted (filtered from normal reads) rather than physically erasing rows.
- Eventually consistent summary views: Asynchronous order summary projections can briefly lag transactional writes;
ordersremains the canonical source for order status. - Confidential PII posture: Buyer names and street/city/province addresses are classified
confidentialand protected by encryption at rest, regional residency, and backup retention policies.
Database-per-Service Isolation: Only 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 may read or write orderingdb. Active pre-checkout baskets live in Basket DatabaseContainerv1.0.0Basket DatabaseAuthoritative Redis key-value store owned by the Shopping bounded context for customer-scoped pre-checkout shopping bask...Ownercommerce-fulfillment-teamDiagramOpen docs, temporary locks and HTTP idempotency markers live in 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, and post-checkout saga state lives in 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. External services must never query orderingdb directly.
Operational & Resilience Notes
- Local vs. Cloud: Local development runs a persistent PostgreSQL container alongside
catalogdbandschedulerdb; cloud environments run Azure Database for PostgreSQL Flexible Server. - Scaling & HA: Development usesStandard_B1ms(single zone, 7-day backup, 32 GB); Staging usesStandard_D2ds_v5(zone-redundant HA, PgBouncer, 14-day backup, 128 GB); Production usesStandard_D4ds_v5(zone-redundant HA, PgBouncer, 35-day backup, 256 GB). - Active messaging schema: Treat thewolverineschema as the sole authoritative messaging store; ignore any retired messaging tables from historical migrations.
Architecture Visualizations
Loading graph...
Related Documentation
- 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 — Owning service endpoints, gRPC clients, and Kafka handlers.
- 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 locks, atomic HTTP idempotency, and cached responses.
- 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 — Saga coordinating post-checkout cleanup and notifications.
- ADR-001: Use PostgreSQL as the Order system of recordDecision Recordv1.0.0ADR-001: Use PostgreSQL as the Order system of recordPostgreSQL is the authoritative store for Buyer profiles and accepted Orders; Redis and read projections do not own this...Ownercommerce-fulfillment-teamOpen docs — Decision establishing PostgreSQL as Ordering’s system of record.
- ADR-002: Preserve the checkout-time purchase snapshotDecision Recordv1.0.0ADR-002: Preserve the checkout-time purchase snapshotEach accepted Order records the book identifiers, quantities, and prices selected at checkout so later Catalog changes d...Ownercommerce-fulfillment-teamOpen docs — Decision locking checkout-time prices in
order_items. - Backup, Restore & Disaster Recovery (DR)Custom DocBackup, Restore & Disaster Recovery (DR)Operator runbook for PostgreSQL point-in-time restore, Cosmos DB failover verification, Blob Storage recovery, and Qdran...Ownerplatform-engineering-teamOpen doc — Platform backup, restore, and disaster recovery runbook.