From 34b7ac023177387c3754c016bda430707160ee3d Mon Sep 17 00:00:00 2001 From: Djalim Simaila Date: Sun, 26 Apr 2026 22:29:10 +0200 Subject: [PATCH] docs: update CLAUDE.md to reflect completed API layer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mark all implemented endpoints as ✅, document the 3-level test architecture, and clarify that UI pages are the next priority. Co-Authored-By: Claude Sonnet 4.6 --- CLAUDE.md | 147 +++++++++++++++++++++++++++++------------------------- 1 file changed, 80 insertions(+), 67 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index fe5c70d..435d43f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -18,8 +18,8 @@ role-based administration. ### Current Status -🚧 **In Progress** - Application is far from complete. The schema below is the -**final/definitive schema** that should guide all development. +🚧 **In Progress** - API layer largely complete, UI pages not yet built. +The schema below is the **final/definitive schema** that guides all development. --- @@ -133,15 +133,11 @@ erDiagram AJUSTEMENT }o--|| UE : "dans" ``` -### Current Schema (Incomplete) +### Current Schema -The current Drizzle ORM schema in `/databases/schema.ts` only implements: - -- `promotions` -- `students` -- `mobility` - -**Migration needed**: Update schema to match the final ER diagram above. +The Drizzle ORM schema in `/databases/schema.ts` implements all tables: +`roles`, `permissions`, `rolePermissions`, `users`, `promotions`, `students`, +`modules`, `enseignements`, `ues`, `ueModules`, `notes`, `ajustements`, `mobility`. --- @@ -186,71 +182,73 @@ The current Drizzle ORM schema in `/databases/schema.ts` only implements: ### API Endpoints +Legend: ✅ implemented & tested | 📋 not yet implemented + **Students API** -- 📋 GET `/students` (#7) -- 📋 POST `/students` (#8) -- 📋 POST `/students/import-csv` (#9) -- 📋 GET `/students/{numEtud}` (#10) -- 📋 PUT `/students/{numEtud}` (#11) -- 📋 DELETE `/students/{numEtud}` (#12) -- 📋 GET `/promotions` (#13) -- 📋 POST `/promotions` (#14) -- 📋 GET `/promotions/{idPromo}` (#15) -- 📋 PUT `/promotions/{idPromo}` (#16) -- 📋 DELETE `/promotions/{idPromo}` (#17) +- ✅ GET `/students` (#7) +- ✅ POST `/students` (#8) +- ✅ POST `/students/import-csv` (#9) +- ✅ GET `/students/{numEtud}` (#10) +- ✅ PUT `/students/{numEtud}` (#11) +- ✅ DELETE `/students/{numEtud}` (#12) +- ✅ GET `/promotions` (#13) +- ✅ POST `/promotions` (#14) +- ✅ GET `/promotions/{idPromo}` (#15) +- ✅ PUT `/promotions/{idPromo}` (#16) +- ✅ DELETE `/promotions/{idPromo}` (#17) **Administration API - Modules & Enseignements** -- 📋 GET `/modules` (#23) -- 📋 POST `/modules` (#24) -- 📋 GET `/modules/{idModule}` (#25) -- 📋 PUT `/modules/{idModule}` (#26) -- 📋 DELETE `/modules/{idModule}` (#27) -- 📋 POST `/enseignements` (#29) -- 📋 GET `/enseignements/{idProf}/{idModule}/{idPromo}` (#30) -- 📋 DELETE `/enseignements/{idProf}/{idModule}/{idPromo}` (#31) +- ✅ GET `/modules` (#23) +- ✅ POST `/modules` (#24) +- ✅ GET `/modules/{idModule}` (#25) +- ✅ PUT `/modules/{idModule}` (#26) +- ✅ DELETE `/modules/{idModule}` (#27) +- ✅ POST `/enseignements` (#29) +- ✅ GET `/enseignements/{idProf}/{idModule}/{idPromo}` (#30) +- ✅ DELETE `/enseignements/{idProf}/{idModule}/{idPromo}` (#31) **Notes API - UEs & UE-Modules** -- 📋 GET `/ues` (#32) -- 📋 POST `/ues` (#33) -- 📋 GET `/ues/{idUE}` (#34) -- 📋 PUT `/ues/{idUE}` (#35) -- 📋 DELETE `/ues/{idUE}` (#36) -- 📋 GET `/ue-modules` (#37) -- 📋 POST `/ue-modules` (#38) -- 📋 GET `/ue-modules/{idModule}/{idUE}/{idPromo}` (#39) -- 📋 PUT `/ue-modules/{idModule}/{idUE}/{idPromo}` (#40) -- 📋 DELETE `/ue-modules/{idModule}/{idUE}/{idPromo}` (#41) +- ✅ GET `/ues` (#32) +- ✅ POST `/ues` (#33) +- ✅ GET `/ues/{idUE}` (#34) +- ✅ PUT `/ues/{idUE}` (#35) +- ✅ DELETE `/ues/{idUE}` (#36) +- ✅ GET `/ue-modules` (#37) +- ✅ POST `/ue-modules` (#38) +- ✅ GET `/ue-modules/{idModule}/{idUE}/{idPromo}` (#39) +- ✅ PUT `/ue-modules/{idModule}/{idUE}/{idPromo}` (#40) +- ✅ DELETE `/ue-modules/{idModule}/{idUE}/{idPromo}` (#41) **Notes API - Notes & Ajustements** -- 📋 GET `/notes` (#42) -- 📋 POST `/notes` (#43) +- ✅ GET `/notes` (#42) +- ✅ POST `/notes` (#43) - 📋 POST `/notes/import-xlsx` (#44) -- 📋 GET `/notes/{numEtud}/{idModule}` (#45) -- 📋 PUT `/notes/{numEtud}/{idModule}` (#46) -- 📋 DELETE `/notes/{numEtud}/{idModule}` (#47) -- 📋 GET `/ajustements` (#48) -- 📋 POST `/ajustements` (#49) -- 📋 GET `/ajustements/{numEtud}/{idUE}` (#50) -- 📋 PUT `/ajustements/{numEtud}/{idUE}` (#51) -- 📋 DELETE `/ajustements/{numEtud}/{idUE}` (#52) +- ✅ GET `/notes/{numEtud}/{idModule}` (#45) +- ✅ PUT `/notes/{numEtud}/{idModule}` (#46) +- ✅ DELETE `/notes/{numEtud}/{idModule}` (#47) +- ✅ GET `/ajustements` (#48) +- ✅ POST `/ajustements` (#49) +- ✅ GET `/ajustements/{numEtud}/{idUE}` (#50) +- ✅ PUT `/ajustements/{numEtud}/{idUE}` (#51) +- ✅ DELETE `/ajustements/{numEtud}/{idUE}` (#52) **Administration API - Users, Roles & Permissions** -- 📋 GET `/users` (#60) -- 📋 POST `/users` (#61) -- 📋 GET `/users/{id}` (#62) -- 📋 PUT `/users/{id}` (#63) -- 📋 DELETE `/users/{id}` (#64) -- 📋 GET `/roles` (#65) -- 📋 POST `/roles` (#66) -- 📋 GET `/roles/{idRole}` (#67) -- 📋 PUT `/roles/{idRole}` (#68) -- 📋 DELETE `/roles/{idRole}` (#69) -- 📋 GET `/permissions` (#70) +- ✅ GET `/users` (#60) +- ✅ POST `/users` (#61) +- ✅ GET `/users/{id}` (#62) +- ✅ PUT `/users/{id}` (#63) +- ✅ DELETE `/users/{id}` (#64) +- ✅ GET `/roles` (#65) +- ✅ POST `/roles` (#66) +- ✅ GET `/roles/{idRole}` (#67) +- ✅ PUT `/roles/{idRole}` (#68) +- ✅ DELETE `/roles/{idRole}` (#69) +- ✅ GET `/permissions` (#70) --- @@ -298,10 +296,24 @@ deno task check ### Testing -- Write unit tests for business logic -- Integration tests for API endpoints -- E2E tests with HappyDOM for UI interactions -- Mock database with provided helpers +3-level architecture — all 149 tests pass: + +- **Unit** (`tests/unit/`) — pure logic with mock DB + mock API, no real DB +- **Integration** (`tests/integration/`) — Drizzle ORM direct on real DB +- **E2E** (`tests/e2e/`) — Fresh handler + real DB (handler-level, not browser) + +Helpers in `tests/helpers/`: +- `handler.ts` — builds fake Fresh contexts (`makeEmployeeContext`, `makeJsonRequest`…) +- `db_integration.ts` — seed functions + `truncateAll()` for test isolation +- `db_mock.ts` / `api_mock.ts` — in-memory mocks for unit tests + +```bash +deno task test # run all tests +deno task test:coverage # coverage report (terminal) +deno task test:coverage:html # coverage report (HTML → coverage/html/index.html) +nix run nixpkgs#act -- -j unit --no-cache-server # unit tests via GitHub Actions +nix run nixpkgs#act -- -j integration --no-cache-server # integration + e2e via GitHub Actions +``` --- @@ -327,12 +339,13 @@ deno task check ## 💡 Important Notes -1. **Current Limitation**: The database schema in `/databases/schema.ts` does - NOT match the final ER diagram. This is a priority migration task. -2. **Design System**: Follow the Figma prototype for all UI work. +1. **Only missing API**: `POST /notes/import-xlsx` (#44) — all other endpoints are implemented. +2. **Next priority**: UI pages (none built yet) — follow the Figma prototype. 3. **Module Pattern**: Each module should follow the same pattern: routes, API endpoints, components, and tests. 4. **Permissions**: All admin operations should respect the ROLE_PERMISSION system. 5. **Fresh Conventions**: Routes use Fresh's file-based routing convention (e.g., `routes/path/index.tsx`). +6. **Drizzle `.where()` pitfall**: Always wrap multiple conditions with `and()`. + `.where(eq(a), eq(b))` silently ignores the second argument.