📘 Issue Description
Create a comprehensive badges and achievements system that recognizes user milestones, learning progression, and engagement patterns. This system builds on the XP and streak tracking infrastructure to award meaningful achievements that celebrate user accomplishments and encourage continued engagement.
🔍 Steps
Database & Models
-
Create Achievement Models
- Create
Achievement model with categories, requirements, and rewards
- Create
UserAchievement model to track earned badges
- Define achievement types: XP milestones, streaks, learning, special events
-
Seed Achievement Data
- Create achievement definitions with requirements and rewards
- Organize by categories: Progress, Streaks, Mastery, Special
- Include XP bonuses and badge assets for each achievement
Core Services
-
Create Achievement Service
- Create
src/services/achievement.service.ts
- Check user progress against achievement requirements
- Award achievements and bonus XP automatically
- Track achievement progress and completion
-
Create Badge Service
- Create
src/services/badge.service.ts
- Manage badge display and metadata
- Handle badge notifications and celebrations
- Generate achievement certificates/summaries
Integration & Logic
-
Integrate Achievement Checking
- Add achievement checks to XP awarding flow
- Check achievements on streak updates
- Trigger achievement evaluation on question completion
- Send achievement notifications via email
-
Create Achievement Controller
- Create
src/controllers/achievement.controller.ts
- User achievement history and badge collection
- Achievement progress tracking endpoints
- Leaderboards for specific achievements
-
Create Routes
- Create
src/routes/api/modules/achievement.routes.ts
- Achievement catalog and user progress endpoints
- Badge showcase and sharing functionality
✅ Acceptance Criteria
Achievement Categories & Examples
🏆 Progress Achievements
- "First Steps" - Complete your first question (50 XP bonus)
- "Getting Warmed Up" - Earn 100 total XP (100 XP bonus)
- "Learning Machine" - Earn 1,000 total XP (300 XP bonus)
- "Knowledge Seeker" - Earn 5,000 total XP (500 XP bonus)
- "English Master" - Earn 10,000 total XP (1000 XP bonus)
🔥 Streak Achievements
- "Consistent Learner" - 3-day streak (75 XP bonus)
- "Dedicated Student" - 7-day streak (200 XP bonus)
- "Unstoppable Force" - 15-day streak (500 XP bonus)
- "Learning Legend" - 30-day streak (1000 XP bonus)
- "Streak Master" - 100-day streak (2500 XP bonus)
🎯 Mastery Achievements
- "Perfect Score" - Get 10 questions correct in a row (150 XP bonus)
- "Speed Demon" - Complete 20 questions with time bonus (200 XP bonus)
- "Level Conqueror" - Complete 50 questions at each level A1-C2
- "Grammar Guru" - Complete 100 grammar questions (300 XP bonus)
- "Vocabulary Virtuoso" - Complete 100 vocabulary questions (300 XP bonus)
⭐ Special Achievements
- "Early Adopter" - Join Aurora in first month (500 XP bonus)
- "Weekend Warrior" - Complete lessons on 10 weekends (250 XP bonus)
- "Night Owl" - Complete 20 lessons after 10 PM (200 XP bonus)
- "Social Learner" - Refer 3 friends who complete 10 questions (1000 XP bonus)
API Specification
Endpoint: GET /api/v1/achievements/user
Headers:
Authorization: Bearer <jwt_token>
Success Response (200):
{
"success": true,
"data": {
"earned": [
{
"id": "uuid",
"name": "First Steps",
"description": "Complete your first question",
"category": "progress",
"earnedAt": "2024-01-15T10:30:00Z",
"xpBonus": 50,
"badgeUrl": "/badges/first-steps.svg"
}
],
"inProgress": [
{
"id": "uuid",
"name": "Learning Machine",
"description": "Earn 1,000 total XP",
"category": "progress",
"currentProgress": 450,
"requirement": 1000,
"progressPercentage": 45
}
],
"summary": {
"totalEarned": 5,
"totalBonusXP": 750,
"favoriteCategory": "streak"
}
}
}
Achievement Catalog: GET /api/v1/achievements/catalog
{
"success": true,
"data": {
"categories": {
"progress": [
{
"id": "uuid",
"name": "First Steps",
"description": "Complete your first question",
"requirement": "Complete 1 question",
"xpBonus": 50,
"rarity": "common"
}
],
"streak": [...],
"mastery": [...],
"special": [...]
}
}
}
🌎 References
- XP and streak system from previous gamification implementation
- User model with XP tracking fields
- Existing question completion flow in
src/controllers/question.controller.ts
- Email notification system in
src/utils/service/emailNotifier.ts
📜 Additional Notes
Database Schema
-- Achievement definitions
CREATE TABLE achievements (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name VARCHAR(100) NOT NULL,
description TEXT,
category VARCHAR(50),
requirement_type VARCHAR(50), -- 'xp_total', 'streak_days', 'questions_correct', etc.
requirement_value INTEGER,
xp_bonus INTEGER DEFAULT 0,
badge_url VARCHAR(255),
rarity VARCHAR(20) DEFAULT 'common', -- common, rare, epic, legendary
is_active BOOLEAN DEFAULT true,
created_at TIMESTAMP DEFAULT NOW()
);
-- User achievements
CREATE TABLE user_achievements (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID REFERENCES users(id),
achievement_id UUID REFERENCES achievements(id),
earned_at TIMESTAMP DEFAULT NOW(),
progress_value INTEGER DEFAULT 0,
is_notified BOOLEAN DEFAULT false,
UNIQUE(user_id, achievement_id)
);
Achievement Checking Logic
// Trigger points for achievement checks
1. After XP is awarded (check XP milestones)
2. After streak is updated (check streak achievements)
3. After question completion (check mastery achievements)
4. Daily CRON job (check time-based achievements)
Integration Points
- Build on existing XP service from gamification system
- Use current streak tracking infrastructure
- Leverage existing email notification system
- Follow authentication patterns for user-specific data
- Use existing question metadata for mastery achievements
Email Notifications
🎉 Congratulations! You've earned the "Learning Machine" badge!
You've reached 1,000 total XP - keep up the amazing progress!
Bonus: +300 XP added to your account
📘 Issue Description
Create a comprehensive badges and achievements system that recognizes user milestones, learning progression, and engagement patterns. This system builds on the XP and streak tracking infrastructure to award meaningful achievements that celebrate user accomplishments and encourage continued engagement.
🔍 Steps
Database & Models
Create Achievement Models
Achievementmodel with categories, requirements, and rewardsUserAchievementmodel to track earned badgesSeed Achievement Data
Core Services
Create Achievement Service
src/services/achievement.service.tsCreate Badge Service
src/services/badge.service.tsIntegration & Logic
Integrate Achievement Checking
Create Achievement Controller
src/controllers/achievement.controller.tsCreate Routes
src/routes/api/modules/achievement.routes.ts✅ Acceptance Criteria
Achievement Categories & Examples
🏆 Progress Achievements
🔥 Streak Achievements
🎯 Mastery Achievements
⭐ Special Achievements
API Specification
Endpoint:
GET /api/v1/achievements/userHeaders:
Authorization:
Bearer <jwt_token>Success Response (200):
{ "success": true, "data": { "earned": [ { "id": "uuid", "name": "First Steps", "description": "Complete your first question", "category": "progress", "earnedAt": "2024-01-15T10:30:00Z", "xpBonus": 50, "badgeUrl": "/badges/first-steps.svg" } ], "inProgress": [ { "id": "uuid", "name": "Learning Machine", "description": "Earn 1,000 total XP", "category": "progress", "currentProgress": 450, "requirement": 1000, "progressPercentage": 45 } ], "summary": { "totalEarned": 5, "totalBonusXP": 750, "favoriteCategory": "streak" } } }Achievement Catalog:
GET /api/v1/achievements/catalog{ "success": true, "data": { "categories": { "progress": [ { "id": "uuid", "name": "First Steps", "description": "Complete your first question", "requirement": "Complete 1 question", "xpBonus": 50, "rarity": "common" } ], "streak": [...], "mastery": [...], "special": [...] } } }🌎 References
src/controllers/question.controller.tssrc/utils/service/emailNotifier.ts📜 Additional Notes
Database Schema
Achievement Checking Logic
Integration Points
Email Notifications