| name | add-crud-resource |
| description | Use when adding a brand-new CRUD resource beyond the core entity (e.g. a second model the PS requires). |
Add CRUD Resource Playbook
Follow this checklist to introduce a new resource model to the system:
-
Prisma Model Setup:
- Open
prisma/schema.prisma and define your new model (e.g., Category, Comment, Log).
- Add relationships if it belongs to
User or the main entity.
-
Migration & Types:
- Run
npx prisma migrate dev --name add_new_model.
- Run
npx prisma generate to update types.
-
API Endpoints:
- Create
src/app/api/new-resource/route.ts (GET all, POST create).
- Create
src/app/api/new-resource/[id]/route.ts (GET single, PUT update, DELETE).
- Enforce authorization guards (check if user is logged in, check role or owner).
- Validate requests using Zod schemas.
-
Frontend Interface:
- Create list page
src/app/new-resource/page.tsx utilizing the <DataTable> primitive.
- Create detail page
src/app/new-resource/[id]/page.tsx.
- Implement form client components for create/edit.
-
Navigation integration:
- Add routing links inside
<Navbar> or <Sidebar> as needed.