openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 0.1.0 description: Adaptive Learning Support App API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: auth description: Authentication - name: users description: User management - name: progress description: Learning progress - name: achievements description: Badges and achievements - name: rewards description: Stars, coins, XP - name: games description: Game scores and leaderboard - name: daily-challenge description: Daily challenge - name: dashboard description: Dashboard summaries - name: lessons description: Lessons and content paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" # AUTH /auth/me: get: operationId: getMe tags: [auth] summary: Get current user responses: "200": description: Current user content: application/json: schema: $ref: "#/components/schemas/User" "401": description: Not authenticated /auth/login: post: operationId: login tags: [auth] summary: Login with email and password requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LoginInput" responses: "200": description: Logged in content: application/json: schema: $ref: "#/components/schemas/User" "401": description: Invalid credentials /auth/register: post: operationId: register tags: [auth] summary: Register a new user requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RegisterInput" responses: "201": description: Registered content: application/json: schema: $ref: "#/components/schemas/User" /auth/firebase-session: post: operationId: firebaseSession tags: [auth] summary: Exchange a Firebase Authentication ID token for an app session requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/FirebaseSessionInput" responses: "200": description: Session established (existing user matched by Firebase uid or email) content: application/json: schema: $ref: "#/components/schemas/User" "201": description: Session established (new user created from Firebase account) content: application/json: schema: $ref: "#/components/schemas/User" "401": description: Invalid or expired Firebase ID token /auth/logout: post: operationId: logout tags: [auth] summary: Logout responses: "200": description: Logged out content: application/json: schema: $ref: "#/components/schemas/SuccessResponse" # USERS /users: get: operationId: listUsers tags: [users] summary: List all users (admin/teacher) parameters: - name: role in: query schema: type: string enum: [student, parent, teacher, admin] - name: page in: query schema: type: number default: 1 - name: limit in: query schema: type: number default: 20 responses: "200": description: List of users content: application/json: schema: $ref: "#/components/schemas/UserList" /users/{userId}: get: operationId: getUser tags: [users] summary: Get a user by ID parameters: - name: userId in: path required: true schema: type: number responses: "200": description: User content: application/json: schema: $ref: "#/components/schemas/User" "404": description: Not found patch: operationId: updateUser tags: [users] summary: Update user profile parameters: - name: userId in: path required: true schema: type: number requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UserUpdate" responses: "200": description: Updated user content: application/json: schema: $ref: "#/components/schemas/User" delete: operationId: deleteUser tags: [users] summary: Delete a user parameters: - name: userId in: path required: true schema: type: number responses: "200": description: Deleted content: application/json: schema: $ref: "#/components/schemas/SuccessResponse" # PROGRESS /progress/{userId}: get: operationId: getUserProgress tags: [progress] summary: Get learning progress for a user parameters: - name: userId in: path required: true schema: type: number responses: "200": description: User progress content: application/json: schema: $ref: "#/components/schemas/UserProgress" /progress/{userId}/lessons: get: operationId: listCompletedLessons tags: [progress] summary: Get completed lessons list parameters: - name: userId in: path required: true schema: type: number - name: subject in: query schema: type: string enum: [math, english, phonics] responses: "200": description: Lesson progress list content: application/json: schema: type: array items: $ref: "#/components/schemas/LessonProgress" /progress/record: post: operationId: recordProgress tags: [progress] summary: Record a lesson completion requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ProgressInput" responses: "201": description: Progress recorded content: application/json: schema: $ref: "#/components/schemas/LessonProgress" # ACHIEVEMENTS /achievements: get: operationId: listAchievements tags: [achievements] summary: List all possible achievements responses: "200": description: Achievements list content: application/json: schema: type: array items: $ref: "#/components/schemas/Achievement" /achievements/{userId}: get: operationId: getUserAchievements tags: [achievements] summary: Get achievements for a user parameters: - name: userId in: path required: true schema: type: number responses: "200": description: User achievements content: application/json: schema: type: array items: $ref: "#/components/schemas/UserAchievement" # REWARDS /rewards/{userId}: get: operationId: getUserRewards tags: [rewards] summary: Get rewards for a user parameters: - name: userId in: path required: true schema: type: number responses: "200": description: User rewards content: application/json: schema: $ref: "#/components/schemas/UserRewards" /rewards/award: post: operationId: awardRewards tags: [rewards] summary: Award stars, coins, XP to a user requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RewardInput" responses: "200": description: Updated rewards content: application/json: schema: $ref: "#/components/schemas/UserRewards" # GAMES /games/leaderboard: get: operationId: getLeaderboard tags: [games] summary: Get game leaderboard parameters: - name: game in: query required: true schema: type: string enum: [math-sprint, memory-match, word-builder, balloon-pop, treasure-hunt, shape-match, letter-match, sentence-builder, number-puzzle, picture-puzzle] - name: limit in: query schema: type: number default: 10 responses: "200": description: Leaderboard entries content: application/json: schema: type: array items: $ref: "#/components/schemas/LeaderboardEntry" /games/scores: post: operationId: submitScore tags: [games] summary: Submit a game score requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ScoreInput" responses: "201": description: Score submitted content: application/json: schema: $ref: "#/components/schemas/GameScore" /games/scores/{userId}: get: operationId: getUserScores tags: [games] summary: Get scores for a user parameters: - name: userId in: path required: true schema: type: number responses: "200": description: Game scores content: application/json: schema: type: array items: $ref: "#/components/schemas/GameScore" # DAILY CHALLENGE /daily-challenge/today: get: operationId: getTodayChallenge tags: [daily-challenge] summary: Get today's daily challenge responses: "200": description: Today's challenge content: application/json: schema: $ref: "#/components/schemas/DailyChallenge" /daily-challenge/submit: post: operationId: submitDailyChallenge tags: [daily-challenge] summary: Submit daily challenge answers requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/DailyChallengeSubmission" responses: "200": description: Challenge result content: application/json: schema: $ref: "#/components/schemas/DailyChallengeResult" /daily-challenge/status/{userId}: get: operationId: getDailyChallengeStatus tags: [daily-challenge] summary: Check if user completed today's challenge parameters: - name: userId in: path required: true schema: type: number responses: "200": description: Challenge status content: application/json: schema: $ref: "#/components/schemas/DailyChallengeStatus" # DASHBOARD SUMMARIES /dashboard/student/{userId}: get: operationId: getStudentDashboard tags: [dashboard] summary: Student dashboard summary parameters: - name: userId in: path required: true schema: type: number responses: "200": description: Student dashboard content: application/json: schema: $ref: "#/components/schemas/StudentDashboard" /dashboard/parent/{userId}: get: operationId: getParentDashboard tags: [dashboard] summary: Parent dashboard — progress of linked children parameters: - name: userId in: path required: true schema: type: number responses: "200": description: Parent dashboard content: application/json: schema: $ref: "#/components/schemas/ParentDashboard" /dashboard/teacher/{userId}: get: operationId: getTeacherDashboard tags: [dashboard] summary: Teacher dashboard — all students summary parameters: - name: userId in: path required: true schema: type: number responses: "200": description: Teacher dashboard content: application/json: schema: $ref: "#/components/schemas/TeacherDashboard" /dashboard/admin: get: operationId: getAdminDashboard tags: [dashboard] summary: Admin dashboard — platform-wide analytics responses: "200": description: Admin dashboard content: application/json: schema: $ref: "#/components/schemas/AdminDashboard" # WEEKLY / MONTHLY PROGRESS CHARTS /progress/{userId}/weekly: get: operationId: getWeeklyProgress tags: [progress] summary: Weekly learning activity chart data parameters: - name: userId in: path required: true schema: type: number responses: "200": description: Weekly progress data points content: application/json: schema: type: array items: $ref: "#/components/schemas/ProgressDataPoint" /progress/{userId}/subjects: get: operationId: getSubjectProgress tags: [progress] summary: Per-subject accuracy and completion breakdown parameters: - name: userId in: path required: true schema: type: number responses: "200": description: Subject progress breakdown content: application/json: schema: type: array items: $ref: "#/components/schemas/SubjectProgress" components: schemas: HealthStatus: type: object properties: status: type: string required: - status SuccessResponse: type: object properties: success: type: boolean message: type: string required: - success User: type: object properties: id: type: number email: type: string displayName: type: string role: type: string enum: [student, parent, teacher, admin] avatarUrl: type: ["string", "null"] gradeLevel: type: ["number", "null"] age: type: ["number", "null"] parentId: type: ["number", "null"] createdAt: type: string required: - id - email - displayName - role - createdAt UserList: type: object properties: users: type: array items: $ref: "#/components/schemas/User" total: type: number page: type: number limit: type: number required: - users - total - page - limit LoginInput: type: object properties: email: type: string password: type: string role: type: string enum: [student, parent, teacher, admin] required: - email - password RegisterInput: type: object properties: email: type: string password: type: string displayName: type: string role: type: string enum: [student, parent, teacher, admin] gradeLevel: type: number age: type: number required: - email - password - displayName - role FirebaseSessionInput: type: object properties: idToken: type: string description: The Firebase Authentication ID token from the frontend's signed-in user # Only used the first time a brand-new Firebase account signs in (no # matching user by firebaseUid or email yet). Ignored for existing users. displayName: type: string role: type: string enum: [student, parent, teacher, admin] gradeLevel: type: number age: type: number required: - idToken UserUpdate: type: object properties: displayName: type: string avatarUrl: type: string gradeLevel: type: number age: type: number UserProgress: type: object properties: userId: type: number totalLessonsCompleted: type: number totalTimeMinutes: type: number overallAccuracy: type: number currentStreak: type: number longestStreak: type: number level: type: number xp: type: number stars: type: number coins: type: number required: - userId - totalLessonsCompleted - totalTimeMinutes - overallAccuracy - currentStreak - longestStreak - level - xp - stars - coins LessonProgress: type: object properties: id: type: number userId: type: number subject: type: string enum: [math, english, phonics] lessonId: type: string lessonTitle: type: string score: type: number accuracy: type: number timeSpentMinutes: type: number completedAt: type: string required: - id - userId - subject - lessonId - lessonTitle - score - accuracy - timeSpentMinutes - completedAt ProgressInput: type: object properties: userId: type: number subject: type: string enum: [math, english, phonics] lessonId: type: string lessonTitle: type: string score: type: number accuracy: type: number timeSpentMinutes: type: number required: - userId - subject - lessonId - lessonTitle - score - accuracy - timeSpentMinutes ProgressDataPoint: type: object properties: date: type: string lessonsCompleted: type: number timeMinutes: type: number accuracy: type: number required: - date - lessonsCompleted - timeMinutes - accuracy SubjectProgress: type: object properties: subject: type: string enum: [math, english, phonics] lessonsCompleted: type: number totalLessons: type: number accuracy: type: number timeMinutes: type: number required: - subject - lessonsCompleted - totalLessons - accuracy - timeMinutes Achievement: type: object properties: id: type: string title: type: string description: type: string icon: type: string category: type: string enum: [math, english, phonics, games, streaks, general] xpReward: type: number coinsReward: type: number required: - id - title - description - icon - category - xpReward - coinsReward UserAchievement: type: object properties: achievement: $ref: "#/components/schemas/Achievement" unlockedAt: type: string required: - achievement - unlockedAt UserRewards: type: object properties: userId: type: number stars: type: number coins: type: number xp: type: number level: type: number xpToNextLevel: type: number unlockedAvatars: type: array items: type: string activeAvatar: type: string required: - userId - stars - coins - xp - level - xpToNextLevel - unlockedAvatars - activeAvatar RewardInput: type: object properties: userId: type: number stars: type: number coins: type: number xp: type: number reason: type: string required: - userId GameScore: type: object properties: id: type: number userId: type: number displayName: type: string game: type: string score: type: number coinsEarned: type: number starsEarned: type: number playedAt: type: string required: - id - userId - displayName - game - score - coinsEarned - starsEarned - playedAt LeaderboardEntry: type: object properties: rank: type: number userId: type: number displayName: type: string avatarUrl: type: ["string", "null"] score: type: number playedAt: type: string required: - rank - userId - displayName - score - playedAt ScoreInput: type: object properties: userId: type: number game: type: string enum: [math-sprint, memory-match, word-builder, balloon-pop, treasure-hunt, shape-match, letter-match, sentence-builder, number-puzzle, picture-puzzle] score: type: number coinsEarned: type: number starsEarned: type: number required: - userId - game - score - coinsEarned - starsEarned DailyChallenge: type: object properties: date: type: string mathQuestions: type: array items: $ref: "#/components/schemas/ChallengeQuestion" englishQuestions: type: array items: $ref: "#/components/schemas/ChallengeQuestion" phonicsQuestions: type: array items: $ref: "#/components/schemas/ChallengeQuestion" required: - date - mathQuestions - englishQuestions - phonicsQuestions ChallengeQuestion: type: object properties: id: type: string subject: type: string enum: [math, english, phonics] question: type: string options: type: array items: type: string correctAnswer: type: string hint: type: string required: - id - subject - question - options - correctAnswer - hint DailyChallengeSubmission: type: object properties: userId: type: number date: type: string answers: type: array items: $ref: "#/components/schemas/ChallengeAnswer" required: - userId - date - answers ChallengeAnswer: type: object properties: questionId: type: string answer: type: string required: - questionId - answer DailyChallengeResult: type: object properties: totalCorrect: type: number totalQuestions: type: number earnedBadge: type: boolean coinsEarned: type: number starsEarned: type: number xpEarned: type: number required: - totalCorrect - totalQuestions - earnedBadge - coinsEarned - starsEarned - xpEarned DailyChallengeStatus: type: object properties: userId: type: number date: type: string completed: type: boolean score: type: ["number", "null"] earnedBadge: type: boolean required: - userId - date - completed - earnedBadge StudentDashboard: type: object properties: user: $ref: "#/components/schemas/User" rewards: $ref: "#/components/schemas/UserRewards" recentProgress: type: array items: $ref: "#/components/schemas/LessonProgress" subjectBreakdown: type: array items: $ref: "#/components/schemas/SubjectProgress" recentAchievements: type: array items: $ref: "#/components/schemas/UserAchievement" dailyChallengeCompleted: type: boolean weeklyStreak: type: number required: - user - rewards - recentProgress - subjectBreakdown - recentAchievements - dailyChallengeCompleted - weeklyStreak ParentDashboard: type: object properties: children: type: array items: $ref: "#/components/schemas/ChildSummary" weeklyActivity: type: array items: $ref: "#/components/schemas/ProgressDataPoint" required: - children - weeklyActivity ChildSummary: type: object properties: user: $ref: "#/components/schemas/User" progress: $ref: "#/components/schemas/UserProgress" recentLessons: type: array items: $ref: "#/components/schemas/LessonProgress" subjectBreakdown: type: array items: $ref: "#/components/schemas/SubjectProgress" required: - user - progress - recentLessons - subjectBreakdown TeacherDashboard: type: object properties: totalStudents: type: number avgAccuracy: type: number activeToday: type: number topPerformers: type: array items: $ref: "#/components/schemas/StudentSummary" studentsNeedingHelp: type: array items: $ref: "#/components/schemas/StudentSummary" subjectStats: type: array items: $ref: "#/components/schemas/SubjectStats" required: - totalStudents - avgAccuracy - activeToday - topPerformers - studentsNeedingHelp - subjectStats StudentSummary: type: object properties: user: $ref: "#/components/schemas/User" accuracy: type: number lessonsCompleted: type: number lastActive: type: string required: - user - accuracy - lessonsCompleted - lastActive SubjectStats: type: object properties: subject: type: string avgAccuracy: type: number totalLessonsCompleted: type: number required: - subject - avgAccuracy - totalLessonsCompleted AdminDashboard: type: object properties: totalStudents: type: number totalTeachers: type: number totalParents: type: number activeToday: type: number totalLessonsCompleted: type: number avgAccuracy: type: number topGames: type: array items: $ref: "#/components/schemas/GameStats" registrationsThisWeek: type: number required: - totalStudents - totalTeachers - totalParents - activeToday - totalLessonsCompleted - avgAccuracy - topGames - registrationsThisWeek GameStats: type: object properties: game: type: string timesPlayed: type: number avgScore: type: number required: - game - timesPlayed - avgScore