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
Name | Type | Required | Description |
---|---|---|---|
categoryId | UUID | Required | Unique identifier for the category |
name | string | Required | Name of the category |
description | string | Optional | Description of the category |
slug | string | Required | URL-friendly identifier for the category |
parentCategoryId | UUID | Optional | Parent category for hierarchical structure |
childCategories | array | Optional | Subcategories under this category |
level | integer | Required | Depth level in the category hierarchy (0 = root) |
isActive | boolean | Required | Whether the category is currently active |
sortOrder | integer | Optional | Display order within the same level |
icon | string | Optional | Icon URL or identifier for the category |
imageUrl | string | Optional | Category banner or thumbnail image |
seoTitle | string | Optional | SEO-optimized title for the category page |
seoDescription | string | Optional | SEO meta description for the category page |
products | array | Optional | Products belonging to this category |
createdAt | DateTime | Required | Date and time when the category was created |
updatedAt | DateTime | Optional | Date and time when the category was last updated |
Relationships
- Parent Category: Each category can have one parent
Category
(identified byparentCategoryId
). - Child Categories: A category can have multiple child
Category
entities creating a hierarchy. - Products: A category contains multiple
Product
entities (identified bycategoryId
).
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 andlevel
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)