Catalog Database
Authoritative PostgreSQL system of record owned by the Catalog bounded context for books, authors, categories, publishers, and vector-indexing coordination.
Purpose & Ownership Boundary
Catalog Database (catalogdb) is the authoritative relational system of record for the Catalog bounded context, owned 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. PostgreSQL was chosen for strict relational integrity across product taxonomy, transactional outbox messaging, and trigger-driven change capture for asynchronous search 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.
Data Store Profile
| Property | Value |
|---|---|
| Bounded Context / Owner | Catalog — Catalog Experience TeamTeamCatalog Experience TeamStream-Aligned team owning BookWorm's product catalog, customer reviews, and storefront/backoffice discovery experience....Open docs |
| Engine / Technology | PostgreSQL 18 (Azure Database for PostgreSQL Flexible Server) |
| Store Type | Database |
| Primary Writer(s) | 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 (domain writes), Catalog IngestionServicev1.0.0Catalog IngestionInternal background worker that reads pending Catalog book updates and synchronizes semantic search vectors in Qdrant. SubscribesProcessVectorBatchIntegrationEventOwnercatalog-experience-teamDiagramRepositoryOpen docs (queue acknowledgment only) |
| Primary Reader(s) | 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, Catalog IngestionServicev1.0.0Catalog IngestionInternal background worker that reads pending Catalog book updates and synchronizes semantic search vectors in Qdrant. SubscribesProcessVectorBatchIntegrationEventOwnercatalog-experience-teamDiagramRepositoryOpen docs |
| Authoritative / Source of Truth | Yes |
| Data Classification | Internal |
| Retention / TTL Policy | Indefinite (soft-delete flag on books; transactional outbox pruned after dispatch) |
Logical Data Layout & Key Patterns
All identifiers use snake_case, primary keys default to time-ordered uuidv7(), and audit timestamps (created_at, last_modified_at) are database-generated.
| Table / Schema | Owned Entity | Partition / Primary Key | Purpose & Concurrency |
|---|---|---|---|
books | BookEntityv1.0.0BookCanonical sellable title in the product catalog, encapsulating descriptive metadata, pricing, stock availability, taxono...Ownercatalog-experience-teamOpen docs | id (uuidv7()) | Canonical book catalog, pricing, availability status, soft-delete flag (is_deleted), blob URN (image), and derived rating projection (average_rating, total_reviews); optimistic concurrency via row_version. |
authors | AuthorEntityv1.0.0AuthorRepresents a credited author of one or more books in the product catalog, enforcing display-name validity and referentia...Ownercatalog-experience-teamOpen docs | id (uuidv7()) | Author directory; deletion restricted while referenced in book_authors. |
categories | CategoryEntityv1.0.0CategorySingle-level taxonomy classification grouping books by subject or genre within the product catalog.Ownercatalog-experience-teamOpen docs | id (uuidv7()) | Product category taxonomy with unique name; deleting a category sets books.category_id to NULL. |
publishers | PublisherEntityv1.0.0PublisherRepresents a publishing house or imprint associated with books in the product catalog.Ownercatalog-experience-teamOpen docs | id (uuidv7()) | Publisher directory with unique name; deleting a publisher sets books.publisher_id to NULL. |
book_authors | BookEntityv1.0.0BookCanonical sellable title in the product catalog, encapsulating descriptive metadata, pricing, stock availability, taxono...Ownercatalog-experience-teamOpen docs, AuthorEntityv1.0.0AuthorRepresents a credited author of one or more books in the product catalog, enforcing display-name validity and referentia...Ownercatalog-experience-teamOpen docs | (book_id, author_id) | Many-to-many join table; deleting a book cascades to its author links. |
pending_vector_updates | — | book_id (uuid) | Coalescing change-capture queue with revision UUID and updated_at; repeated edits update the row in place. |
wolverine schema | — | Envelope ID | Transactional outbox and inbox tables sharing the domain write transaction; partitions Kafka events by BookId and FeedbackId. |
Consistency, Isolation & Security Guardrails
- Transactional outbox: Domain writes and outbound integration events commit in a single PostgreSQL transaction via the
wolverineoutbox schema. - Trigger-driven search sync: Five database triggers (
books,book_authors,authors,categories,publishers) enqueue affectedbook_idrows intopending_vector_updates. Catalog IngestionServicev1.0.0Catalog IngestionInternal background worker that reads pending Catalog book updates and synchronizes semantic search vectors in Qdrant. SubscribesProcessVectorBatchIntegrationEventOwnercatalog-experience-teamDiagramRepositoryOpen docs acquires PostgreSQL advisory lock740031001, processes up to200rows per batch, and deletes only rows whosebook_idandrevisionstill match. - Soft-delete & URN invariants: Books use
is_deletedsoft deletion rather than physical row removal. Thebooks.imagecolumn stores permanent blob URNs pointing to 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, never raw bytes or expiring SAS URLs. - Derived rating projections:
average_ratingandtotal_reviewsonbooksare eventually consistent projections updated from Feedback createdEventv1.0.0Feedback createdIndicates that a customer feedback rating was created for a book. Rating API publishes this event so Catalog can update ...Ownercatalog-experience-teamSchemaDiagramOpen docs and Feedback deletedEventv1.0.0Feedback deletedIndicates that a customer feedback rating was deleted for a book. Rating API publishes this event so Catalog can remove ...Ownercatalog-experience-teamSchemaDiagramOpen 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 remains authoritative for individual reviews.
Database-per-Service Isolation: Only 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 may mutate catalog domain tables, and Catalog IngestionServicev1.0.0Catalog IngestionInternal background worker that reads pending Catalog book updates and
synchronizes semantic search vectors in Qdrant.
SubscribesProcessVectorBatchIntegrationEventOwnercatalog-experience-teamDiagramRepositoryOpen docs is restricted to reading catalog state and acknowledging pending_vector_updates. External services (such as Basket APIServicev1.0.0Basket APIInternal HTTP and gRPC service for managing customer-scoped shopping baskets,
Catalog price enrichment, and post-checkou...PublishesGetBookGrpc, GetBooksGrpc +2SubscribesCreateBasket, UpdateBasket +4APIsOpenAPI, AsyncAPIOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs, 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, or Rating APIServicev1.0.0Rating APIInternal HTTP and A2A gRPC service for collecting, listing, deleting, and
summarizing customer feedback for Catalog book...PublishesFeedbackCreatedIntegrationEvent, FeedbackDeletedIntegrationEventSubscribesCreateFeedback, DeleteFeedback +3APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs) must never connect to catalogdb directly—all cross-context reads flow through 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 HTTP/gRPC contracts or Kafka events.
Operational & Resilience Notes
- Local vs. Cloud: Local development runs a single persistent PostgreSQL container with
automatic dev seeding; cloud environments run Azure Database for PostgreSQL Flexible Server on
the shared
postgresinstance alongsideorderingdbandschedulerdb. - 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). - Upgrades & monitoring: Apply schema changes exclusively through versioned migrations (never by replaying static SQL snapshots), and monitorpending_vector_updatesrow count and oldestupdated_atto detect ingestion lag.
Architecture Visualizations & Schema
Loading graph...
CREATE TABLE authors ( id uuid NOT NULL DEFAULT uuidv7(), name character varying(100) NOT NULL, CONSTRAINT pk_authors PRIMARY KEY (id));
CREATE TABLE categories ( id uuid NOT NULL DEFAULT uuidv7(), name character varying(50) NOT NULL, CONSTRAINT pk_categories PRIMARY KEY (id));
CREATE TABLE publishers ( id uuid NOT NULL DEFAULT uuidv7(), name character varying(100) NOT NULL, CONSTRAINT pk_publishers PRIMARY KEY (id));
CREATE TABLE books ( id uuid NOT NULL DEFAULT uuidv7(), name character varying(50) NOT NULL, description character varying(1000) NOT NULL, image character varying(255), price_original_price numeric(18, 2), price_discount_price numeric(18, 2), status smallint NOT NULL, average_rating double precision NOT NULL DEFAULT 0.0, total_reviews integer NOT NULL, category_id uuid, publisher_id uuid, is_deleted boolean NOT NULL, created_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, last_modified_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP, CONSTRAINT pk_books PRIMARY KEY (id), CONSTRAINT fk_books_categories_category_id FOREIGN KEY (category_id) REFERENCES categories (id) ON DELETE SET NULL, CONSTRAINT fk_books_publishers_publisher_id FOREIGN KEY (publisher_id) REFERENCES publishers (id) ON DELETE SET NULL);
CREATE TABLE book_authors ( id uuid NOT NULL DEFAULT uuidv7(), author_id uuid NOT NULL, book_id uuid NOT NULL, CONSTRAINT pk_book_authors PRIMARY KEY (id), CONSTRAINT fk_book_authors_authors_author_id FOREIGN KEY (author_id) REFERENCES authors (id) ON DELETE RESTRICT, CONSTRAINT fk_book_authors_books_book_id FOREIGN KEY (book_id) REFERENCES books (id) ON DELETE CASCADE);
CREATE INDEX ix_book_authors_author_id ON book_authors (author_id);CREATE INDEX ix_book_authors_book_id ON book_authors (book_id);CREATE INDEX ix_books_category_id ON books (category_id);CREATE INDEX ix_books_publisher_id ON books (publisher_id);CREATE UNIQUE INDEX ix_categories_name ON categories (name);CREATE UNIQUE INDEX ix_publishers_name ON publishers (name);
-- Books waiting for asynchronous vector indexing.CREATE TABLE pending_vector_updates ( book_id uuid PRIMARY KEY, revision uuid NOT NULL DEFAULT gen_random_uuid(), updated_at timestamp with time zone NOT NULL DEFAULT clock_timestamp());
CREATE INDEX ix_pending_vector_updates_updated_at ON pending_vector_updates (updated_at);
CREATE FUNCTION enqueue_vector_update(target_book_id uuid) RETURNS voidLANGUAGE sqlAS $$ INSERT INTO pending_vector_updates (book_id) VALUES (target_book_id) ON CONFLICT (book_id) DO UPDATE SET revision = gen_random_uuid(), updated_at = clock_timestamp();$$;
CREATE FUNCTION enqueue_book_vector_update() RETURNS triggerLANGUAGE plpgsqlAS $$BEGIN IF TG_OP = 'DELETE' THEN PERFORM enqueue_vector_update(OLD.id); RETURN OLD; END IF;
PERFORM enqueue_vector_update(NEW.id); RETURN NEW;END;$$;
CREATE TRIGGER books_vector_updateAFTER INSERT OR UPDATE OR DELETE ON booksFOR EACH ROWEXECUTE FUNCTION enqueue_book_vector_update();
CREATE FUNCTION enqueue_book_author_vector_update() RETURNS triggerLANGUAGE plpgsqlAS $$BEGIN IF TG_OP <> 'INSERT' THEN PERFORM enqueue_vector_update(OLD.book_id); END IF;
IF TG_OP <> 'DELETE' THEN PERFORM enqueue_vector_update(NEW.book_id); RETURN NEW; END IF;
RETURN OLD;END;$$;
CREATE TRIGGER book_authors_vector_updateAFTER INSERT OR UPDATE OR DELETE ON book_authorsFOR EACH ROWEXECUTE FUNCTION enqueue_book_author_vector_update();
CREATE FUNCTION enqueue_related_book_vector_updates() RETURNS triggerLANGUAGE plpgsqlAS $$BEGIN IF TG_TABLE_NAME = 'authors' THEN PERFORM enqueue_vector_update(book_id) FROM book_authors WHERE author_id = OLD.id; ELSIF TG_TABLE_NAME = 'categories' THEN PERFORM enqueue_vector_update(id) FROM books WHERE category_id = OLD.id; ELSIF TG_TABLE_NAME = 'publishers' THEN PERFORM enqueue_vector_update(id) FROM books WHERE publisher_id = OLD.id; END IF;
IF TG_OP = 'DELETE' THEN RETURN OLD; END IF;
RETURN NEW;END;$$;
CREATE TRIGGER authors_vector_updateBEFORE UPDATE OR DELETE ON authorsFOR EACH ROWEXECUTE FUNCTION enqueue_related_book_vector_updates();
CREATE TRIGGER categories_vector_updateBEFORE UPDATE OR DELETE ON categoriesFOR EACH ROWEXECUTE FUNCTION enqueue_related_book_vector_updates();
CREATE TRIGGER publishers_vector_updateBEFORE UPDATE OR DELETE ON publishersFOR EACH ROWEXECUTE FUNCTION enqueue_related_book_vector_updates();
-- Existing books must be indexed by the first vector-ingestion batches.INSERT INTO pending_vector_updates (book_id)SELECT idFROM books;Related Documentation
- 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 — Owning service endpoints, gRPC contracts, and transactional outbox.
- Catalog IngestionServicev1.0.0Catalog IngestionInternal background worker that reads pending Catalog book updates and
synchronizes semantic search vectors in Qdrant.
SubscribesProcessVectorBatchIntegrationEventOwnercatalog-experience-teamDiagramRepositoryOpen docs — Worker draining
pending_vector_updatesinto 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. - 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 — Derived Qdrant hybrid search index fed from this database.
- 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 — Binary cover media store referenced by
books.imageURNs. - 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 — Decision establishing PostgreSQL as Catalog’s system of record.
- 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 — Decision for trigger-based vector update coalescing.
- 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.