---
id: book
name: Book
version: 1.0.0
identifier: id
aggregateRoot: true
summary: Canonical sellable title in the product catalog, encapsulating descriptive metadata, pricing, stock availability, taxonomy links, and derived rating summaries.
owners:
  - catalog-experience-team
badges:
  - content: Aggregate Root
    backgroundColor: blue
    textColor: blue
properties:
  - name: id
    type: UUID
    required: true
    description: Globally unique UUIDv7 identifier for the book.
  - name: name
    type: string
    required: true
    description: Display title of the book (non-whitespace, up to 50 characters).
  - name: description
    type: string
    required: true
    description: Synopsis or editorial description of the book (up to 1,000 characters).
  - name: image
    type: string
    required: false
    description: Cover image asset reference or URL (up to 255 characters).
  - name: price
    type: object
    required: true
    description: Regular price and optional promotional sale price.
    properties:
      - name: originalPrice
        type: decimal
        required: true
        description: Regular non-negative unit price.
      - name: discountPrice
        type: decimal
        required: false
        description: Optional sale price; must be non-negative and not exceed originalPrice.
  - name: status
    type: string
    required: true
    description: Catalog listing availability state.
    enum:
      - InStock
      - OutOfStock
  - name: averageRating
    type: double
    required: true
    description: Derived mean rating projected asynchronously from customer feedback.
  - name: totalReviews
    type: integer
    required: true
    description: Derived count of customer reviews projected asynchronously.
  - name: categoryId
    type: UUID
    required: false
    description: Identifier of the assigned Category, if any.
    references: category
    referencesIdentifier: id
    relationType: belongsTo
  - name: publisherId
    type: UUID
    required: false
    description: Identifier of the assigned Publisher, if any.
    references: publisher
    referencesIdentifier: id
    relationType: publishedBy
  - name: authorIds
    type: array
    required: false
    description: Identifiers of the Authors credited on this book.
    references: author
    referencesIdentifier: id
    relationType: writtenBy
    items:
      type: UUID
  - name: isDeleted
    type: boolean
    required: true
    description: Soft-delete marker hiding retired books from standard queries.
  - name: createdAt
    type: datetime
    required: true
    description: UTC timestamp when the book was created.
  - name: lastModifiedAt
    type: datetime
    required: false
    description: UTC timestamp of the most recent modification.
  - name: rowVersion
    type: string
    required: true
    description: Persistence-managed optimistic concurrency token.
---

## Domain Role & Boundary

**Book** is the central Aggregate Root in the [[domain|catalog]] bounded context, representing a sellable title with its descriptive metadata, pricing value object, availability status, taxonomy associations, and derived rating summary. Owned by [[service|catalog-api]] (with vector index synchronization handled by [[service|catalog-ingestion]]), it serves as the single source of truth for product discovery and checkout price resolution. It explicitly does **not** own customer shopping baskets ([[domain|shopping]]), locked purchase-time order prices ([[domain|ordering]]), or individual customer reviews ([[domain|reviews]]).

## Entity Profile

| Property                      | Value                                                                       |
| :---------------------------- | :-------------------------------------------------------------------------- |
| **Bounded Context / Domain**  | [[domain\|catalog]]                                                         |
| **Owning Service**            | [[service\|catalog-api]]                                                    |
| **DDD Role**                  | Aggregate Root                                                              |
| **Identifier Strategy**       | UUIDv7 generated at persistence                                             |
| **Persistence Store**         | Catalog relational database (`books`)                                       |
| **Deletion Semantics**        | Soft-delete (`isDeleted` flag excludes retired books from standard queries) |
| **Concurrency Control**       | Optimistic concurrency via persistence-managed row version                  |
| **PII / Data Classification** | Public catalog metadata (non-PII)                                           |

## Attributes & Constraints

<EntityPropertiesTable />

| Attribute                       | Business Rule / Constraint                                                                 | Sensitivity / Notes          |
| :------------------------------ | :----------------------------------------------------------------------------------------- | :--------------------------- |
| `name`                          | Required; non-whitespace, max 50 characters, indexed for lookup.                           | Public                       |
| `description`                   | Required on persistence and update; non-whitespace, max 1,000 characters.                  | Public                       |
| `price`                         | Embedded value object (`originalPrice >= 0`; `discountPrice >= 0` and `<= originalPrice`). | Monetary precision `(18, 2)` |
| `status`                        | Defaults to `InStock`; transitions between `InStock` and `OutOfStock`.                     | Availability indicator only  |
| `averageRating`, `totalReviews` | Default to `0.0` and `0`; updated exclusively via asynchronous feedback events.            | Derived projection           |
| `categoryId`, `publisherId`     | Nullable taxonomy references; cleared to null if the parent taxonomy is deleted.           | Optional foreign keys        |

## Domain Invariants & Lifecycle

- **Pricing integrity:** Original price cannot be negative, and an optional discount price must be non-negative and never exceed the original price.
- **Availability semantics:** New books default to `InStock`. Catalog availability indicates listing status for discovery and never acts as an inventory reservation or fulfillment guarantee.
- **Derived rating summary:** `averageRating` and `totalReviews` are rebuilt from [[domain|reviews]] events; removing the last review resets both fields to `0`.
- **Soft-delete isolation:** Deleting a book marks `isDeleted = true` rather than removing the record, automatically hiding the book and its author links from standard catalog queries.
- **Taxonomy replacement:** Updating a book replaces its credited [[entity|author]] links as a complete set.

:::warning
Catalog price updates never retroactively change prices on existing [[entity|order-item]] records. Conversely, if a [[domain|reviews]] event arrives for a soft-deleted or nonexistent book, [[service|catalog-api]] emits [[event|BookUpdatedRatingFailedIntegrationEvent]] so Reviews can compensate.
:::

## Relationships & Associated Operations

| Category                     | Resource                                                                                                                                                                        | Role / Interaction                                         |
| :--------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------- |
| **Related Entities**         | [[entity\|author]], [[entity\|category]], [[entity\|publisher]]                                                                                                                 | Intra-context taxonomy and authorship relationships        |
| **Cross-Context References** | [[entity\|feedback]], [[entity\|basket-item]], [[entity\|order-item]]                                                                                                           | Referenced strictly by `bookId` across service boundaries  |
| **Mutating Commands**        | [[command\|CreateBook]], [[command\|UpdateBook]], [[command\|DeleteBook]]                                                                                                       | Manage book lifecycle, metadata, and soft deletion         |
| **Read Queries**             | [[query\|GetBook]], [[query\|ListBooks]], [[query\|GetBookGrpc]], [[query\|GetBooksGrpc]], [[query\|ListBooksGrpc]], [[query\|GetBookDetailsGrpc]], [[query\|GetDashboardGrpc]] | HTTP discovery, hybrid search, and internal gRPC lookups   |
| **Events**                   | [[event\|FeedbackCreatedIntegrationEvent]], [[event\|FeedbackDeletedIntegrationEvent]], [[event\|BookUpdatedRatingFailedIntegrationEvent]]                                      | Consume rating deltas and signal missing-book compensation |
