4.2 KiB
Category Domain Report
Scope
Sprint 4 added a complete Category Domain on top of the existing backend API contract. Backend endpoints and payload names were not changed.
Existing backend category fields remain isolated as DTO input:
categoryIDparentIDnameiconpriorityvisiblecategoriesCountitemCountnames[]
The UI now consumes category domain models rather than backend-shaped category responses.
Implemented Files
DTO
src/app/core/categories/dto/category.dto.ts
Defines CategoryDto and CategoryNameDto for existing backend category payloads. Compatibility fields for current mock/API variants are accepted only at the DTO boundary.
Domain Model
src/app/core/categories/models/category-domain.model.ts
Frontend category model exposes:
idparentIdtitleiconpriorityvisibleitemCountchildren[]translations
No backend category naming is required by category UI consumers.
Mapper
src/app/core/categories/mappers/category.mapper.ts
Maps backend DTOs into domain categories, including:
- backend id normalization
- parent id normalization
- title fallback selection
names[]totranslations- nested DTO flattening
- visible-category filtering
- priority sorting
- duplicate id de-duplication
Tree Utilities
src/app/core/categories/utils/category-tree.utils.ts
Supports:
- flat list to tree
- unlimited nesting
- parent lookup
- children lookup
- breadcrumb generation
- leaf detection
- tree flattening for future lazy-loading compatibility
Repository Abstraction
src/app/core/categories/repositories/category.repository.tssrc/app/core/categories/repositories/api-category.repository.tssrc/app/core/categories/category-repository.token.ts
CategoryRepository returns DTOs from the existing GET /category API. The injection token uses the existing runtime provider strategy and remains compatible with both mock and API modes. Mock mode continues to work through the existing mock-data interceptor.
Category Service
src/app/core/categories/category.service.ts
Converts repository DTOs through the mapper and exposes domain methods:
- all categories
- category tree
- root categories
- category by id
- children
- parent
- breadcrumb
- leaf detection
Category Facade
src/app/facades/platform/category.facade.ts
Exposes observable streams and state for:
- all categories
- category tree
- root categories
- category by id
- selected category
- breadcrumb
- children
Product Compatibility
src/app/core/products/models/product-domain.model.tssrc/app/core/products/providers/api-product-data.provider.ts
ProductFacade.getCategories() now resolves through CategoryService, so compatibility category access also returns the new category domain model.
UI Migration
Updated category-facing UI consumers:
src/app/pages/home/home.component.tssrc/app/pages/home/home.component.htmlsrc/app/pages/category/subcategories.component.tssrc/app/pages/category/subcategories.component.htmlsrc/app/pages/category/category.component.ts
The home page and subcategory page now consume CategoryFacade and Category domain models. Category route item loading still uses the existing product facade for product lists, without changing product/payment/auth contracts.
Validation
Completed checks:
- DTOs are isolated under
core/categories/dto. - Category mapper exists and is the only category DTO-to-domain conversion point.
- Category UI uses
CategoryFacadeand category domain models. - Category backend field names are contained to the category DTO/mapper boundary and compatibility internals.
- Components do not use
HttpClientfor category data. - No authentication changes were made.
- No payment changes were made.
- No bootstrap contract changes were made.
- No backend API contract changes were made.
- Mock/API compatibility is preserved through the repository token and existing mock interceptor.
Build validation passed:
npm run build
Stop Point
Category Domain implementation is complete for Sprint 4. Stop here for approval before starting the next domain or any Builder/Backoffice work.