ADR-001: Use PostgreSQL as the Catalog system of record
Catalog Database (PostgreSQL) is the single authoritative store for books, authors, categories, and publishers; cache and vector index are derived.
1. Context & Problem
Catalog information is deeply interconnected: BookEntityv1.0.0BookCanonical sellable title in the product catalog, encapsulating descriptive metadata, pricing, stock availability, taxono...Ownercatalog-experience-teamOpen docss link to AuthorEntityv1.0.0AuthorRepresents a credited author of one or more books in the product catalog, enforcing display-name validity and referentia...Ownercatalog-experience-teamOpen docss, CategoryEntityv1.0.0CategorySingle-level taxonomy classification grouping books by subject or genre within the product catalog.Ownercatalog-experience-teamOpen docss, and PublisherEntityv1.0.0PublisherRepresents a publishing house or imprint associated with books in the product catalog.Ownercatalog-experience-teamOpen docss, including many-to-many relationships between books and authors. These records must stay consistent whenever products are created, updated, filtered, sorted, or paged. Price and availability also require a single trusted value that downstream checkout validation can rely on.
At the same time, Catalog uses a read cache to speed up popular queries and a search index to match books by meaning and keywords. Both are derived helpers that can lag behind edits or become temporarily unavailable—neither should become a competing source of product truth. Because book cover images and customer reviews belong to separate capabilities, Catalog also needs an explicit boundary around what data it owns.
2. Business Value
- Single source of product truth: Pricing, availability, and product descriptions stay consistent across browsing, search, and purchase validation.
- Built-in data integrity: Automated relational rules prevent broken links, orphaned author associations, or inconsistent book metadata.
- Resilience without data loss: Outages in the read cache or search index may slow responses or delay search freshness, but never compromise core product records or block updates.
- No lost search updates: Pending search-index work is recorded alongside every product save, ensuring search catches up reliably even if background workers are temporarily offline.
- Clear domain boundaries: Keeps canonical product data separate from image files and individual customer reviews, reducing cross-team coupling.
3. How It Works
Catalog DatabaseContainerv1.0.0Catalog DatabaseAuthoritative PostgreSQL system of record owned by the Catalog bounded context for books, authors, categories, publisher...Ownercatalog-experience-teamDiagramOpen docs serves as the single authoritative store for Catalog-owned books, authors, categories, publishers, and their relationships.
- Controlled access: Catalog APIServicev1.0.0Catalog APIInternal HTTP and gRPC service for Catalog product management, hybrid discovery, and authoritative book metadata. PublishesBookUpdatedRatingFailedIntegrationEventSubscribesCreatePublisher, UpdatePublisher +24APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs validates and applies all product updates. Other domains consume Catalog’s published service interfaces rather than reading its database tables directly. Catalog IngestionServicev1.0.0Catalog IngestionInternal background worker that reads pending Catalog book updates and synchronizes semantic search vectors in Qdrant. SubscribesProcessVectorBatchIntegrationEventOwnercatalog-experience-teamDiagramRepositoryOpen docs reads catalog data and manages the search-indexing work queue, but never authors or alters canonical product records.
- Automatic relationship protection: Database rules keep relationships coherent—removing a category or publisher preserves affected books by clearing that link, deleting a book removes its author associations, and an author cannot be deleted while still linked to books.
- Guaranteed handoff to search: Whenever catalog data changes, a pending search-update marker is saved in the exact same step. This lets Catalog IngestionServicev1.0.0Catalog IngestionInternal background worker that reads pending Catalog book updates and synchronizes semantic search vectors in Qdrant. SubscribesProcessVectorBatchIntegrationEventOwnercatalog-experience-teamDiagramRepositoryOpen docs refresh Catalog VectorContainerv1.0.0Catalog VectorNon-authoritative Qdrant vector search index owned by the Catalog bounded context for hybrid semantic and keyword book d...Ownercatalog-experience-teamDiagramOpen docs in the background without making product saves wait on AI embeddings or search availability (see ADR-003: Maintain the vector index asynchronously through a database-backed queueDecision Recordv1.0.0ADR-003: Maintain the vector index asynchronously through a database-backed queueDatabase triggers enqueue changed books, and Catalog Ingestion drains the queue in batches to update Qdrant, decoupling ...Ownercatalog-experience-teamOpen docs).
- Derived helpers only: Catalog CacheContainerv1.0.0Catalog CacheNon-authoritative FusionCache and Redis caching layer owned by the Catalog bounded context for fast book detail lookups ...Ownercatalog-experience-teamDiagramOpen docs and Catalog VectorContainerv1.0.0Catalog VectorNon-authoritative Qdrant vector search index owned by the Catalog bounded context for hybrid semantic and keyword book d...Ownercatalog-experience-teamDiagramOpen docs are non-authoritative copies that can be rebuilt or repopulated from source data at any time. Search queries use the vector index only to identify candidate books, then load current details from the authoritative database—ensuring purchase-time price and availability checks never rely on cached or search-index copies.
- Scoped authority: Book cover images live in Catalog Blob StorageContainerv1.0.0Catalog Blob StorageAuthoritative Azure Blob Storage container owned by the Catalog bounded context for binary book cover images and media a...Ownercatalog-experience-teamDiagramOpen docs and are linked by reference. Individual customer reviews are owned by the Reviews domain; Catalog keeps only a summary rating updated via integration messages.
4. Trade-offs & Lessons Learned
Alternatives considered
- Use a document store or distributed cache as the primary store: Simplifies some read patterns, but makes cross-entity integrity harder to guarantee and blurs the line between canonical product truth and read optimizations.
- Treat the cache or search index as authoritative: Eliminates extra lookups, but introduces silent drift between what shoppers see and actual product rules due to expiration, indexing lag, and rebuilds.
- Split product data across multiple relational stores: Offers isolated scaling, but introduces duplicate metadata, inconsistent identities, and complex cross-store reconciliation.
Trade-offs & operational considerations
- Hard dependency for writes and search resolution: Availability of the primary database is essential for saving catalog edits and resolving search candidates into canonical book records.
- Shared database load: Because the database also holds the search-indexing work queue, background ingestion adds database activity that must be monitored alongside queue age and depth.
- Eventual search consistency: Saving a book via the API confirms database persistence, not that semantic search has already refreshed.
- Controlled operational changes: Direct manual edits to database rows should occur only for approved operational corrections under engineering change controls.
5. Technical Reference
- System of record: Catalog DatabaseContainerv1.0.0Catalog DatabaseAuthoritative PostgreSQL system of record owned by the Catalog bounded context for books, authors, categories, publisher...Ownercatalog-experience-teamDiagramOpen docs (PostgreSQL), accessed for writes by Catalog APIServicev1.0.0Catalog APIInternal HTTP and gRPC service for Catalog product management, hybrid discovery, and authoritative book metadata. PublishesBookUpdatedRatingFailedIntegrationEventSubscribesCreatePublisher, UpdatePublisher +24APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs and read for indexing by Catalog IngestionServicev1.0.0Catalog IngestionInternal background worker that reads pending Catalog book updates and synchronizes semantic search vectors in Qdrant. SubscribesProcessVectorBatchIntegrationEventOwnercatalog-experience-teamDiagramRepositoryOpen docs.
- Identifiers & timestamps: PostgreSQL-generated
uuidv7()identifiers and database-generated creation/modification timestamps. - Referential integrity rules:
- Category or publisher deletion clears the foreign-key reference on books (
SET NULLbehavior) so books are preserved. - Book deletion cascades to
book_authorlinks. - Author deletion is restricted while
book_authorlinks remain.
- Category or publisher deletion clears the foreign-key reference on books (
- Transactional vector queue: Database triggers atomically write to
pending_vector_updates(coalesced by book ID and revision) within the same PostgreSQL transaction as the catalog mutation. - External storage & projection boundaries:
- Book images are stored in Catalog Blob StorageContainerv1.0.0Catalog Blob StorageAuthoritative Azure Blob Storage container owned by the Catalog bounded context for binary book cover images and media a...Ownercatalog-experience-teamDiagramOpen docs and referenced from the book record by URN.
- Individual feedback records belong to Reviews; Catalog stores only a denormalized rating summary updated from Reviews integration messages.
- Cache & search rules:
- Catalog CacheContainerv1.0.0Catalog CacheNon-authoritative FusionCache and Redis caching layer owned by the Catalog bounded context for fast book detail lookups ...Ownercatalog-experience-teamDiagramOpen docs entries are invalidated on book changes and expire per configured lifetime; cache loss impacts performance only.
- Text search queries Catalog VectorContainerv1.0.0Catalog VectorNon-authoritative Qdrant vector search index owned by the Catalog bounded context for hybrid semantic and keyword book d...Ownercatalog-experience-teamDiagramOpen docs for candidate book IDs, then reads canonical records from PostgreSQL; price and availability for purchase validation must never come from cache or Qdrant.
- Schema governance:
- Schema changes require an EF Core migration and an update to the documented current-state schema reference.