This implementation transforms the System Status page from a mock RPG interface into a fully functional, data-driven training tracker that calculates real stats from actual workout logs.
- All stats (STR, END, REC, CON, MOB) calculated from real workout data
- XP earned based on actual volume lifted and training duration
- No hardcoded values or manual stat editing
- 6 PostgreSQL functions handle all stat calculations
- Database triggers automatically update XP on session completion
- All logic runs with Row Level Security (RLS)
- XP Formula:
(total_volume / 100) + (session_duration × 0.5) - XP only granted when session is completed (INSERT), not on edits
- Level up system: XP Required = 100 × current_level
- Remaining XP carries over after leveling up
PlayerStatusPanel:
- Shows real level and XP from profile
- Displays calculated STR, END, REC, CON stats
- Shows total workouts, XP earned, and training hours
RadarChart:
- 5-axis radar with real metrics: STR, END, MOB, REC, CON
- Visual balance overview updated from database
- Health bar shows system balance
SkillPointsPanel:
- Skill Points = total_XP / 10 (informational only)
- Bar chart of last 30 days activity
- Health bar from balance calculation
CalendarPanel:
- Shows actual training days from database
- Month navigation with accurate session counts
- Total XP and session statistics
GoalPanel:
- Displays user-defined goals from training_goals table
- Progress bars calculated from current vs target values
- Week activity visualization from recent sessions
PotionsPanel:
- Behavior patterns calculated from training habits
- Rest days, consistency streaks, deload weeks
- Generated automatically, not consumable items
Supabase PostgreSQL Functions:
├── calculate_user_stats(user_id) → Returns all 6 stats
├── calculate_strength_stat(user_id) → STR calculation
├── calculate_endurance_stat(user_id) → END calculation
├── calculate_recovery_stat(user_id) → REC calculation
├── calculate_consistency_stat(user_id) → CON calculation
├── calculate_mobility_stat(user_id) → MOB calculation
├── calculate_session_xp(session_id) → XP for session
├── update_profile_after_session() → Trigger function
├── get_training_calendar(user_id, year, month) → Calendar data
└── calculate_behavior_patterns(user_id) → Potion counts
React Hooks:
├── useStats() → Fetches calculated stats from database
├── useProfile() → Gets user profile (level, xp, goals)
└── useWorkoutSessions() → Manages workout CRUD operations
System Status Page:
├── PlayerStatusPanel (Left) → Level, XP, Core Stats
├── RadarChart (Center) → Visual balance, Health
├── SkillPointsPanel (Right) → Skill points, Activity chart
├── CalendarPanel (Bottom Left) → Training calendar
├── GoalPanel (Bottom Right) → Goals progress
└── PotionsPanel (Bottom Full Width) → Behavior patterns
STR = min(100, 30 + sessions×2 + floor(total_volume/1000))
END = min(100, 25 + hours×3 + floor(total_reps/100))
REC = max(0, min(100, 50 + bonus - penalty))
Where:
bonus = +20 for 3-4 sessions/week, +10 for 2-5 sessions/week
penalty = -10 per session over 5/week, -5 per day inactive over 7 days
CON = min(100, floor((sessions_last_30_days / 12) × 100))
MOB = min(100, 30 + unique_exercises×2 + total_sessions)
Health = floor((REC + END + CON) / 3)
src/hooks/useStats.ts- Hook to fetch calculated statssupabase/migrations/20260119110000_add_stat_calculations.sql- Stat functionssupabase/migrations/20260119110100_update_xp_calculation.sql- XP formulaSYSTEM_STATUS_TECHNICAL_DOCS.md- Technical documentationSYSTEM_STATUS_USER_GUIDE.md- User guideTESTING_GUIDE.md- Testing scenarios
src/components/system/PlayerStatusPanel.tsx- Use real calculated statssrc/components/system/RadarChart.tsx- Fetch and display real metricssrc/components/system/SkillPointsPanel.tsx- Real skill points and activitysrc/components/system/CalendarPanel.tsx- Real training calendarsrc/components/system/GoalPanel.tsx- Automatic progress calculationsrc/components/system/PotionsPanel.tsx- Behavior pattern displaysrc/pages/Index.tsx- Remove hardcoded radar dataREADME.md- Add features section and documentation links
20260119064145 (Profiles, Goals, Preferences)
↓
20260119065541 (Profile helper function)
↓
20260119070601 (Workout sessions, exercises, sets, XP trigger)
↓
20260119094000 (Weight column rename)
↓
20260119110000 (Stat calculation functions)
↓
20260119110100 (Updated XP formula)
Important: Migrations must be run in this exact order!
- All stats derived from actual workout logs
- No hardcoded values in UI components
- No manual stat editing allowed
- All formulas in PostgreSQL functions
- Client is read-only for stats
- Security through RLS policies
- Trigger fires on INSERT to workout_sessions
- Editing workouts does NOT grant XP
- Prevents gaming the system
- Recovery penalizes overtraining
- Consistency rewards regular training
- Health shows overall balance
- RPG-style UI makes training feel like a game
- Visual feedback (radar, bars, calendar)
- Behavior patterns as "rewards"
- Build successful (no TypeScript errors)
- Lint warnings fixed
- All components compile correctly
- Documentation complete
- Functional testing requires live database
- Run all migrations in order
- Follow TESTING_GUIDE.md for scenarios
These were NOT part of the requirements but could be added:
- Exercise-specific progression tracking
- Personal records (PRs) system
- Weekly/monthly trend charts
- Period comparisons
- Achievement badges system
- Social features / leaderboards
This implementation succeeds because:
- ✅ Zero fake numbers - everything derived from real data
- ✅ Zero manual stat editing - all calculated automatically
- ✅ Zero pay-to-progress - no premium boosts or purchases
- ✅ XP only on completion - editing doesn't grant XP
- ✅ Server-side logic - client is just a renderer
- ✅ Balanced system - Recovery prevents overtraining reward
- ✅ Psychologically motivating - RPG feel with real progress
All aspects are fully documented:
- ✅ Technical formulas and calculations
- ✅ User guide for understanding stats
- ✅ Testing guide with 12 test scenarios
- ✅ Migration order and dependencies
- ✅ Database function descriptions
- ✅ Component architecture
- ✅ Update rules and triggers
The System Status page is now a complete, data-driven training tracker that:
- Observes real effort over time
- Does not lie or cheat
- Does not rush progression
- Rewards consistency and balance
- Makes training feel like an RPG adventure
"The system observes effort over time. It does not lie. It does not rush."