/admin/categories. The store has 13 categories organized hierarchically using a parent_id self-reference. Categories are split between the vape and 420 sections.
Data Shape
Hierarchical Structure
Categories support one level of nesting viaparent_id:
parent_id is a foreign key to the same categories table. The TypeScript type CategoryWithChildren extends Category with a children: Category[] array used to build tree views in the UI.
CRUD Functions
getAllCategories
section (ascending), then by order_index (ascending). Returns all fields including description, image_url, and is_popular.
createCategory
updateCategory
deleteCategory
toggleCategoryActive
is_active field. Inactive categories are hidden from the storefront navigation but their products remain accessible if a customer has a direct URL.
Ordering
Categories within a section are sorted byorder_index (ascending). Lower numbers appear first. Update order_index via updateCategory to reorder:
Slug Generation
Category slugs are auto-generated from thename field using the slugify() utility:
/vape/accesorios-vape) and must be unique per section. If a slug collision occurs, add a suffix manually before saving.
Section Assignment
Every category belongs to eithervape or 420. Products can only be assigned to categories in their own section. Attempting to assign a vape product to a 420 category is prevented at the service layer.
