4 Commits

2 changed files with 100 additions and 68 deletions
+91
View File
@@ -0,0 +1,91 @@
# Phase 06 — Intelligent Workout Adaptation & Recovery Tracking
## 🎯 Goals
Skapa intelligenta träningsprogram som anpassas baserat på muskelgruppernas återhämtning, inte bara vilket pass som kördes senast.
## 📋 Features
### 06-01: Workout Swap/Rotation System
- [ ] Add "Swap Workout" button to WorkoutPage
- [ ] Show available workouts for current week
- [ ] Replace current workout while keeping tracking
- [ ] Update UI to show swap history
- [ ] Database: Update workout_logs to track swaps
### 06-02: Muscle Group Recovery Tracking
- [ ] Model: Define muscle groups per exercise
- [ ] Calculate recovery time from last workout targeting each group
- [ ] Store: muscle_group_recovery table (timestamp, intensity)
- [ ] Display: Recovery status in ExerciseCard (red/yellow/green)
- [ ] Algorithm: Track last 7-14 days of activity per muscle group
### 06-03: Smart Workout Recommendation Engine
- [ ] Analyze: Which muscle groups were trained this week
- [ ] Identify: Most-recovered groups available to train today
- [ ] Suggest: 2-3 workouts that target recovered muscle groups
- [ ] Avoid: Overtraining same groups (48-72h rest recommendation)
- [ ] Backend: POST /api/recommendations/smart-workout
### 06-04: Recovery Metrics & Analytics
- [ ] Dashboard card: Recovery status per muscle group
- [ ] Chart: 7-day muscle group activity heatmap
- [ ] Insight: "Chest needs work", "Legs well-recovered"
- [ ] Prediction: Next recommended workout based on recovery
### 06-05: UI/UX Polish
- [ ] Integrate swap system with recommendation engine
- [ ] Show recovery timeline for each group
- [ ] Mobile-friendly recovery badges
- [ ] One-tap "Use Recommendation" button
- [ ] Visual feedback for muscle group selection
### 06-06: Testing & Validation
- [ ] E2E tests: Swap workflow
- [ ] E2E tests: Recovery calculation accuracy
- [ ] Performance: Recovery algorithm benchmarks
- [ ] User feedback: Recommendation quality validation
## 🏗️ Database Changes
```sql
-- Muscle Group Recovery Tracking
CREATE TABLE muscle_group_recovery (
id SERIAL PRIMARY KEY,
user_id INTEGER REFERENCES users(id),
muscle_group VARCHAR(50),
last_workout_date TIMESTAMP,
intensity FLOAT, -- 0-1
exercises_count INT,
created_at TIMESTAMP DEFAULT NOW()
);
-- Workout Swaps
ALTER TABLE workout_logs ADD COLUMN swapped_from_id INT REFERENCES workout_logs(id);
```
## 🔑 Key Algorithms
### Recovery Calculation
```
recovery_score = 1.0 if last_workout > 72h ago
recovery_score = 0.5 if 48h < last_workout < 72h
recovery_score = 0.2 if 24h < last_workout < 48h
recovery_score = 0.0 if last_workout < 24h
```
### Smart Recommendation
1. Get all exercises available
2. Group by muscle group
3. Calculate recovery for each group
4. Sort by recovery score (highest = best to train)
5. Filter: exclude groups with score < 0.3
6. Return: Top 3 workouts with best muscle group coverage
## 📦 Implementation Order
1. **06-01** — Basic swap functionality (UI + backend)
2. **06-02** — Recovery tracking (database + calculations)
3. **06-03** — Recommendation engine (backend algorithm)
4. **06-04** — Analytics & visualization (frontend)
5. **06-05** — Polish & integration
6. **06-06** — Testing
---
+9 -68
View File
@@ -1,70 +1,11 @@
{ {
"lastRun": "2026-03-03T21:25:00Z", "lastRun": "2026-03-06T12:34:00+01:00",
"status": "completed", "status": "in-progress",
"currentPhase": "08", "currentPhase": "06",
"task": "08-01: Health Monitoring & Logging Infrastructure", "currentTask": "06-01",
"result": "Structured logging (Winston) successfully integrated with console and file outputs. Enhanced health endpoint implemented with uptime tracking and database connectivity status. Request logging middleware added to all routes. Documentation completed in README.md with examples.", "taskName": "Workout Swap/Rotation System",
"commits": [ "result": "Phase 06 initialized - Starting Task 06-01: Workout Swap/Rotation System",
"e09017d - feat(08-01): Health monitoring & logging infrastructure" "unblocked": true,
], "nextAction": "Implement swap workout UI + backend API",
"deliverables": { "taskDescription": "Add 'Swap Workout' button to WorkoutPage. Show available workouts. Replace current workout while keeping tracking. Update UI to show swap history. Database: Update workout_logs to track swaps."
"structuredLogging": {
"status": "complete",
"implementation": "Winston logger with file rotation",
"outputs": ["logs/combined.log", "logs/error.log"],
"logLevels": ["debug", "info", "warn", "error"]
},
"healthEndpoint": {
"status": "complete",
"endpoint": "GET /api/health",
"fields": ["status", "uptime", "timestamp", "database.connected", "database.responseTime"],
"statusCodes": {
"healthy": 200,
"degraded": 200,
"unhealthy": 503
}
},
"requestLogging": {
"status": "complete",
"middleware": "requestLoggerMiddleware",
"fields": ["method", "path", "statusCode", "duration", "ip", "userAgent"]
},
"documentation": {
"status": "complete",
"location": "backend/README.md",
"sections": [
"Logging & Monitoring",
"Structured Logging (Winston)",
"Request Logging Middleware",
"Health Check API"
]
},
"testing": {
"status": "complete",
"testFile": "backend/test/health.test.js",
"coverage": ["health endpoint", "uptime tracking", "database error handling", "logging middleware"]
}
},
"implementation_details": {
"logger_module": "src/utils/logger.js",
"health_module": "src/utils/health.js",
"middleware": "src/middleware/requestLogger.js",
"winston_configuration": "console and file transports with rotation",
"request_logging_scope": "all HTTP requests",
"structured_logging_scope": "auth events, data modifications, errors"
},
"verification": {
"gitStatus": "clean",
"syntaxCheck": "passed",
"modules": ["logger.js", "health.js", "requestLogger.js"],
"endpointStatus": "operational"
},
"nextAction": "Phase 08-02: Database Backups & Recovery or continue with other Phase 08 tasks. Logging infrastructure is now production-ready.",
"notes": "All request and operation logging is now structured and persisted to files with rotation. Health endpoint provides real-time uptime and database metrics for deployment monitoring.",
"projectStatus": {
"phase": "08-01",
"completionPercent": "90%",
"deploymentReady": true,
"nextMilestone": "08-02: Database Backups or 08-03: Security Hardening"
}
} }