Category (v1.0.0)

Represents a product category with hierarchical structure support.

Overview

The Category entity organizes products into a hierarchical structure, supporting multi-level categorization. It enables efficient product discovery and navigation through the e-commerce catalog.

Entity Properties

NameTypeRequiredDescription
categoryIdUUIDRequiredUnique identifier for the category
namestringRequiredName of the category
descriptionstringOptionalDescription of the category
slugstringRequiredURL-friendly identifier for the category
parentCategoryIdUUIDOptionalParent category for hierarchical structure
childCategoriesarray<Category>OptionalSubcategories under this category
levelintegerRequiredDepth level in the category hierarchy (0 = root)
isActivebooleanRequiredWhether the category is currently active
sortOrderintegerOptionalDisplay order within the same level
iconstringOptionalIcon URL or identifier for the category
imageUrlstringOptionalCategory banner or thumbnail image
seoTitlestringOptionalSEO-optimized title for the category page
seoDescriptionstringOptionalSEO meta description for the category page
productsarray<Product>OptionalProducts belonging to this category
createdAtDateTimeRequiredDate and time when the category was created
updatedAtDateTimeOptionalDate and time when the category was last updated

Relationships

  • Parent Category: Each category can have one parent Category (identified by parentCategoryId).
  • Child Categories: A category can have multiple child Category entities creating a hierarchy.
  • Products: A category contains multiple Product entities (identified by categoryId).

Hierarchy Examples

Electronics (Level 0)
├── Computers (Level 1)
│   ├── Laptops (Level 2)
│   ├── Desktops (Level 2)
│   └── Tablets (Level 2)
├── Mobile Phones (Level 1)
│   ├── Smartphones (Level 2)
│   └── Feature Phones (Level 2)
└── Audio (Level 1)
    ├── Headphones (Level 2)
    └── Speakers (Level 2)

Business Rules

  • Root categories have parentCategoryId as null and level as 0
  • Child categories must have a valid parentCategoryId
  • Category slugs must be unique across the entire catalog
  • Categories cannot be deleted if they contain products or subcategories
  • Inactive categories should hide all associated products from public view
  • Maximum hierarchy depth should be limited (e.g., 5 levels)