COMPLETED TASKS:
✅ 06-01: Workout Swap System
- Added swapped_from_id to workout_logs
- Created workout_swaps table for history
- POST /api/workouts/:id/swap endpoint
- GET /api/workouts/available endpoint
- Reversible swaps with audit trail
✅ 06-02: Muscle Group Recovery Tracking
- Created muscle_group_recovery table
- Implemented calculateRecoveryScore() function
- GET /api/recovery/muscle-groups endpoint
- GET /api/recovery/most-recovered endpoint
- Auto-tracking on workout log completion
✅ 06-03: Smart Workout Recommendations
- GET /api/recommendations/smart-workout endpoint
- 7-day workout analysis algorithm
- Recovery-based filtering (>30% threshold)
- Top 3 recommendations with context
- Context-aware reasoning messages
DATABASE CHANGES:
- Added 4 new tables: muscle_group_recovery, workout_swaps, custom_workouts, custom_workout_exercises
- Extended workout_logs with: swapped_from_id, source_type, custom_workout_id, custom_workout_exercise_id
- Created 7 new indexes for performance
IMPLEMENTATION:
- Recovery service with 4 core functions
- 2 new route handlers (recovery, smartRecommendations)
- Updated workouts router with swap endpoints
- Integrated recovery tracking into POST /api/logs
- Full error handling and logging
TESTING:
- Test file created: /backend/test/phase-06-tests.js
- Ready for E2E and staging validation
STATUS: Ready for frontend integration and production review
Branch: feature/06-phase-06
- Set up Winston structured logging with console and file outputs
- Create GET /api/health endpoint with uptime, database status, response times
- Add request logging middleware (method, path, statusCode, duration)
- Create health monitoring module with database connectivity checks
- Log all HTTP requests with timing information
- Log auth events (login, register) and data modifications
- Replace console.log/error with structured logger calls
- Update backend README with logging configuration documentation
- Add tests for health endpoint and logging middleware
- Logs directory: logs/combined.log and logs/error.log
Deliverables met:
✓ Structured logging (Winston) integrated
✓ Enhanced health endpoint with uptime & database info
✓ Request logging middleware attached to all routes
✓ Comprehensive logging documentation in README.md
✓ Tests passing for health and logging functionality
✓ All critical operations logged with context
- Enhanced exaSearch service with Exa API + fallback tier system
* Tier 1: Exa API (primary)
* Tier 2: Synthetic results with suggested web sources
* Improved error handling with graceful degradation
- Updated backend exerciseResearch route to return provider info
* Returns 'provider' field identifying which API was used
* Returns 'status' field (success/degraded) for UI feedback
* Better error messages for debugging
- Enhanced ResearchDisplay component with fallback feedback
* New ResearchProviderBadge shows which provider was used
* Visual indicators for fallback results (Suggested badge)
* Support for multiple provider types (exa, fallback, gemini, etc.)
* Improved error handling and recovery flows
- Updated ExerciseResearchPanel with better error handling
* Proper response parsing from backend
* Forwards provider and status info to display component
* Improved accessibility with tooltip hints
- Added comprehensive Research Display styling
* Responsive layout for mobile and desktop
* Visual hierarchy for summaries and sources
* Provider badge styling with color-coding
* Fallback state indicators for user awareness
- ExerciseResearchPanel: add ProviderBadge component showing which AI
tier (Ollama/Gemini/OpenRouter/OpenCode/Exa) served the response
- Add auto-retry on 429/503 with 2s delay and retry counter in button
- Normalize error messages for common failure modes (network, rate-limit)
- ResearchDisplay: pass onRetry prop to error state for inline retry button
- CSS: .research-panel-controls flex row, .provider-badge with per-provider
colour coding, .rd-error-actions + .rd-retry button styles
- Add ResearchDisplay.jsx: pure presentational component for research
data with loading skeleton, accessible error state, and source cards
- Refactor ExerciseResearchPanel to delegate rendering to ResearchDisplay
(separates fetch/state logic from display)
- Add ExerciseEncyclopediaPage.css: full dark-theme stylesheet using
CSS variables (--bg-*, --text-*, --accent, --border, --radius-*)
replacing the light-theme WorkoutEditPage.css import
- Update ExerciseEncyclopediaPage.jsx: new semantic class names,
keyboard-accessible card toggle (Enter key + role=button + aria-expanded)
- Mobile-responsive at 600px breakpoint
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add ExerciseResearchPanel component with Get Research button, loading state, summary display, and source links
- Add ExerciseEncyclopediaPage with exercise list and integrated research panel
- Wire encyclopedia view into App.jsx navigation
- Add encyclopedia nav button to Dashboard
- Add CSS for research panel and encyclopedia search
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Created 04-06-PLAN.md outlining persistence improvements phases
- Phase 04-06-01: Draft persistence via localStorage
- Added useDraftWorkout hook for auto-saving/loading drafts
- Integrated hook into WorkoutEditPage
- Added draft recovery prompt UI
- Drafts cleared after successful save
- Phase 04-06-02: Save error handling & retry (scaffolding)
- Added error state and syncStatus tracking
- Added handleRetry() for failed saves
- Error banner with retry button
- Phase 04-06-03: Sync status UI (scaffolding)
- Added visual feedback for save progress
- Status indicators: saving, saved, error
- Disabled UI during save to prevent conflicts
- Created comprehensive styles for new UI components
Status: 04-06-01 complete and integrated. Ready for testing.
- Fetch custom workouts for authenticated user
- Display 'Anpassad' (custom) or 'Program' badge on each workout card
- Add badge component with orange accent for custom, muted color for program
- Badge positioned bottom-right of workout icon
- Responsive styling consistent with Gravl dark theme
- All build checks pass
- Added deleteLog function in App.jsx: calls DELETE /api/logs and removes entry from local logs state
- Passed onDeleteSet={deleteLog} to WorkoutPage in workout view render
- Updated WorkoutPage function signature to accept onDeleteSet prop
- Passed onDeleteSet through to each ExerciseCard (ExerciseCard already calls it in handleDeleteSet)
- Non-logged sets (404 from backend) silently ignored via catch block
- Replace fixed setInputs object with setList array state
- Add showAddModal state and set-type chooser modal (Vanligt set / Dropset)
- handleAddNormal: append one set pre-filled from last row's weight and reps
- handleAddDropset: append 3 sets at 100%/80%/60% weight (rounded to 2.5kg), 10 reps
- handleDeleteSet: remove by index with last-set guard (no delete when only 1 remains)
- handleComplete and handleInputChange updated to use array index (idx+1 as set_number)
- Progress badge and all-done class use setList.length instead of exercise.sets
- onDeleteSet prop added (optional stub for backend wiring in plan 02)
- Add trash icon SVG to Icons.jsx (outline trash can, consistent with icon library)
- Import WeightInput and RepsInput in WorkoutPage.jsx
- Replace bare <input type="number"> elements with stepper components
- Update .set-inputs alignment to flex-start for taller steppers
- Update .set-row alignment to flex-start
- Remove now-redundant .weight-input and .reps-input CSS rules (main + mobile)
CSS:
- Dark background (#0a0a0f, #0d0d12, #15151b)
- Orange accent (#ff6b35)
- Muted text (#a1a1aa, #71717a)
- Inter font from Google Fonts
- Workout type colors (push/pull/legs/etc)
Dashboard:
- Calendar dots are CSS circles, not emoji
- Coach avatar uses SVG icon
- All emojis replaced with Icons.jsx SVGs
- Navigation uses proper icons
WorkoutPage:
- Warmup exercises without emojis
- Check icons instead of emoji checkmarks
- Arrow icons for navigation
- Fire icon for warmup section
Professional fitness app aesthetic inspired by Nike/FITBOD
TODO: Comprehensive design plan for fitness app feel
- Dark theme color palette
- Professional typography guidelines
- SVG icons to replace ALL emojis
- UI component standards
- Inspiration from Nike/FITBOD/Strong
Partial work from Claude Code:
- Icons.jsx component (SVG icons)
- Dashboard.jsx updates (some emoji removal)
- 'Välj pass' section with all available workouts
- Compact workout cards with exercise tags
- Click any workout → WorkoutPage
- No more 'Vilodag' - user can always pick a workout
- Dedicated workout page with progress tracking
- Warmup section with general + muscle-specific exercises
- Preparatory sets (2x10 @ 50% of first exercise)
- Checkbox tracking for warmup completion
- Progress bar showing completed exercises
- Animated 'Finish workout' button when done
- Mobile-first CSS with responsive design
Built by Claude Code 2.1.29
ProfilePage:
- View/edit user info (name, age, height, goal, level)
- Show current measurements (weight, body fat, waist, neck)
- Show strength records (bench/squat/deadlift 1RM)
ProgressPage:
- Tab navigation (weight, body fat, strength)
- SVG line charts for progress visualization
- Stats showing current, first, and change
- Trend indicators (up/down)
Dashboard:
- Navigation icons for profile (👤) and progress (📊)
- Connected navigation to App.jsx routing
- Dashboard.jsx: main landing page after login
- Coach greeting based on time of day
- Weekly calendar showing workout days
- Today's workout card with exercises
- Quick stats (workouts/week, streak)
- Upcoming workouts list
- Full responsive CSS
- App.jsx updated to show Dashboard first
- Ny databasstruktur för historik/progress tracking
- Nya endpoints: POST/GET measurements och strength
- Onboarding sparar till rätt tabeller
- Beräknar och sparar body_fat_pct
- Fixar tomma numeriska fält (null istället för '')
- Döljer 1RM för nybörjare