Architecture — Category Master: Three-Level Hierarchy Administration
| Metadata | Details |
|---|---|
| System | product-catalog — Category Master |
| Document ID | ARCH-2026-PCT-002 |
| Author | Engineering Team |
| Status | Approved |
Implements SR-024, per the hierarchy-representation decision in ADR-00038.
Components
| Component | Language/Runtime | Role |
|---|---|---|
CategoryPage.tsx / CategoryController.ts |
React (admin UI) | Three-panel cascading tree + Inspector Panel |
pages/CategoryRootLeafPage.tsx / CategoryRootLeafController.ts |
React (admin UI) | Level-0 (root) sub-form, hosted in the Add/Edit Drawer |
pages/CategorySubcatsLeafPage.tsx / CategorySubcatsLeafController.ts |
React (admin UI) | Level-1 (sub-category) sub-form |
pages/CategoryLeafNodesPage.tsx / CategoryLeafNodesController.ts |
React (admin UI) | Level-2 (leaf) sub-form |
CategoryRepository.ts |
React/Axios (admin UI) | Sole apiClient consumer for this feature |
transport/api/category/ |
Go (Echo REST) | product-catalog’s category controller |
service/category/ |
Go | Validation, ancestors computation, children-existence delete guard |
repository/category/ |
Go (MongoDB) | categories collection persistence |
transport/grpc/category/ |
Go (gRPC server) | CategoryQueryService.GetCategoriesByIDs, read-only |
shop-service (gRPC client) |
Go | Resolves category details for storefront display |
| Product-setup wizard (REST client) | React (admin UI) | Separate consumer of GET /category/product-categories |
End-to-end flow (A) — Create a root category (level 0)
- Admin selects “Add Root,” fills
pages/CategoryRootLeafPage.tsx’sname/slug/specTemplatefields (SR-024 FR-04), and submits. CategoryRepository.tscallsPOST /product/admin/api/v1/categorywithnodeLevel = 0,parentId = null.service/category/Createvalidates the payload againstdomain/category_validation.go’s level-0 rules, confirmssluguniqueness (SR-024 FR-07), setsancestors = [](a root has none), and inserts the document viarepository/category/(SR-024 FR-09).
End-to-end flow (B) — Create a sub-category (level 1) or leaf category (level 2)
- Admin selects the parent node in the panel above, then “Add Sub-Category” or “Add Leaf” — the Drawer hosts
CategorySubcatsLeafPage.tsxorCategoryLeafNodesPage.tsxaccordingly (SR-024 FR-05/FR-06). CategoryRepository.tscallsPOST /product/admin/api/v1/categorywithparentIdset to the selected parent’s ID andnodeLevelset accordingly (never client-chosen independently of the parent).service/category/Createreads the parent document, sets the new document’sancestors = parent.ancestors + [parent.id](SR-024 FR-09), setsmainDisplayCategorydeterministically by level (SR-024 FR-05/FR-06), and inserts the document.
End-to-end flow (C) — Edit, delete, and the two downstream reads
- Edit:
PUT /product/admin/api/v1/category/:idupdates onlyname/slug/spec_template/display_order/main_display_category/variant_attributes—parentId/nodeLevel/ancestorsare immutable after insert (SR-024 FR-08). - Delete:
DELETE /product/admin/api/v1/category/:idfirst checksrepository/category/for any document whoseparentIdequals the target’s ID; if any exist, the call is rejected rather than deleted (SR-024 FR-10). - Product wizard’s category picker:
GET /product/admin/api/v1/category/product-categoriesreturns every leaf category joined with its parent’svariantAttributes— a separate, read-only consumer of this same collection (SR-024 FR-13). shop-service’s gRPC read:CategoryQueryService.GetCategoriesByIDsresolves category details for the storefront, entirely independent of this console’s REST surface (SR-024 FR-14).
Why this is simple, and what it does not yet guarantee
Computing ancestors once, at insert, and never allowing parentId/nodeLevel to change afterward (per ADR-00038) means no code path anywhere in product-catalog ever has to cascade an ancestor-array correction to a node’s descendants — the array is write-once and trusted thereafter.
This flow does not yet guarantee: (a) a way to move a category to a different parent or level once created — not supported at all, by design, not just unbuilt; (b) any staged-publish lifecycle the way Warehouse Master/Package Master have — active is always true; (c) that description/createdAt/updatedAt, though stored on every document, are ever returned to a caller. All three, plus the admin console’s absent search/filter/pagination and the feature’s missing DEV_MOCK_* fallback, are tracked in Technical Debt — TD-00018.
Related Documents
- BRD-023 — Category Master: Maintaining the Product Category Hierarchy
- SR-024 — Category Master: Administration System Requirements
- ADR-00038 — Adjacency List with Denormalized Ancestors, and Immutable Tree Position, for Category Master
- Technical Debt — Category Master Gaps
- Admin UI Walkthrough — Category Master Console
- Microservices: product-catalog, shop-service