# ProductCategory

## Description

ProductCategory represents a single node in a hierarchical tree structure used to classify products for commercial and marketing purposes. Each category is identified by a globally unique code and has a display name. Root categories have no parent. Categories can be reorganized by moving them to a different parent, and children follow their parent.

This is distinct from item-management's taxonomy, which classifies Items at the SKU level. Product categories organize the commercial view of products (e.g., Apparel > Men's > T-Shirts).

## Domain Model Definitions

### Model type

Standard

### Command Definitions

- [createProductCategory](../commands/CreateProductCategory.md) - Create a new root or child category
- [updateProductCategory](../commands/UpdateProductCategory.md) - Update the display name of an existing category
- [moveProductCategory](../commands/MoveProductCategory.md) - Reparent a category within the tree
- [deleteProductCategory](../commands/DeleteProductCategory.md) - Delete a leaf category with no product assignments

### Query Definitions

- GetProductCategory - Retrieve a category by id or code
- ListProductCategoryChildren - Retrieve direct child categories of a given category

### Models

- ProductCategory

### Invariants

- Category code is required, globally unique, and immutable after creation
- Category name is required and must be non-empty
- Root categories have a null parent reference
- Child categories must reference a valid existing parent category
- Category tree respects a configurable maximum depth (prevents excessively deep hierarchies)
- Circular references are prevented -- a category cannot be its own ancestor
- Category deletion is blocked if the category has child categories
- Category deletion is blocked if the category has product assignments
- Moving a category updates the category's parent reference while preserving its descendants

### Relationships

- **Self-Referential Parent-Child**: Each category optionally references another ProductCategory as its parent, forming a tree
- **Referenced By ProductCategoryAssignments**: Categories are linked to products via many-to-many assignments
