Catalog Database (v1.0.0)

Primary database for product catalog information.

Overview

The Catalog Database is the authoritative source for all product catalog information in the BookWorm system. Built on PostgreSQL 18, it manages the complete lifecycle of book products, including their metadata, categorization, authorship, and publisher information. This database serves as the backbone of the product catalog service, enabling efficient product discovery, management, and synchronization across the BookWorm platform.

Schema Design

The database follows Domain-Driven Design (DDD) principles with the following aggregate roots:

Book Aggregate

The central entity representing books in the catalog system. Each book contains:

  • Core Information: Name, description, and image
  • Pricing: Base price and optional sale price (managed as a value object)
  • Status: Current availability status (InStock, OutOfStock, etc.)
  • Rating Metrics: Average rating and total reviews count
  • Relationships: Links to Category, Publisher, and multiple Authors through BookAuthor junction table

Category Aggregate

Organizes books into logical groupings:

  • Name: Unique category identifier (e.g., Fiction, Non-Fiction, Science, History)
  • Used for product organization and filtering

Author Aggregate

Represents book authors in the system:

  • Name: Author’s full name
  • Books: Many-to-many relationship with books through BookAuthor junction table
  • Supports co-authored books

Publisher Aggregate

Manages publisher information:

  • Name: Publisher company name
  • Books: One-to-many relationship with books

BookAuthor (Junction Entity)

Enables many-to-many relationships between books and authors, supporting co-authored publications. Includes soft delete capability for maintaining historical data integrity.

Key Features

Soft Delete Support

Books and BookAuthor entities implement soft delete patterns, ensuring:

  • Historical data preservation for audit trails
  • Safe deletion without breaking referential integrity
  • Ability to recover accidentally deleted records
  • Compliance with data retention policies

Audit Trail

All entities inherit auditable properties tracking:

  • Creation timestamp
  • Last modification timestamp
  • Created by user
  • Modified by user

Domain Events

The Book aggregate emits domain events (e.g., BookCreatedEvent) for:

  • Event-driven architecture integration
  • Cross-service communication
  • Audit logging
  • Real-time updates to other services (Basket, Ordering)

Data Classification & Governance

  • Classification: Internal - Not exposed directly to external systems
  • Access Mode: Read/Write - Full CRUD operations for authorized services
  • Retention: 2 years - Aligns with business and regulatory requirements
  • Residency: East Asia region - Optimized for primary user base location
  • Authoritative: True - Single source of truth for catalog data

Performance Considerations

  • Indexed on frequently queried fields (Name, CategoryId, PublisherId, Status)
  • Optimized for read-heavy workloads typical of e-commerce catalog browsing
  • Supports efficient filtering and searching through specification patterns
  • Materialized rating data (AverageRating, TotalReviews) for fast retrieval

Integration Points

The Catalog Database integrates with:

  • Basket Service: Product information for cart items
  • Ordering Service: Product details for order processing
  • Rating Service: Aggregated rating data updates
  • Search Service: Product indexing for full-text search
  • Finance Service: Pricing information for revenue calculations

Security

  • Database access restricted to Catalog Service only
  • Connection strings managed through secure configuration
  • Row-level security policies for multi-tenant scenarios (if applicable)
  • Encryption at rest for sensitive data
  • Audit logging for all data modifications