Gamification Database Schema
Status: ✅ Complete
Last Updated: 2026-08-18
Overview
Gamification schema, services, API routes, and the Character / Combat / Progression UI (tabs, shop, inventory, achievements, house, banking, fighter profiles). See Idle Fighter, Banking, and Fighter profiles.
Database Models
Core Models
- ✅ UserGamification Model - Level, XP, total XP, coins, lastLoginDate
- ✅ Achievement Model - Global/user-specific achievements, types, rarity, rewards
- ✅ UserAchievement Model - Junction table for user achievement progress and unlocks
- ✅ UserStreak Model - Streak types, current/longest streaks, lastDate, frozen flag
- ✅ ShopItem Model - Global/user-specific items, pricing, rarity, category
- ✅ UserInventoryItem Model - Owned items, quantity, equipped status
- ✅ XpHistory Model - Tracking all XP gains with source and multiplier
Backend Services
GamificationService
- ✅ Core service with XP calculation, streak tracking, achievement checking, level progression
- ✅ 19 unit tests passing (comprehensive coverage)
API Routes
- ✅
/api/gamification/stats- Get user gamification stats - ✅
/api/gamification/xp- Track XP gains - ✅
/api/gamification/streak- Manage streaks - ✅
/api/gamification/login- Track daily login - ✅ 15 integration tests passing
Service Integrations
All core services integrated with gamification:
- ✅ ChecklistService - Awards XP and updates streaks when checklist items completed, perfect day bonus
- ✅ TaskService - Awards XP when tasks completed
- ✅ PerimeterService - Awards XP and updates streak when perimeter tasks completed
- ✅ TrainingService - Awards XP 100-500 based on sessionRPE, updates training consistency streak
- ✅ JournalService - Awards XP and updates journaling streak when entries created
- ✅ ReadingSessionService - Awards XP based on pages read, updates reading streak
- ✅ Login Integration - Login route calls
gamification.trackLoginfor daily login streaks and bonuses - ✅ TransactionService - Awards 5 XP + 1 coin when user logs a transaction (finance ↔ gamification)
- ✅ BankingService - Banking skill: save coins (earn 1% daily interest), bet on market (UP/DOWN). Awards banking skill XP on deposit and bet. Market ticks daily (resolve bets, apply interest).
- ✅ Finance achievements - FinanceAchievementService checks and unlocks achievements for: first/10/50/100 transactions, first budget, under budget month, first savings goal, 3 savings goals. Wired from TransactionService, BudgetService, SavingsGoalService, FinancialAnalyticsService (alerts).
- ✅ 11 comprehensive integration tests covering all service integrations
Frontend Implementation
Core UI
- ✅ TodayPage shows level, XP bar, coins, login streak in header
- ✅ Character page (redesigned with card-based layout)
- ✅ Character page component refactoring (7 reusable components)
Modals
- ✅ Modal component (reusable with keyboard support, click-outside-to-close, body scroll lock)
- ✅ Inventory Modal
- ✅ Shop Modal (updates coins after purchase)
- ✅ Achievements Modal
- ✅ XP History Modal (pagination support)
- ✅ Challenges Modal
- ✅ House Modal
- ✅ Collections Modal
- ✅ Seasonal Events Modal
Shop & Inventory
- ✅ Shop purchase functionality (service method, route endpoint, comprehensive tests)
- ✅ Inventory equip/unequip (connected to character endpoints)
- ✅ Room furniture placement (RoomDetailPage, house service endpoints)
Navigation
- ✅ Navigation menu simplified (Character direct link, modals accessible from Character page)
Related UI lives on Character, Combat, and Progression hubs — not a pending frontend.