From c70d2a391af3dee9c333423023968e8ad37026f8 Mon Sep 17 00:00:00 2001 From: Ccjcarkbla Date: Wed, 10 Jun 2026 22:26:02 -0400 Subject: [PATCH] v2 Planning start --- .gitignore | 2 + V2/planning/ARCHITECTURE.md | 370 +++++++++++++++++++++++++++ V2/planning/DATA_MODEL.md | 348 +++++++++++++++++++++++++ V2/planning/DISPLAY_DESIGN.md | 253 ++++++++++++++++++ V2/planning/MIGRATION_PLAN.md | 154 +++++++++++ V2/planning/PRODUCT_VISION.md | 210 +++++++++++++++ V2/planning/README.md | 27 ++ V2/planning/REQUIREMENTS.md | 118 +++++++++ V2/planning/ROLES_AND_PERMISSIONS.md | 244 ++++++++++++++++++ 9 files changed, 1726 insertions(+) create mode 100644 V2/planning/ARCHITECTURE.md create mode 100644 V2/planning/DATA_MODEL.md create mode 100644 V2/planning/DISPLAY_DESIGN.md create mode 100644 V2/planning/MIGRATION_PLAN.md create mode 100644 V2/planning/PRODUCT_VISION.md create mode 100644 V2/planning/README.md create mode 100644 V2/planning/REQUIREMENTS.md create mode 100644 V2/planning/ROLES_AND_PERMISSIONS.md diff --git a/.gitignore b/.gitignore index 77575d5..b6d77c4 100644 --- a/.gitignore +++ b/.gitignore @@ -414,3 +414,5 @@ FodyWeavers.xsd # JetBrains Rider *.sln.iml +.claude/ +.exclude/ \ No newline at end of file diff --git a/V2/planning/ARCHITECTURE.md b/V2/planning/ARCHITECTURE.md new file mode 100644 index 0000000..1afb111 --- /dev/null +++ b/V2/planning/ARCHITECTURE.md @@ -0,0 +1,370 @@ +# VitFit V2 — Architecture + +## Guiding Principles + +1. **Lean stack** — The server has 2 CPU / 4 GB RAM. No unnecessary processes. +2. **Modular** — Each feature is a drop-in module. Core framework is untouched when adding features. +3. **Safari-first** — All frontend decisions are validated against Safari on iPadOS. +4. **24h session stability** — Long-running JS must not leak memory or drift. Server-authoritative state where possible. +5. **API-clean** — REST responses are consistent now so a future iOS app requires no backend changes. + +--- + +## Server Environment + +| Item | Value | +|------|-------| +| OS | Ubuntu 24.04.1 LTS | +| Access | PuTTY (SSH), WinSCP (SFTP) — no other access method | +| App root | `/home/ubuntu/site/` | +| Frontend pages | `/home/ubuntu/site/public/` | +| Video uploads | `/home/ubuntu/site/uploads/` (outside public, **do not move**) | +| Process manager | PM2 | +| Reverse proxy | Nginx | + +The `uploads/` directory is **outside** the `public/` static tree intentionally. All video files are served through an authenticated Express route, never as bare static files. This means gym videos are not publicly accessible without a valid JWT — a security improvement over V1. + +--- + +## Backend + +### Framework: Express.js (keep) + +No reason to change. Lightweight, well-understood, sufficient for the load. + +**Changes from V1:** +- Routes split into module files, not one monolithic `app.js` +- Middleware organized: auth, validation, error handling, logging — each in own file +- `helmet` added for security headers +- `express-rate-limit` on `/login` +- `express-validator` or `zod` for request body validation on all routes + +### Database: SQLite + Sequelize (keep, add migrations) + +SQLite is appropriate for a single-gym install with < 10 concurrent users. Do not over-engineer. + +**Changes from V1:** +- Replace `sync({ alter: true })` with proper Sequelize migrations (`sequelize-cli`) +- Every schema change ships as a numbered migration file +- V1 → V2 migration script handles the initial data carry-over +- DB file location configurable via `.env` + +### Video File Serving + +V1 stored uploads in `public/uploads/` and served them as static files — no auth required to access the video files if you knew the URL. V2 changes this. + +**V2 approach: authenticated streaming route** + +``` +GET /uploads/:filename + → authenticateToken middleware + → pipes file from /home/ubuntu/site/uploads/:filename + → sets correct Content-Type based on mime type stored in DB + → supports Range header for video seeking (required by Safari's