openapi: 3.1.0 info: title: Api version: 0.1.0 description: EPS TOPIK Kosakata API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: Auth description: Browser and mobile authentication endpoints. - name: vocab description: Vocabulary operations - name: stats description: Statistics and progress - name: quiz description: Quiz operations - name: tryout description: Mock EPS-TOPIK exam (tryout) - name: units description: Curriculum unit metadata - name: payments description: Manual payment and access - name: admin description: Admin payment verification - name: adminContent description: Admin content management (vocab, tryout) 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" /auth/user: get: tags: [Auth] operationId: getCurrentAuthUser summary: Get the currently authenticated user parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' responses: '200': description: Auth status resolved successfully. content: application/json: schema: $ref: '#/components/schemas/AuthUserEnvelope' /login: get: tags: [Auth] operationId: beginBrowserLogin summary: Start the browser OIDC login flow parameters: - name: returnTo in: query required: false schema: type: string responses: '302': description: Redirect to the OIDC authorization endpoint. /callback: get: tags: [Auth] operationId: handleBrowserLoginCallback summary: Complete the browser OIDC login flow parameters: - name: code in: query required: false schema: type: string - name: state in: query required: false schema: type: string - name: iss in: query required: false schema: type: string format: uri responses: '302': description: Redirect to the returnTo path on success or /api/login on failure. /logout: get: tags: [Auth] operationId: logoutBrowserSession summary: Clear the session and begin OIDC logout parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' responses: '302': description: Redirect to the OIDC provider logout URL. /vocab: get: operationId: listVocab tags: [vocab] summary: List vocabulary words with optional filtering parameters: - name: chapter in: query required: false description: Unit id (e.g. unit1). Omit for all accessible units. schema: type: string - name: status in: query required: false schema: type: string enum: [all, hafal, susah, belum] - name: q in: query required: false schema: type: string responses: "200": description: List of vocabulary words content: application/json: schema: type: array items: $ref: "#/components/schemas/VocabWord" /vocab/{wordId}/status: put: operationId: updateWordStatus tags: [vocab] summary: Update the learning status of a vocabulary word parameters: - name: wordId in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/WordStatusInput" responses: "200": description: Updated word with new status content: application/json: schema: $ref: "#/components/schemas/VocabWord" "401": description: Not authenticated content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" /stats: get: operationId: getStats tags: [stats] summary: Get learning progress statistics for the current user responses: "200": description: Progress statistics by chapter content: application/json: schema: $ref: "#/components/schemas/StatsResponse" /stats/overall: get: operationId: getOverallStats tags: [stats] summary: Get overall learning progress across all chapters responses: "200": description: Overall statistics content: application/json: schema: $ref: "#/components/schemas/OverallStats" /quiz: get: operationId: getQuizQuestion tags: [quiz] summary: Get a random quiz question with 4 answer choices parameters: - name: chapter in: query required: false description: Unit id (e.g. unit1) or "all". schema: type: string responses: "200": description: A quiz question with 4 choices content: application/json: schema: $ref: "#/components/schemas/QuizQuestion" /quiz/result: post: operationId: submitQuizResult tags: [quiz] summary: Submit a quiz answer and record the result requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/QuizResultInput" responses: "200": description: Quiz result with correct answer content: application/json: schema: $ref: "#/components/schemas/QuizResultResponse" /tryout: get: operationId: startTryout tags: [tryout] summary: Start a new tryout exam (paid access required) responses: "200": description: A fresh tryout exam (questions without answers) content: application/json: schema: $ref: "#/components/schemas/TryoutExam" "401": description: Not authenticated content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" "403": description: No paid access content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" /tryout/submit: post: operationId: submitTryout tags: [tryout] summary: Submit tryout answers for server-side scoring requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/TryoutSubmitInput" responses: "200": description: Scored result with per-question review content: application/json: schema: $ref: "#/components/schemas/TryoutResultResponse" "401": description: Not authenticated content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" "403": description: No paid access content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" /tryout/history: get: operationId: getTryoutHistory tags: [tryout] summary: List the current user's past tryout attempts responses: "200": description: Tryout attempt history content: application/json: schema: $ref: "#/components/schemas/TryoutHistoryResponse" "401": description: Not authenticated content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" /units: get: operationId: listUnits tags: [units] summary: List all curriculum units with lock state for the current user responses: "200": description: Units with metadata and lock state content: application/json: schema: $ref: "#/components/schemas/UnitsResponse" /access: get: operationId: getAccess tags: [payments] summary: Get the current user's access status and payment details responses: "200": description: Access status content: application/json: schema: $ref: "#/components/schemas/AccessStatus" /payment-request: post: operationId: submitPaymentRequest tags: [payments] summary: Submit a manual ShopeePay payment request for admin verification requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PaymentRequestInput" responses: "200": description: Updated access status after submitting the request content: application/json: schema: $ref: "#/components/schemas/AccessStatus" "401": description: Not authenticated content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" "409": description: Already has access or a pending request content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" /admin/payment-requests: get: operationId: listPaymentRequests tags: [admin] summary: List payment requests (admin only) parameters: - name: status in: query required: false schema: type: string enum: [pending, approved, rejected, all] responses: "200": description: List of payment requests with user info content: application/json: schema: $ref: "#/components/schemas/AdminPaymentRequestList" "403": description: Not an admin content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" /admin/payment-requests/{id}/approve: post: operationId: approvePaymentRequest tags: [admin] summary: Approve a payment request (admin only) parameters: - name: id in: path required: true schema: type: string responses: "200": description: The updated payment request content: application/json: schema: $ref: "#/components/schemas/AdminPaymentRequest" "403": description: Not an admin content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" "404": description: Request not found content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" /admin/payment-requests/{id}/reject: post: operationId: rejectPaymentRequest tags: [admin] summary: Reject a payment request (admin only) parameters: - name: id in: path required: true schema: type: string responses: "200": description: The updated payment request content: application/json: schema: $ref: "#/components/schemas/AdminPaymentRequest" "403": description: Not an admin content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" "404": description: Request not found content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" # ─── Admin Content Management ────────────────────────────────────────────── /admin/units: get: operationId: adminListUnits tags: [adminContent] summary: List all curriculum units (admin only) responses: "200": description: All units with word counts content: application/json: schema: $ref: "#/components/schemas/AdminUnitListResponse" "403": description: Not an admin content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" post: operationId: adminCreateUnit tags: [adminContent] summary: Create a new curriculum unit (admin only) requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdminUnitInput" responses: "200": description: Created unit content: application/json: schema: $ref: "#/components/schemas/AdminUnit" "403": description: Not an admin content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" /admin/units/{id}: put: operationId: adminUpdateUnit tags: [adminContent] summary: Update a curriculum unit (admin only) parameters: - name: id in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdminUnitUpdateInput" responses: "200": description: Updated unit content: application/json: schema: $ref: "#/components/schemas/AdminUnit" "403": description: Not an admin content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" "404": description: Unit not found content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" delete: operationId: adminDeleteUnit tags: [adminContent] summary: Delete a curriculum unit and all its words (admin only) parameters: - name: id in: path required: true schema: type: string responses: "200": description: Deletion successful content: application/json: schema: $ref: "#/components/schemas/SuccessResponse" "403": description: Not an admin content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" "404": description: Unit not found content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" /admin/words: get: operationId: adminListWords tags: [adminContent] summary: List vocabulary words (admin only) parameters: - name: unitId in: query required: false schema: type: string - name: q in: query required: false schema: type: string responses: "200": description: List of words content: application/json: schema: $ref: "#/components/schemas/AdminWordListResponse" "403": description: Not an admin content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" post: operationId: adminCreateWord tags: [adminContent] summary: Create a vocabulary word (admin only) requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdminWordInput" responses: "200": description: Created word content: application/json: schema: $ref: "#/components/schemas/AdminWord" "403": description: Not an admin content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" /admin/words/{id}: put: operationId: adminUpdateWord tags: [adminContent] summary: Update a vocabulary word (admin only) parameters: - name: id in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdminWordUpdateInput" responses: "200": description: Updated word content: application/json: schema: $ref: "#/components/schemas/AdminWord" "403": description: Not an admin content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" "404": description: Word not found content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" delete: operationId: adminDeleteWord tags: [adminContent] summary: Delete a vocabulary word (admin only) parameters: - name: id in: path required: true schema: type: string responses: "200": description: Deletion successful content: application/json: schema: $ref: "#/components/schemas/SuccessResponse" "403": description: Not an admin content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" "404": description: Word not found content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" /admin/tryout-questions: get: operationId: adminListTryoutQuestions tags: [adminContent] summary: List tryout questions (admin only) parameters: - name: section in: query required: false schema: type: string enum: [listening, reading] responses: "200": description: List of tryout questions content: application/json: schema: $ref: "#/components/schemas/AdminTryoutQuestionListResponse" "403": description: Not an admin content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" post: operationId: adminCreateTryoutQuestion tags: [adminContent] summary: Create a tryout question (admin only) requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdminTryoutQuestionInput" responses: "200": description: Created question content: application/json: schema: $ref: "#/components/schemas/AdminTryoutQuestion" "403": description: Not an admin content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" /admin/tryout-questions/{id}: put: operationId: adminUpdateTryoutQuestion tags: [adminContent] summary: Update a tryout question (admin only) parameters: - name: id in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AdminTryoutQuestionUpdateInput" responses: "200": description: Updated question content: application/json: schema: $ref: "#/components/schemas/AdminTryoutQuestion" "403": description: Not an admin content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" "404": description: Question not found content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" delete: operationId: adminDeleteTryoutQuestion tags: [adminContent] summary: Delete a tryout question (admin only) parameters: - name: id in: path required: true schema: type: string responses: "200": description: Deletion successful content: application/json: schema: $ref: "#/components/schemas/SuccessResponse" "403": description: Not an admin content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" "404": description: Question not found content: application/json: schema: $ref: "#/components/schemas/ErrorEnvelope" components: parameters: AuthorizationSessionHeader: name: Authorization in: header required: false description: Opaque session token — `Bearer `. schema: type: string SessionCookie: name: sid in: cookie required: false description: Browser session cookie. schema: type: string schemas: HealthStatus: type: object properties: status: type: string required: - status AuthUser: type: object required: [id, email, firstName, lastName, profileImageUrl, isAdmin] properties: id: type: string email: type: [string, 'null'] format: email firstName: type: [string, 'null'] lastName: type: [string, 'null'] profileImageUrl: type: [string, 'null'] isAdmin: type: boolean AuthUserEnvelope: type: object required: [user] properties: user: oneOf: - $ref: '#/components/schemas/AuthUser' - type: 'null' MobileTokenExchangeRequest: type: object required: [code, code_verifier, redirect_uri, state] properties: code: type: string minLength: 1 code_verifier: type: string minLength: 1 redirect_uri: type: string minLength: 1 format: uri state: type: string minLength: 1 nonce: type: string minLength: 1 MobileTokenExchangeSuccess: type: object required: [token] properties: token: type: string LogoutSuccess: type: object required: [success] properties: success: type: boolean const: true ErrorEnvelope: type: object required: [error] properties: error: type: string SuccessResponse: type: object required: [success] properties: success: type: boolean VocabWord: type: object required: [id, ko, idn, chapter, status] properties: id: type: string ko: type: string idn: type: string chapter: type: string audioUrl: type: [string, 'null'] imageUrl: type: [string, 'null'] status: type: string enum: [hafal, susah, belum] WordStatusInput: type: object required: [status] properties: status: type: string enum: [hafal, susah, belum] ChapterStats: type: object required: [chapter, chapterLabel, total, hafal, susah, belum, percentHafal] properties: chapter: type: string chapterLabel: type: string total: type: integer hafal: type: integer susah: type: integer belum: type: integer percentHafal: type: integer StatsResponse: type: object required: [chapters] properties: chapters: type: array items: $ref: "#/components/schemas/ChapterStats" OverallStats: type: object required: [total, hafal, susah, belum, percentHafal, quizScore, quizTotal] properties: total: type: integer hafal: type: integer susah: type: integer belum: type: integer percentHafal: type: integer quizScore: type: integer quizTotal: type: integer QuizChoice: type: object required: [id, text] properties: id: type: string text: type: string QuizQuestion: type: object required: [wordId, ko, chapter, choices] properties: wordId: type: string ko: type: string chapter: type: string choices: type: array items: $ref: "#/components/schemas/QuizChoice" QuizResultInput: type: object required: [wordId, selectedId] properties: wordId: type: string selectedId: type: string chapter: type: string QuizResultResponse: type: object required: [correct, correctId, correctText, pointsEarned] properties: correct: type: boolean correctId: type: string correctText: type: string pointsEarned: type: integer TryoutQuestionPublic: type: object required: [id, section, audioText, passage, question, options] properties: id: type: string section: type: string enum: [listening, reading] audioText: type: [string, 'null'] passage: type: [string, 'null'] question: type: string options: type: array items: type: string TryoutExam: type: object required: - examToken - questions - listeningCount - readingCount - totalQuestions - durationSeconds - passScore - maxScore properties: examToken: type: string questions: type: array items: $ref: "#/components/schemas/TryoutQuestionPublic" listeningCount: type: integer readingCount: type: integer totalQuestions: type: integer durationSeconds: type: integer passScore: type: integer maxScore: type: integer TryoutAnswerInput: type: object required: [questionId, selectedIndex] properties: questionId: type: string selectedIndex: type: integer TryoutSubmitInput: type: object required: [examToken, answers, durationSeconds] properties: examToken: type: string answers: type: array items: $ref: "#/components/schemas/TryoutAnswerInput" durationSeconds: type: integer minimum: 0 TryoutQuestionReview: type: object required: [questionId, section, correctAnswer, selectedIndex, isCorrect, explanation] properties: questionId: type: string section: type: string enum: [listening, reading] correctAnswer: type: integer selectedIndex: type: integer isCorrect: type: boolean explanation: type: [string, 'null'] TryoutResultResponse: type: object required: - id - totalScore - listeningScore - readingScore - correctCount - totalQuestions - passed - durationSeconds - passScore - maxScore - createdAt - review properties: id: type: string totalScore: type: integer listeningScore: type: integer readingScore: type: integer correctCount: type: integer totalQuestions: type: integer passed: type: boolean durationSeconds: type: integer passScore: type: integer maxScore: type: integer createdAt: type: string review: type: array items: $ref: "#/components/schemas/TryoutQuestionReview" TryoutHistoryItem: type: object required: - id - totalScore - listeningScore - readingScore - correctCount - totalQuestions - passed - durationSeconds - createdAt properties: id: type: string totalScore: type: integer listeningScore: type: integer readingScore: type: integer correctCount: type: integer totalQuestions: type: integer passed: type: boolean durationSeconds: type: integer createdAt: type: string TryoutHistoryResponse: type: object required: [attempts, bestScore, totalAttempts] properties: attempts: type: array items: $ref: "#/components/schemas/TryoutHistoryItem" bestScore: type: integer totalAttempts: type: integer Unit: type: object required: [id, number, titleKo, titleId, isFree, wordCount, locked] properties: id: type: string number: type: integer titleKo: type: string titleId: type: string isFree: type: boolean wordCount: type: integer locked: type: boolean UnitsResponse: type: object required: [units, hasAccess] properties: units: type: array items: $ref: "#/components/schemas/Unit" hasAccess: type: boolean AccessStatus: type: object required: [hasAccess, status, priceIdr, shopeePayNumber, shopeePayName] properties: hasAccess: type: boolean status: type: string enum: [none, pending, approved, rejected] priceIdr: type: integer shopeePayNumber: type: string shopeePayName: type: string PaymentRequestInput: type: object required: [senderName] properties: senderName: type: string minLength: 1 maxLength: 100 note: type: string maxLength: 500 AdminPaymentRequest: type: object required: [id, userId, userEmail, userName, senderName, note, amount, status, reviewedAt, createdAt] properties: id: type: string userId: type: string userEmail: type: [string, 'null'] userName: type: [string, 'null'] senderName: type: [string, 'null'] note: type: [string, 'null'] amount: type: integer status: type: string enum: [pending, approved, rejected] reviewedAt: type: [string, 'null'] createdAt: type: string AdminPaymentRequestList: type: object required: [requests] properties: requests: type: array items: $ref: "#/components/schemas/AdminPaymentRequest" # ─── Admin Content Schemas ───────────────────────────────────────────── UploadResponse: type: object required: [url] properties: url: type: string AdminUnit: type: object required: [id, number, titleKo, titleId, isFree, wordCount, createdAt, updatedAt] properties: id: type: string number: type: integer titleKo: type: string titleId: type: string isFree: type: boolean wordCount: type: integer createdAt: type: string updatedAt: type: string AdminUnitListResponse: type: object required: [units] properties: units: type: array items: $ref: "#/components/schemas/AdminUnit" AdminUnitInput: type: object required: [number, titleKo, titleId] properties: number: type: integer titleKo: type: string titleId: type: string isFree: type: boolean AdminUnitUpdateInput: type: object properties: titleKo: type: string titleId: type: string isFree: type: boolean AdminWord: type: object required: [id, unitId, ko, idn, sortOrder, audioUrl, imageUrl, createdAt, updatedAt] properties: id: type: string unitId: type: string ko: type: string idn: type: string sortOrder: type: integer audioUrl: type: [string, 'null'] imageUrl: type: [string, 'null'] createdAt: type: string updatedAt: type: string AdminWordListResponse: type: object required: [words] properties: words: type: array items: $ref: "#/components/schemas/AdminWord" AdminWordInput: type: object required: [unitId, ko, idn] properties: unitId: type: string ko: type: string idn: type: string sortOrder: type: integer audioUrl: type: [string, 'null'] imageUrl: type: [string, 'null'] AdminWordUpdateInput: type: object properties: unitId: type: string ko: type: string idn: type: string sortOrder: type: integer audioUrl: type: [string, 'null'] imageUrl: type: [string, 'null'] AdminTryoutQuestion: type: object required: [id, section, audioText, passage, question, options, answer, explanation, isActive, sortOrder, createdAt, updatedAt] properties: id: type: string section: type: string enum: [listening, reading] audioText: type: [string, 'null'] passage: type: [string, 'null'] question: type: string options: type: array items: type: string answer: type: integer explanation: type: [string, 'null'] isActive: type: boolean sortOrder: type: integer createdAt: type: string updatedAt: type: string AdminTryoutQuestionListResponse: type: object required: [questions] properties: questions: type: array items: $ref: "#/components/schemas/AdminTryoutQuestion" AdminTryoutQuestionInput: type: object required: [section, question, options, answer] properties: section: type: string enum: [listening, reading] audioText: type: [string, 'null'] passage: type: [string, 'null'] question: type: string options: type: array items: type: string minItems: 4 maxItems: 4 answer: type: integer minimum: 0 maximum: 3 explanation: type: [string, 'null'] isActive: type: boolean sortOrder: type: integer AdminTryoutQuestionUpdateInput: type: object properties: audioText: type: [string, 'null'] passage: type: [string, 'null'] question: type: string options: type: array items: type: string minItems: 4 maxItems: 4 answer: type: integer minimum: 0 maximum: 3 explanation: type: [string, 'null'] isActive: type: boolean sortOrder: type: integer