---
id: category
name: Category
version: 1.0.0
identifier: id
aggregateRoot: true
summary: Single-level taxonomy classification grouping books by subject or genre within the product catalog.
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 category.
  - name: name
    type: string
    required: true
    description: Unique category display name (non-whitespace, up to 50 characters).
---

## Domain Role & Boundary

**Category** is an Aggregate Root in the [[domain|catalog]] bounded context representing a single-level subject or genre classification for books. Owned by [[service|catalog-api]], it provides a controlled vocabulary for storefront filtering and backoffice organization. It explicitly does **not** own a collection of books or hierarchical parent-child category trees; books reference their category by identifier.

## 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 (`categories`)                                    |
| **Deletion Semantics**        | Hard-delete; clears `categoryId` to null on affected [[entity\|book]] records |
| **Concurrency Control**       | Last-write-wins (unique name constraint enforced by store)                    |
| **PII / Data Classification** | Public catalog metadata (non-PII)                                             |

## Attributes & Constraints

<EntityPropertiesTable />

| Attribute | Business Rule / Constraint                                                      | Sensitivity / Notes   |
| :-------- | :------------------------------------------------------------------------------ | :-------------------- |
| `id`      | Immutable primary identifier generated as UUIDv7.                               | Public identifier     |
| `name`    | Required, non-whitespace, max 50 characters, globally unique across categories. | Unique index enforced |

## Domain Invariants & Lifecycle

- **Name required:** Creating or renaming a category with a null, empty, or whitespace-only name is rejected.
- **Global uniqueness:** Duplicate category names are rejected by the persistence layer to keep storefront filters unambiguous.
- **Non-cascading hard delete:** Removing a category permanently deletes the category record and sets `categoryId` to null on any linked [[entity|book]] without deleting the books themselves.
- **Lifecycle events:** Creation, renaming, and deletion raise internal domain events within [[service|catalog-api]].

:::note
Because categories are flat (single-level) and hard-deleted, renaming a category immediately reflects across all referencing books without migrating child trees.
:::

## Relationships & Associated Operations

| Category              | Resource                                                                              | Role / Interaction                                                |
| :-------------------- | :------------------------------------------------------------------------------------ | :---------------------------------------------------------------- |
| **Related Entities**  | [[entity\|book]]                                                                      | One category classifies zero or more books via `books.categoryId` |
| **Mutating Commands** | [[command\|CreateCategory]], [[command\|UpdateCategory]], [[command\|DeleteCategory]] | Create, rename, or remove a category                              |
| **Read Queries**      | [[query\|ListCategories]], [[query\|ListCategoriesGrpc]]                              | Storefront filter lists and internal gRPC lookups                 |
