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: API specification servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: course description: Course content (weeks, lectures, topics) - name: assignments description: Homeworks, tests, midterm, final - name: practice description: Infinite practice sessions and adaptive problem generation - name: tutor description: AI tutor chat - name: detection description: AI-generation and diachronic detection - name: analytics description: User performance analytics and reports paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /course/overview: get: operationId: getCourseOverview tags: [course] summary: Course-level overview with weeks, assignments, and progress responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/CourseOverview" /course/weeks/{weekNumber}: get: operationId: getWeek tags: [course] summary: Get one week's lectures and assignment list parameters: - name: weekNumber in: path required: true schema: { type: integer, minimum: 1, maximum: 4 } responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Week" /course/lectures/{lectureId}: get: operationId: getLecture tags: [course] summary: Get the full lecture text for a topic parameters: - name: lectureId in: path required: true schema: { type: integer } responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Lecture" /course/topics: get: operationId: listTopics tags: [course] summary: List all course topics (used for analytics + tutor scoping) responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/Topic" /assignments: get: operationId: listAssignments tags: [assignments] summary: List all assignments (homeworks, tests, midterm, final) responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/AssignmentSummary" /assignments/{assignmentId}: get: operationId: getAssignment tags: [assignments] summary: Get an assignment with its problems parameters: - name: assignmentId in: path required: true schema: { type: integer } responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Assignment" /assignments/{assignmentId}/start: post: operationId: startAssignmentAttempt tags: [assignments] summary: Start (or resume) an attempt on an assignment parameters: - name: assignmentId in: path required: true schema: { type: integer } responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/AttemptState" /assignments/attempts/{attemptId}: get: operationId: getAttempt tags: [assignments] summary: Get current attempt state (answers, time remaining) parameters: - name: attemptId in: path required: true schema: { type: integer } responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/AttemptState" /assignments/attempts/{attemptId}/answer: put: operationId: saveAnswer tags: [assignments] summary: Save (or update) a single answer with keystroke trace parameters: - name: attemptId in: path required: true schema: { type: integer } requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AnswerInput" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/AnswerSaved" /assignments/attempts/{attemptId}/submit: post: operationId: submitAttempt tags: [assignments] summary: Submit the attempt for grading (also runs AI + diachronic detection) parameters: - name: attemptId in: path required: true schema: { type: integer } responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/AttemptResult" /assignments/attempts/{attemptId}/reanalyze: post: operationId: reanalyzeAttempt tags: [assignments] summary: Re-read a submitted attempt's answers through a chosen lens (ephemeral preview; not persisted) parameters: - name: attemptId in: path required: true schema: { type: integer } requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ReanalyzeInput" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/ReanalyzeResult" /assignments/attempts/{attemptId}/problems/{problemId}/rebuttals: get: operationId: listRebuttals tags: [assignments] summary: List the back-and-forth where the student pushed back on a problem's feedback parameters: - name: attemptId in: path required: true schema: { type: integer } - name: problemId in: path required: true schema: { type: integer } responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/RebuttalThread" post: operationId: addRebuttal tags: [assignments] summary: Push back on the app's reading of an answer; the app reconsiders (and may revise) parameters: - name: attemptId in: path required: true schema: { type: integer } - name: problemId in: path required: true schema: { type: integer } requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RebuttalInput" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Rebuttal" /practice/sessions: post: operationId: startPracticeSession tags: [practice] summary: Start a new practice session (infinite, adaptive) requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PracticeSessionInput" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/PracticeSession" /practice/sessions/{sessionId}/next: post: operationId: nextPracticeProblem tags: [practice] summary: Generate the next problem (adaptive difficulty, de-novo) parameters: - name: sessionId in: path required: true schema: { type: integer } requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/NextProblemInput" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/PracticeProblem" /practice/sessions/{sessionId}/grade: post: operationId: gradePracticeAnswer tags: [practice] summary: Grade a practice answer; returns correct/incorrect and explanation parameters: - name: sessionId in: path required: true schema: { type: integer } requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PracticeAnswerInput" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/PracticeGrade" /tutor/ask: post: operationId: askTutor tags: [tutor] summary: Ask the AI tutor a question (text reply with optional spoken audio URL) requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/TutorAskInput" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/TutorReply" /detection/scan: post: operationId: scanText tags: [detection] summary: Run AI-generation + diachronic detection on a candidate answer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/DetectionScanInput" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/DetectionResult" /analytics/summary: get: operationId: getAnalyticsSummary tags: [analytics] summary: Overall performance summary (averages, attempts, streaks) responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/AnalyticsSummary" /analytics/topics: get: operationId: getTopicAnalytics tags: [analytics] summary: Per-topic accuracy and strength/weakness ranking responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/TopicAnalytics" /analytics/activity: get: operationId: getRecentActivity tags: [analytics] summary: Recent practice + assignment activity timeline responses: "200": description: OK content: application/json: schema: type: array items: $ref: "#/components/schemas/ActivityItem" /analytics/report: post: operationId: generateReport tags: [analytics] summary: Generate (and persist) a narrative strengths/weaknesses report responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/AnalyticsReport" /analytics/report/latest: get: operationId: getLatestReport tags: [analytics] summary: Most recently saved report for the current mode (null if none yet) responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/LatestProfileReport" /analytics/report/history: get: operationId: getReportHistory tags: [analytics] summary: Past report snapshots for the current mode, newest first responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/ProfileReportHistory" /settings: get: operationId: getSettings tags: [settings] summary: Current analysis mode and per-mode framework selection responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/AppSettings" put: operationId: updateSettings tags: [settings] summary: Update analysis mode and/or framework selection requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SettingsInput" responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/AppSettings" components: schemas: HealthStatus: type: object properties: status: { type: string } required: [status] Topic: type: object required: [id, slug, title, weekNumber] properties: id: { type: integer } slug: { type: string } title: { type: string } weekNumber: { type: integer } blurb: { type: ["string", "null"] } Lecture: type: object required: [id, topicId, title, weekNumber, body] properties: id: { type: integer } topicId: { type: integer } title: { type: string } weekNumber: { type: integer } body: type: string description: Short Markdown lecture text (the baseline / minimum-detail version). The frontend lets users select passages and send them to the tutor. bodyMedium: type: ["string", "null"] description: Medium-length version with more explanation and more examples. Null if not yet generated. bodyLong: type: ["string", "null"] description: Long version with the most explanation and the most examples. Null if not yet generated. Week: type: object required: [weekNumber, title, lectures, assignments] properties: weekNumber: { type: integer } title: { type: string } summary: { type: ["string", "null"] } lectures: type: array items: $ref: "#/components/schemas/LectureRef" assignments: type: array items: $ref: "#/components/schemas/AssignmentSummary" LectureRef: type: object required: [id, title, topicId] properties: id: { type: integer } title: { type: string } topicId: { type: integer } AssignmentSummary: type: object required: [id, kind, title, weekNumber, problemCount, isTimed, status] properties: id: { type: integer } kind: type: string enum: [homework, test, midterm, final] title: { type: string } weekNumber: { type: integer } problemCount: { type: integer } isTimed: { type: boolean } timeLimitMinutes: { type: ["integer", "null"] } status: type: string enum: [not_started, in_progress, submitted] bestScore: { type: ["number", "null"] } lastAttemptId: { type: ["integer", "null"] } Assignment: type: object required: [id, kind, title, weekNumber, isTimed, problems] properties: id: { type: integer } kind: type: string enum: [homework, test, midterm, final] title: { type: string } weekNumber: { type: integer } isTimed: { type: boolean } timeLimitMinutes: { type: ["integer", "null"] } instructions: { type: ["string", "null"] } problems: type: array items: $ref: "#/components/schemas/Problem" Problem: type: object required: [id, position, prompt, topicId] properties: id: { type: integer } position: { type: integer } prompt: { type: string } topicId: { type: integer } topicTitle: { type: ["string", "null"] } hint: { type: ["string", "null"] } AttemptState: type: object required: [id, assignmentId, status, startedAt, answers] properties: id: { type: integer } assignmentId: { type: integer } status: type: string enum: [in_progress, submitted] startedAt: { type: string, format: date-time } submittedAt: { type: ["string", "null"], format: date-time } deadlineAt: { type: ["string", "null"], format: date-time } answers: type: array items: $ref: "#/components/schemas/SavedAnswer" SavedAnswer: type: object required: [problemId, answer] properties: problemId: { type: integer } answer: { type: string } keystrokeCount: { type: ["integer", "null"] } eraseCount: { type: ["integer", "null"] } correct: { type: ["boolean", "null"] } explanation: { type: ["string", "null"] } aiFlagged: { type: ["boolean", "null"] } detectionRationale: { type: ["string", "null"] } AnswerInput: type: object required: [problemId, answer, trace] properties: problemId: { type: integer } answer: { type: string } trace: $ref: "#/components/schemas/KeystrokeTrace" KeystrokeTrace: type: object required: [keystrokeCount, eraseCount, durationMs] properties: keystrokeCount: { type: integer } eraseCount: { type: integer } bulkInsertCount: { type: integer, default: 0 } longestBulkInsertChars: { type: integer, default: 0 } rewriteSegments: { type: integer, default: 0 } durationMs: { type: integer } AnswerSaved: type: object required: [ok] properties: ok: { type: boolean } AttemptResult: type: object required: [attemptId, score, total, percent, perProblem, detection] properties: attemptId: { type: integer } score: { type: number } total: { type: number } percent: { type: number } perProblem: type: array items: $ref: "#/components/schemas/ProblemResult" detection: type: array items: $ref: "#/components/schemas/DetectionResult" ProblemResult: type: object required: [problemId, correct, explanation] properties: problemId: { type: integer } correct: { type: boolean } userAnswer: { type: string } correctAnswer: { type: string } explanation: { type: string } ReanalyzeInput: type: object required: [mode, framework] properties: mode: type: string enum: [self_knowledge, career] framework: type: string description: Framework id for the chosen mode, or "auto" for all of them ReanalyzeResult: type: object required: [mode, framework, items] properties: mode: type: string enum: [self_knowledge, career] framework: { type: string } items: type: array items: $ref: "#/components/schemas/ReanalyzeItem" ReanalyzeItem: type: object required: [problemId, correct, explanation] properties: problemId: { type: integer } correct: { type: boolean } explanation: { type: string } RebuttalInput: type: object required: [message] properties: message: type: string description: The student's push-back on the app's reading of their answer Rebuttal: type: object required: [id, userMessage, appResponse, revised, createdAt] properties: id: { type: integer } userMessage: { type: string } appResponse: { type: string } revised: type: boolean description: True when the app changed its reading in light of the push-back createdAt: { type: string, format: date-time } RebuttalThread: type: object required: [items] properties: items: type: array items: $ref: "#/components/schemas/Rebuttal" PracticeSessionInput: type: object required: [tutorEnabled] properties: weekNumber: { type: ["integer", "null"] } topicId: { type: ["integer", "null"] } tutorEnabled: { type: boolean } focusOnWeaknesses: { type: boolean, default: true } initialDifficulty: type: ["number", "null"] description: Starting difficulty 1-5; if omitted defaults to 2.0 PracticeSession: type: object required: [id, tutorEnabled, difficulty, weekNumber] properties: id: { type: integer } tutorEnabled: { type: boolean } difficulty: { type: number } weekNumber: { type: ["integer", "null"] } topicId: { type: ["integer", "null"] } focusOnWeaknesses: { type: boolean } NextProblemInput: type: object properties: request: type: ["string", "null"] description: Free-form user request, e.g. "give me harder probability problems" topicId: { type: ["integer", "null"] } PracticeProblem: type: object required: [id, prompt, topicId, difficulty] properties: id: { type: integer } prompt: { type: string } topicId: { type: integer } topicTitle: { type: string } difficulty: { type: number } PracticeAnswerInput: type: object required: [problemId, answer, trace] properties: problemId: { type: integer } answer: { type: string } trace: $ref: "#/components/schemas/KeystrokeTrace" PracticeGrade: type: object required: [problemId, correct, explanation, newDifficulty] properties: problemId: { type: integer } correct: { type: boolean } correctAnswer: { type: string } explanation: { type: string } newDifficulty: { type: number } tutorTip: { type: ["string", "null"] } TutorAskInput: type: object required: [message] properties: sessionId: { type: ["integer", "null"] } message: { type: string } selectedLectureText: { type: ["string", "null"] } lectureId: { type: ["integer", "null"] } problemId: { type: ["integer", "null"] } TutorReply: type: object required: [text] properties: text: { type: string } audioUrl: { type: ["string", "null"] } DetectionScanInput: type: object required: [text, trace] properties: text: { type: string } trace: $ref: "#/components/schemas/KeystrokeTrace" DetectionResult: type: object required: [problemId, aiScore, aiFlagged, diachronicScore, diachronicFlagged, rationale] properties: problemId: { type: ["integer", "null"] } aiScore: type: number description: 0..1 probability the text is AI-generated aiFlagged: { type: boolean } diachronicScore: type: number description: 0..1 probability the user is rewording AI output (based on keystroke pattern) diachronicFlagged: { type: boolean } rationale: { type: string } AnalyticsSummary: type: object required: [officialAverage, practiceAccuracy, attemptsCount, practiceCount, streakDays] properties: officialAverage: { type: number } practiceAccuracy: { type: number } attemptsCount: { type: integer } practiceCount: { type: integer } streakDays: { type: integer } strongestTopic: { type: ["string", "null"] } weakestTopic: { type: ["string", "null"] } TopicAnalytics: type: object required: [topicId, topicTitle, weekNumber, attempts, accuracy, strengthLabel] properties: topicId: { type: integer } topicTitle: { type: string } weekNumber: { type: integer } attempts: { type: integer } accuracy: { type: number } strengthLabel: type: string enum: [strong, solid, developing, weak, untested] ActivityItem: type: object required: [id, kind, title, at] properties: id: { type: integer } kind: type: string enum: [practice, assignment] title: { type: string } at: { type: string, format: date-time } score: { type: ["number", "null"] } topicTitle: { type: ["string", "null"] } AnalyticsReport: type: object required: [generatedAt, narrative, strengths, weaknesses, recommendations] properties: generatedAt: { type: string, format: date-time } narrative: { type: string } strengths: type: array items: { type: string } weaknesses: type: array items: { type: string } recommendations: type: array items: { type: string } ProfileReport: type: object required: [ id, generatedAt, mode, framework, narrative, strengths, weaknesses, recommendations, answeredCount, ] properties: id: { type: integer } generatedAt: { type: string, format: date-time } mode: { type: string } framework: { type: string } narrative: { type: string } strengths: type: array items: { type: string } weaknesses: type: array items: { type: string } recommendations: type: array items: { type: string } answeredCount: { type: integer } LatestProfileReport: type: object required: [report] properties: report: oneOf: - $ref: "#/components/schemas/ProfileReport" - type: "null" ProfileReportHistory: type: array items: $ref: "#/components/schemas/ProfileReport" CourseOverview: type: object required: [title, weeks, totals] properties: title: { type: string } weeks: type: array items: $ref: "#/components/schemas/Week" totals: type: object required: [assignmentsCompleted, assignmentsTotal, practiceCount] properties: assignmentsCompleted: { type: integer } assignmentsTotal: { type: integer } practiceCount: { type: integer } AppSettings: type: object required: [mode, selfFramework, careerFramework, stance] properties: mode: type: string enum: [self_knowledge, career] selfFramework: type: string enum: [ auto, cognitive_distortions, defense_mechanisms, attachment, self_discrepancy, attribution, ] careerFramework: type: string enum: [auto, riasec, onet, strong, career_anchors, big_five] stance: type: string description: Temperament of the feedback — how charitable vs. severe the grader is enum: [ neutral, looking_for_good, really_looking_for_good, constructively_critical, constructively_very_critical, pure_damnation, ] SettingsInput: type: object properties: mode: type: string enum: [self_knowledge, career] selfFramework: type: string enum: [ auto, cognitive_distortions, defense_mechanisms, attachment, self_discrepancy, attribution, ] careerFramework: type: string enum: [auto, riasec, onet, strong, career_anchors, big_five] stance: type: string enum: [ neutral, looking_for_good, really_looking_for_good, constructively_critical, constructively_very_critical, pure_damnation, ]