# VitFit V2 — Structure Index Implementation blueprints. Read planning docs first, then these structure docs before writing code. ## Documents | Document | What it covers | |----------|---------------| | [FILE_STRUCTURE.md](FILE_STRUCTURE.md) | Every file in the project with purpose, exports, and key behavior | | [BACKEND_METHODS.md](BACKEND_METHODS.md) | Method signatures for all core/ and module service files | | [API_ROUTES.md](API_ROUTES.md) | Every endpoint: method, path, auth, request body, response shape, errors | | [DATABASE_SCHEMA.md](DATABASE_SCHEMA.md) | Sequelize model definitions, associations, indexes, migration order | | [SOCKET_EVENTS.md](SOCKET_EVENTS.md) | Timer engine Socket.io events (server→client and client→server) | | [FRONTEND_MAP.md](FRONTEND_MAP.md) | Every HTML page: access roles, API calls on load, user actions, key JS behavior | | [TESTING.md](TESTING.md) | Test structure, unit/integration/socket/e2e test cases, helpers, scripts | ## Reading Order 1. `FILE_STRUCTURE.md` — get the big picture of what exists 2. `DATABASE_SCHEMA.md` — understand the data shapes before reading services 3. `BACKEND_METHODS.md` — understand what each service function does 4. `API_ROUTES.md` — understand the contract between frontend and backend 5. `SOCKET_EVENTS.md` — understand the timer real-time system 6. `FRONTEND_MAP.md` — understand how each page uses the API 7. `TESTING.md` — understand what must be tested and how ## Module Count | Layer | Count | |-------|-------| | Backend modules | 10 (auth, users, org, videos, workouts, timers, crossfit, clients, audit, sysadmin) | | API endpoints | 55 | | Database tables | 13 | | Socket.io events | 8 | | Frontend pages | 22 | | Shared JS modules | 4 (core, socket-client, display, timer-display) | | CSS files | 4 (base, layout, components, display) | ## Implementation Notes - All modules are auto-loaded by `app.js` scanning `modules/*/routes.js` - All service functions throw `AppError` — routes never construct error responses directly - All routes call `core/audit.js log()` after successful mutations - `organizationId` is added to every DB query by the service layer, not the route layer - Display-mode pages (`*-display.html`) are the TV-facing views; all others are coach-facing - `core.js` runs on every page; `socket-client.js` only on display and timer pages