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 | Every file in the project with purpose, exports, and key behavior |
| BACKEND_METHODS.md | Method signatures for all core/ and module service files |
| API_ROUTES.md | Every endpoint: method, path, auth, request body, response shape, errors |
| DATABASE_SCHEMA.md | Sequelize model definitions, associations, indexes, migration order |
| SOCKET_EVENTS.md | Timer engine Socket.io events (server→client and client→server) |
| FRONTEND_MAP.md | Every HTML page: access roles, API calls on load, user actions, key JS behavior |
| TESTING.md | Test structure, unit/integration/socket/e2e test cases, helpers, scripts |
Reading Order
FILE_STRUCTURE.md— get the big picture of what existsDATABASE_SCHEMA.md— understand the data shapes before reading servicesBACKEND_METHODS.md— understand what each service function doesAPI_ROUTES.md— understand the contract between frontend and backendSOCKET_EVENTS.md— understand the timer real-time systemFRONTEND_MAP.md— understand how each page uses the APITESTING.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.jsscanningmodules/*/routes.js - All service functions throw
AppError— routes never construct error responses directly - All routes call
core/audit.js log()after successful mutations organizationIdis 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.jsruns on every page;socket-client.jsonly on display and timer pages