openapi: 3.1.0 info: title: Api version: 0.1.0 servers: - url: /api tags: - name: health - name: curriculum - name: teachers - name: tutor - name: tp - name: teachers-workspace - name: assessments - name: payments paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check description: Returns server health status responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /curriculum/competences: get: operationId: listCompetences tags: [curriculum] summary: List competences description: Returns all competences, optionally filtered by subject parameters: - name: subject in: query required: false schema: type: string enum: [MATHS, PC, SVT] responses: "200": description: List of competences content: application/json: schema: type: array items: $ref: "#/components/schemas/CompetenceSummary" /curriculum/competences/{id}: get: operationId: getCompetence tags: [curriculum] summary: Get competence detail description: Returns a competence with its leçons and prerequisites parameters: - name: id in: path required: true schema: type: string responses: "200": description: Competence detail content: application/json: schema: $ref: "#/components/schemas/CompetenceDetail" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/NotFound" /curriculum/lecons/{id}: get: operationId: getLecon tags: [curriculum] summary: Get leçon detail description: Returns a leçon with full APC content parameters: - name: id in: path required: true schema: type: string responses: "200": description: Leçon detail content: application/json: schema: $ref: "#/components/schemas/LeconDetail" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/NotFound" /curriculum/tp-fiches: get: operationId: listTpFiches tags: [curriculum] summary: List TP fiches description: Returns TP fiches, optionally filtered by subject parameters: - name: subject in: query required: false schema: type: string enum: [PC, SVT] responses: "200": description: List of TP fiches content: application/json: schema: type: array items: $ref: "#/components/schemas/TpFiche" /teachers/{id}/dashboard-data: get: operationId: getTeacherDashboard tags: [teachers] summary: Get teacher dashboard data description: Returns teacher profile, class counts, and quick-pick leçon options parameters: - name: id in: path required: true schema: type: string format: uuid responses: "200": description: Teacher dashboard data content: application/json: schema: $ref: "#/components/schemas/TeacherDashboard" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/NotFound" /tutor/start: post: operationId: startTutorSession tags: [tutor] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/StartTutorRequest" responses: "200": description: Session started content: application/json: schema: $ref: "#/components/schemas/StartTutorResponse" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/NotFound" /tutor/message: post: operationId: sendTutorMessage tags: [tutor] description: > Sends a student message and streams the Socratic tutor response as Server-Sent Events. Each event is a JSON line prefixed with "data: ". Event types: token (partial text), tool_use (tool invocation), done (session state), error (failure). requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SendMessageRequest" responses: "200": description: SSE stream content: text/event-stream: schema: type: string description: SSE stream of TutorStreamEvent JSON objects "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/NotFound" /tp/start: post: operationId: startTpSession tags: [tp] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/StartTpRequest" responses: "200": description: TP session started content: application/json: schema: $ref: "#/components/schemas/StartTpResponse" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/NotFound" /tp/message: post: operationId: sendTpMessage tags: [tp] description: > Sends a student message during a TP session and streams the TP supervisor response as Server-Sent Events. Same event format as /tutor/message. requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SendMessageRequest" responses: "200": description: SSE stream content: text/event-stream: schema: type: string "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/NotFound" /tp/advance-phase: post: operationId: advanceTpPhase tags: [tp] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdvancePhaseRequest" responses: "200": description: Phase advanced content: application/json: schema: $ref: "#/components/schemas/AdvancePhaseResponse" "400": description: Bad request content: application/json: schema: $ref: "#/components/schemas/NotFound" /tp/{id}/sim: get: operationId: getTpSim tags: [tp] description: > Returns the custom HTML5 simulation for a TP fiche as text/html. Response is cached aggressively — sims are immutable once deployed. Returns 404 if the TP fiche has no custom sim (use phetSimUrl instead for PC fiches). parameters: - name: id in: path required: true schema: type: string responses: "200": description: Custom HTML5 simulation for the TP fiche content: text/html: schema: type: string "404": description: No custom sim available for this TP fiche content: application/json: schema: $ref: "#/components/schemas/NotFound" /teachers/{id}/lesson-plan: post: operationId: generateLessonPlan tags: [teachers-workspace] description: > Generates an APC-format lesson plan for the specified leçon. Streams the response as Server-Sent Events (same format as tutor/message). Updates teachers.last_prepared_lecon_id on call. parameters: - name: id in: path required: true schema: type: string format: uuid requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LessonPlanRequest" responses: "200": description: SSE stream of token events content: text/event-stream: schema: type: string "404": description: Teacher or leçon not found content: application/json: schema: $ref: "#/components/schemas/NotFound" /teachers/{id}/heatmap: get: operationId: getClassHeatmap tags: [teachers-workspace] description: > Returns aggregate mastery scores for all students in the teacher's classes, grouped by competence and leçon. Only includes leçons where at least one student has a mastery score record. parameters: - name: id in: path required: true schema: type: string format: uuid - name: subject in: query required: false schema: type: string enum: [MATHS, PC, SVT] responses: "200": description: Heatmap data content: application/json: schema: $ref: "#/components/schemas/HeatmapData" "404": description: Teacher not found content: application/json: schema: $ref: "#/components/schemas/NotFound" /teachers/{id}/flagged-sessions: get: operationId: getFlaggedSessions tags: [teachers-workspace] description: > Returns sessions flagged for teacher attention via the flag_for_teacher tool in Stage 2. Ordered by most recent first. parameters: - name: id in: path required: true schema: type: string format: uuid responses: "200": description: List of flagged sessions content: application/json: schema: type: array items: $ref: "#/components/schemas/FlaggedSession" "404": description: Teacher not found content: application/json: schema: $ref: "#/components/schemas/NotFound" /assessments/generate: post: operationId: generateAssessmentQuestions tags: [assessments] description: > Generates BEPC-format or formative assessment questions for a given competence using Claude. Returns both structured JSON (for in-app use) and Markdown (for teacher export/print). Does NOT save to DB — the caller decides whether to persist via POST /assessments. requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/GenerateAssessmentRequest" responses: "200": description: Generated assessment with questions and markdown content: application/json: schema: $ref: "#/components/schemas/GeneratedAssessment" "404": description: Competence not found content: application/json: schema: $ref: "#/components/schemas/NotFound" /assessments: post: operationId: createAssessment tags: [assessments] description: Persists a generated assessment to the DB. requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateAssessmentRequest" responses: "201": description: Assessment persisted content: application/json: schema: $ref: "#/components/schemas/AssessmentRecord" /assessments/{id}/respond: post: operationId: submitAssessmentResponse tags: [assessments] description: > Student submits answers to all questions in an assessment. MCQ questions are auto-graded immediately. Open questions receive scoreAwarded null pending teacher grading. parameters: - name: id in: path required: true schema: type: string format: uuid requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SubmitResponsesRequest" responses: "200": description: Submission results with auto-graded scores content: application/json: schema: $ref: "#/components/schemas/SubmitResponsesResult" "404": description: Assessment not found content: application/json: schema: $ref: "#/components/schemas/NotFound" /pilot/report: get: operationId: getPilotReportData tags: [assessments] description: > Returns structured pilot impact data for all students across all pilot schools. Used to generate the CSV and HTML-print report. responses: "200": description: Pilot report data content: application/json: schema: $ref: "#/components/schemas/PilotReportData" /pilot/report/csv: get: operationId: downloadPilotReportCsv tags: [assessments] description: Downloads the pilot report as a UTF-8 CSV file with BOM. responses: "200": description: CSV file content: text/csv: schema: type: string /pilot/report/print: get: operationId: getPilotReportHtml tags: [assessments] description: > Returns a print-ready HTML page containing the full pilot impact report. Bilingual French primary, English section headers. responses: "200": description: Print-ready HTML content: text/html: schema: type: string /payments/tiers: get: operationId: listSubscriptionTiers tags: [payments] description: Returns all available subscription tiers with pricing. responses: "200": description: List of subscription tiers content: application/json: schema: type: array items: $ref: "#/components/schemas/SubscriptionTier" /payments/cinetpay/initiate: post: operationId: initiateCinetpayPayment tags: [payments] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/InitiatePaymentRequest" responses: "200": description: Payment initiated content: application/json: schema: $ref: "#/components/schemas/PaymentInitiateResponse" "400": description: Invalid request content: application/json: schema: $ref: "#/components/schemas/NotFound" /payments/cinetpay/webhook: post: operationId: cinetpayWebhook tags: [payments] description: Webhook receiver for CinetPay payment notifications. requestBody: required: true content: application/json: schema: type: object responses: "200": description: Webhook received content: application/json: schema: type: object properties: received: type: boolean /payments/wave/initiate: post: operationId: initiateWavePayment tags: [payments] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/InitiatePaymentRequest" responses: "200": description: Payment initiated content: application/json: schema: $ref: "#/components/schemas/PaymentInitiateResponse" /payments/wave/webhook: post: operationId: waveWebhook tags: [payments] requestBody: required: true content: application/json: schema: type: object responses: "200": description: Webhook received content: application/json: schema: type: object properties: received: type: boolean /payments/status/{studentId}: get: operationId: getSubscriptionStatus tags: [payments] parameters: - name: studentId in: path required: true schema: type: string format: uuid responses: "200": description: Subscription status for this student content: application/json: schema: $ref: "#/components/schemas/SubscriptionStatus" components: schemas: HealthStatus: type: object properties: status: type: string required: [status] NotFound: type: object properties: error: type: string required: [error] HabileteContenu: type: object properties: habilete: type: string contenu: type: string required: [habilete, contenu] CompetenceSummary: type: object properties: id: type: string libelle: type: string domaine: type: string subject: type: string leconCount: type: integer required: [id, libelle, domaine, subject, leconCount] LeconSummary: type: object properties: id: type: string leconNumero: type: integer leconTitre: type: string sessionOpener: type: string nullable: true required: [id, leconNumero, leconTitre] CompetenceDetail: type: object properties: id: type: string libelle: type: string domaine: type: string subject: type: string masteryThreshold: type: integer lecons: type: array items: $ref: "#/components/schemas/LeconSummary" prerequisites: type: array items: type: string required: [id, libelle, domaine, subject, masteryThreshold, lecons, prerequisites] LeconDetail: type: object properties: id: type: string competenceId: type: string leconNumero: type: integer leconTitre: type: string theme: type: string situationApprentissage: type: string sessionOpener: type: string nullable: true habilitesContenus: type: array items: $ref: "#/components/schemas/HabileteContenu" criteresEvaluation: type: array items: type: string ressources: type: array items: type: string required: [id, competenceId, leconNumero, leconTitre, theme, situationApprentissage, habilitesContenus, criteresEvaluation, ressources] TpFiche: type: object properties: id: type: string subject: type: string titre: type: string objectif: type: string phetSimName: type: string nullable: true phetSimUrl: type: string nullable: true customSimRequired: type: boolean phases: type: object properties: prediction: type: string observation: type: string analyse: type: string required: [prediction, observation, analyse] required: [id, subject, titre, objectif, customSimRequired, phases] QuickPickOption: type: object properties: leconId: type: string leconTitre: type: string competenceId: type: string competenceLibelle: type: string subject: type: string lastUsed: type: string format: date-time nullable: true required: [leconId, leconTitre, competenceId, competenceLibelle, subject] TeacherDashboard: type: object properties: teacherId: type: string format: uuid fullName: type: string schoolName: type: string subjectAssignments: type: array items: type: string classAssignments: type: array items: type: string studentCount: type: integer quickPickOptions: type: array items: $ref: "#/components/schemas/QuickPickOption" required: [teacherId, fullName, schoolName, subjectAssignments, classAssignments, studentCount, quickPickOptions] StartTutorRequest: type: object properties: studentId: type: string format: uuid leconId: type: string required: [studentId, leconId] StartTutorResponse: type: object properties: sessionId: type: string format: uuid sessionOpener: type: string description: First message Claude sends — student never sees a blank input leconTitre: type: string competenceLibelle: type: string currentMastery: type: integer description: Current mastery score 0-100 for this leçon required: [sessionId, sessionOpener, leconTitre, competenceLibelle, currentMastery] StartTpRequest: type: object properties: studentId: type: string format: uuid tpFicheId: type: string required: [studentId, tpFicheId] StartTpResponse: type: object properties: sessionId: type: string format: uuid currentPhase: type: string enum: [prediction, observation, analyse] phasePrompt: type: string description: The TP supervisor opening question for the current phase tpTitre: type: string phetSimUrl: type: string nullable: true customSimRequired: type: boolean required: [sessionId, currentPhase, phasePrompt, tpTitre, customSimRequired] SendMessageRequest: type: object properties: sessionId: type: string format: uuid message: type: string minLength: 1 required: [sessionId, message] AdvancePhaseRequest: type: object properties: sessionId: type: string format: uuid required: [sessionId] AdvancePhaseResponse: type: object properties: sessionId: type: string format: uuid nextPhase: type: string enum: [observation, analyse] nullable: true phasePrompt: type: string nullable: true isComplete: type: boolean description: True when analyse phase is complete — all three phases done required: [sessionId, isComplete] LessonPlanRequest: type: object properties: leconId: type: string description: e.g. CI-MATHS-3E-C01-L05 className: type: string description: e.g. "3ème A" required: [leconId, className] HeatmapCell: type: object properties: leconId: type: string leconTitre: type: string competenceId: type: string competenceLibelle: type: string subject: type: string averageScore: type: number description: 0–100, average across all students with a score record studentsScored: type: integer description: number of students who have at least one session on this leçon totalStudents: type: integer required: [leconId, leconTitre, competenceId, competenceLibelle, subject, averageScore, studentsScored, totalStudents] HeatmapData: type: object properties: teacherId: type: string format: uuid totalStudents: type: integer cells: type: array items: $ref: "#/components/schemas/HeatmapCell" required: [teacherId, totalStudents, cells] FlaggedSession: type: object properties: sessionId: type: string format: uuid studentId: type: string format: uuid studentName: type: string leconId: type: string nullable: true leconTitre: type: string nullable: true flagReason: type: string nullable: true flaggedAt: type: string format: date-time required: [sessionId, studentId, studentName, flaggedAt] AssessmentQuestion: type: object properties: id: type: string format: uuid type: type: string enum: [open, mcq] question: type: string choices: type: array items: type: string nullable: true correctAnswer: type: string explanation: type: string competenceId: type: string leconId: type: string nullable: true maxScore: type: integer bepcFormat: type: boolean required: [id, type, question, correctAnswer, explanation, competenceId, maxScore, bepcFormat] GenerateAssessmentRequest: type: object properties: competenceId: type: string type: type: string enum: [bepc, formative] questionCount: type: integer minimum: 1 maximum: 10 default: 5 teacherId: type: string format: uuid nullable: true className: type: string nullable: true required: [competenceId, type] GeneratedAssessment: type: object properties: competenceId: type: string competenceLibelle: type: string subject: type: string type: type: string totalPoints: type: integer questions: type: array items: $ref: "#/components/schemas/AssessmentQuestion" markdownText: type: string required: [competenceId, competenceLibelle, subject, type, totalPoints, questions, markdownText] CreateAssessmentRequest: type: object properties: type: type: string enum: [pre_pilot, post_pilot, formative] subject: type: string competenceId: type: string nullable: true createdByTeacherId: type: string format: uuid nullable: true className: type: string nullable: true markdownText: type: string nullable: true questions: type: array items: $ref: "#/components/schemas/AssessmentQuestion" required: [type, subject, questions] AssessmentRecord: type: object properties: assessmentId: type: string format: uuid questionIds: type: array items: type: string format: uuid required: [assessmentId, questionIds] SubmitResponsesRequest: type: object properties: studentId: type: string format: uuid responses: type: array items: type: object properties: questionId: type: string format: uuid responseText: type: string required: [questionId, responseText] required: [studentId, responses] QuestionResult: type: object properties: questionId: type: string format: uuid scoreAwarded: type: integer nullable: true maxScore: type: integer isCorrect: type: boolean nullable: true explanation: type: string required: [questionId, maxScore, explanation] SubmitResponsesResult: type: object properties: assessmentId: type: string format: uuid studentId: type: string format: uuid results: type: array items: $ref: "#/components/schemas/QuestionResult" totalScored: type: integer totalPossibleAutoGraded: type: integer pendingManualGrading: type: integer required: [assessmentId, studentId, results, totalScored, totalPossibleAutoGraded, pendingManualGrading] PilotStudentRow: type: object properties: studentId: type: string format: uuid fullName: type: string schoolName: type: string gender: type: string nullable: true preScore: type: number nullable: true postScore: type: number nullable: true delta: type: number nullable: true required: [studentId, fullName, schoolName] PilotReportData: type: object properties: generatedAt: type: string format: date-time totalStudents: type: integer studentsWithBothScores: type: integer studentsWithGender: type: integer averageDelta: type: number nullable: true averageDeltaF: type: number nullable: true averageDeltaM: type: number nullable: true rows: type: array items: $ref: "#/components/schemas/PilotStudentRow" required: [generatedAt, totalStudents, studentsWithBothScores, studentsWithGender, rows] SubscriptionTier: type: object properties: id: type: string labelFr: type: string priceXof: type: integer durationDays: type: integer subjectsAllowed: type: array items: type: string maxStudents: type: integer required: [id, labelFr, priceXof, durationDays, subjectsAllowed, maxStudents] InitiatePaymentRequest: type: object properties: studentId: type: string format: uuid tierId: type: string required: [studentId, tierId] PaymentInitiateResponse: type: object properties: paymentId: type: string format: uuid paymentUrl: type: string providerTransactionId: type: string required: [paymentId, paymentUrl, providerTransactionId] SubscriptionStatus: type: object properties: studentId: type: string format: uuid isPilotBypass: type: boolean hasActiveSubscription: type: boolean tierId: type: string nullable: true subjectsAllowed: type: array items: type: string expiresAt: type: string format: date-time nullable: true canAccess: type: boolean required: [studentId, isPilotBypass, hasActiveSubscription, subjectsAllowed, canAccess]