Overview
The frontend Departments page (frontend/app/(dashboard)/departments/page.tsx) is fully built — create/edit/delete forms are done — but every call fails because there is no departments API. Departments are also a required relation on assets and users.
What to Build
A DepartmentsModule in backend/src/departments/ with:
Entity: id (uuid), name (unique), description (nullable), createdAt, updatedAt.
| Method |
Path |
Description |
GET |
/api/departments |
List all, each with assetCount |
POST |
/api/departments |
Create { name, description? } |
PATCH |
/api/departments/:id |
Update name/description |
DELETE |
/api/departments/:id |
Delete (reject or block if assets are still assigned) |
API Contract
frontend/lib/api/assets.ts — getDepartments() expects DepartmentWithCount[] ({ id, name, description, assetCount }), plus createDepartment, updateDepartment, deleteDepartment.
References
- Prior implementation:
git show f28e3f8~1 -- backend/src/ (departments logic lived under the deleted modules)
- Blocked by [BE-01] (guards)
Acceptance Criteria
Overview
The frontend Departments page (
frontend/app/(dashboard)/departments/page.tsx) is fully built — create/edit/delete forms are done — but every call fails because there is no departments API. Departments are also a required relation on assets and users.What to Build
A
DepartmentsModuleinbackend/src/departments/with:Entity:
id(uuid),name(unique),description(nullable),createdAt,updatedAt.GET/api/departmentsassetCountPOST/api/departments{ name, description? }PATCH/api/departments/:idDELETE/api/departments/:idAPI Contract
frontend/lib/api/assets.ts—getDepartments()expectsDepartmentWithCount[]({ id, name, description, assetCount }), pluscreateDepartment,updateDepartment,deleteDepartment.References
git show f28e3f8~1 -- backend/src/(departments logic lived under the deleted modules)Acceptance Criteria
assetCountcomputed per department (0 until assets module lands)409409with a clear messageJwtAuthGuard