ADR-BW-006: Keep business state and persistence access capability-owned
Preserve one accountable owner for each business model and integrate through contracts rather than shared mutable tables.
| Field | Value |
|---|---|
| Status | Proposed |
| Date | 2026-11-07 |
| Owners | Architecture Enabling TeamTeamArchitecture Enabling TeamEnabling team facilitating BookWorm's architecture governance, ADRs, arc42 documentation, engineering standards, testing...Open docs |
| Affected Resources | BookWormDomainv1.0.0BookWormCore e-commerce domain for the BookWorm online bookstore, coordinating catalog discovery, customer baskets, order fulfil...Ownerarchitecture-enabling-teamDiagramRepositoryOpen docs |
| Related ADRs | ADR-BW-001: Decompose BookWorm by business capabilityDecision Recordv1.0.0ADR-BW-001: Decompose BookWorm by business capabilityAlign independently deployable building blocks with bounded contexts rather than a shared business layer.Ownerarchitecture-enabling-teamOpen docs, ADR-BW-007: Distinguish authoritative state from derived viewsDecision Recordv1.0.0ADR-BW-007: Distinguish authoritative state from derived viewsTreat search and rating projections as derived information with explicit consistency limits rather than alternative sour...Ownerarchitecture-enabling-teamOpen docs, ADR-001: Use PostgreSQL as the Catalog system of recordDecision Recordv1.0.0ADR-001: Use PostgreSQL as the Catalog system of recordCatalog Database (PostgreSQL) is the single authoritative store for books, authors, categories, and publishers; cache an...Ownercatalog-experience-teamOpen docs, ADR-001: Use Redis as the authoritative basket storeDecision Recordv1.0.0ADR-001: Use Redis as the authoritative basket storeRedis is the authoritative store for active customer baskets, while accepted orders and Catalog data remain owned by the...Ownercommerce-fulfillment-teamOpen docs, 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, ADR-001: Use PostgreSQL as the feedback system of recordDecision Recordv1.0.0ADR-001: Use PostgreSQL as the feedback system of recordRating Database (PostgreSQL) is the authoritative store for individual customer feedback; no other domain may read or wr...Ownercatalog-experience-teamOpen docs |
Context & Problem Statement
Books, baskets, orders, reviews, chat sessions, and scheduled jobs have distinct consistency, retention, and scaling requirements. Allowing multiple services to read or mutate the same database tables bypasses domain invariants and prevents independent schema evolution.
Decision Drivers
- Invariant enforcement: Route every state mutation through a single authoritative service.
- Storage autonomy: Let each capability choose the datastore best suited to its workload.
- Schema freedom: Evolve internal tables and document schemas without breaking other services.
Options Considered
| Option | Pros | Cons |
|---|---|---|
| Capability-owned state and persistence access | Single authority for invariants; polyglot storage (PostgreSQL, Redis, Cosmos DB) | Cross-domain queries require API composition or projections |
| Shared relational database across services | Simple cross-domain SQL joins | Tight coupling; schema changes risk breaking unrelated services |
| Centralized data-access service | Single access gatekeeper | Creates a central bottleneck that must understand all domain rules |
| Physically isolated servers for every tiny store | Maximum hardware isolation | Unnecessary infrastructure cost for lightweight caches/queues |
Decision & Consequences
Chosen Option: Keep all business state and persistence access strictly owned by the responsible capability. Each service selects its optimal datastore (e.g., Catalog DatabaseContainerv1.0.0Catalog DatabaseAuthoritative PostgreSQL system of record owned by the Catalog bounded context for books, authors, categories, publisher...Ownercatalog-experience-teamDiagramOpen docs, 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, 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, Rating DatabaseContainerv1.0.0Rating DatabaseAuthoritative Azure Cosmos DB system of record owned by the Reviews bounded context for customer feedback documents part...Ownercatalog-experience-teamDiagramOpen docs) and exposes data solely via public contracts.
- Positive: Domain invariants cannot be bypassed; internal schema refactors do not impact consumers.
- Negative: Cross-domain reporting or enrichment requires explicit API calls or derived projections.
Compliance Criteria
- Only the owning service may hold read/write credentials or schemas for its authoritative datastore.
- Cross-service data access must use published HTTP, gRPC, or event contracts—never cross-schema SQL queries.
- Shared infrastructure hosts (such as Redis) must isolate keys by service-owned prefixes.