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: LearnHub Online Learning System API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: auth description: Authentication - name: users description: User management - name: courses description: Course management - name: assignments description: Assignment and submission management - name: progress description: Student progress tracking paths: # ── Auth ───────────────────────────────────────────────────────────────── /auth/login: post: operationId: login tags: [auth] summary: Authenticate a user requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LoginRequest" responses: "200": description: Authenticated user content: application/json: schema: $ref: "#/components/schemas/AuthUser" "401": description: Invalid credentials content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /auth/logout: post: operationId: logout tags: [auth] summary: Sign out (stateless — client discards session) responses: "200": description: Logged out content: application/json: schema: $ref: "#/components/schemas/Logout200" /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" # ── Users ────────────────────────────────────────────────────────────────── /users: get: operationId: getUsers tags: [users] summary: List all users responses: "200": description: List of users content: application/json: schema: type: array items: $ref: "#/components/schemas/AppUser" post: operationId: createUser tags: [users] summary: Create a user requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateUser" responses: "201": description: Created user content: application/json: schema: $ref: "#/components/schemas/AppUser" /users/{id}: get: operationId: getUser tags: [users] summary: Get a user by ID parameters: - { name: id, in: path, required: true, schema: { type: string } } responses: "200": description: A user content: application/json: schema: $ref: "#/components/schemas/AppUser" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" put: operationId: updateUser tags: [users] summary: Update a user parameters: - { name: id, in: path, required: true, schema: { type: string } } requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateUser" responses: "200": description: Updated user content: application/json: schema: $ref: "#/components/schemas/AppUser" delete: operationId: deleteUser tags: [users] summary: Delete a user parameters: - { name: id, in: path, required: true, schema: { type: string } } responses: "204": description: Deleted # ── Courses ───────────────────────────────────────────────────────────────── /courses: get: operationId: getCourses tags: [courses] summary: List all courses (with lessons and enrolled students) responses: "200": description: List of courses content: application/json: schema: type: array items: $ref: "#/components/schemas/Course" post: operationId: createCourse tags: [courses] summary: Create a course requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateCourse" responses: "201": description: Created course content: application/json: schema: $ref: "#/components/schemas/Course" /courses/{id}: get: operationId: getCourse tags: [courses] summary: Get a course by ID parameters: - { name: id, in: path, required: true, schema: { type: string } } responses: "200": description: A course content: application/json: schema: $ref: "#/components/schemas/Course" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" put: operationId: updateCourse tags: [courses] summary: Update a course parameters: - { name: id, in: path, required: true, schema: { type: string } } requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateCourse" responses: "200": description: Updated course content: application/json: schema: $ref: "#/components/schemas/Course" delete: operationId: deleteCourse tags: [courses] summary: Delete a course parameters: - { name: id, in: path, required: true, schema: { type: string } } responses: "204": description: Deleted /courses/{id}/enroll: post: operationId: enrollInCourse tags: [courses] summary: Enroll a student in a course parameters: - { name: id, in: path, required: true, schema: { type: string } } requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/EnrollRequest" responses: "200": description: Enrolled successfully content: application/json: schema: $ref: "#/components/schemas/Course" /courses/{id}/lessons: post: operationId: addLesson tags: [courses] summary: Add a lesson to a course parameters: - { name: id, in: path, required: true, schema: { type: string } } requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateLesson" responses: "201": description: Created lesson content: application/json: schema: $ref: "#/components/schemas/Lesson" /lessons/{id}: delete: operationId: deleteLesson tags: [courses] summary: Delete a lesson parameters: - { name: id, in: path, required: true, schema: { type: string } } responses: "204": description: Deleted # ── Assignments ────────────────────────────────────────────────────────────── /assignments: get: operationId: getAssignments tags: [assignments] summary: List all assignments responses: "200": description: List of assignments content: application/json: schema: type: array items: $ref: "#/components/schemas/Assignment" post: operationId: createAssignment tags: [assignments] summary: Create an assignment requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateAssignment" responses: "201": description: Created assignment content: application/json: schema: $ref: "#/components/schemas/Assignment" /assignments/{id}: get: operationId: getAssignment tags: [assignments] summary: Get an assignment by ID parameters: - { name: id, in: path, required: true, schema: { type: string } } responses: "200": description: An assignment content: application/json: schema: $ref: "#/components/schemas/Assignment" delete: operationId: deleteAssignment tags: [assignments] summary: Delete an assignment parameters: - { name: id, in: path, required: true, schema: { type: string } } responses: "204": description: Deleted /assignments/{id}/submit: post: operationId: submitAssignment tags: [assignments] summary: Submit an assignment parameters: - { name: id, in: path, required: true, schema: { type: string } } requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SubmitRequest" responses: "201": description: Submission created content: application/json: schema: $ref: "#/components/schemas/Submission" /submissions: get: operationId: getSubmissions tags: [assignments] summary: List all submissions (optionally filtered by assignmentId or studentId) parameters: - { name: assignmentId, in: query, required: false, schema: { type: string } } - { name: studentId, in: query, required: false, schema: { type: string } } responses: "200": description: List of submissions content: application/json: schema: type: array items: $ref: "#/components/schemas/Submission" /submissions/{id}/grade: put: operationId: gradeSubmission tags: [assignments] summary: Grade a submission parameters: - { name: id, in: path, required: true, schema: { type: string } } requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/GradeRequest" responses: "200": description: Graded submission content: application/json: schema: $ref: "#/components/schemas/Submission" # ── Progress ───────────────────────────────────────────────────────────────── /progress/{userId}/{courseId}: get: operationId: getCourseProgress tags: [progress] summary: Get a student's progress in a course parameters: - { name: userId, in: path, required: true, schema: { type: string } } - { name: courseId, in: path, required: true, schema: { type: string } } responses: "200": description: Progress data content: application/json: schema: $ref: "#/components/schemas/ProgressResult" /progress: post: operationId: markLessonComplete tags: [progress] summary: Mark a lesson as complete requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/MarkProgressRequest" responses: "201": description: Lesson marked complete content: application/json: schema: $ref: "#/components/schemas/ProgressResult" components: schemas: AuthUserRole: type: string enum: [student, instructor, admin] description: Role of an authenticated user LoginRequest: type: object required: [email, password] properties: email: { type: string, description: "User email address" } password: { type: string, description: "User password" } AuthUser: type: object required: [id, name, email, role, isActive] properties: id: { type: string, description: "User ID" } name: { type: string, description: "User full name" } email: { type: string, description: "User email address" } role: { $ref: "#/components/schemas/AuthUserRole" } isActive: { type: boolean, description: "Account active status" } Logout200: type: object required: [success] properties: success: { type: boolean, description: "Logout success flag" } HealthStatus: type: object properties: status: { type: string } required: [status] ErrorResponse: type: object properties: error: { type: string } required: [error] # ── User schemas ──────────────────────────────────────────────────────── AppUser: type: object required: [id, name, email, role, joinDate, isActive] properties: id: { type: string } name: { type: string } email: { type: string } role: { type: string, enum: [student, instructor, admin] } joinDate: { type: string } isActive: { type: boolean } CreateUser: type: object required: [id, name, email, role, joinDate, isActive] properties: id: { type: string } name: { type: string } email: { type: string } passwordHash: { type: string } role: { type: string, enum: [student, instructor, admin] } joinDate: { type: string } isActive: { type: boolean } # ── Lesson schemas ────────────────────────────────────────────────────── Lesson: type: object required: [id, courseId, title, duration, type, order] properties: id: { type: string } courseId: { type: string } title: { type: string } duration: { type: string } type: { type: string, enum: [video, reading, quiz] } order: { type: integer } CreateLesson: type: object required: [id, title, duration, type, order] properties: id: { type: string } title: { type: string } duration: { type: string } type: { type: string, enum: [video, reading, quiz] } order: { type: integer } # ── Course schemas ────────────────────────────────────────────────────── Course: type: object required: [id, title, description, instructorId, instructorName, category, level, duration, color, rating, isPublished, createdAt, lessons, enrolledStudents] properties: id: { type: string } title: { type: string } description: { type: string } instructorId: { type: string } instructorName: { type: string } category: { type: string } level: { type: string } duration: { type: string } color: { type: string } rating: { type: number } isPublished: { type: boolean } createdAt: { type: string } lessons: type: array items: $ref: "#/components/schemas/Lesson" enrolledStudents: type: array items: type: string CreateCourse: type: object required: [id, title, description, instructorId, instructorName, category, level, duration, color, createdAt] properties: id: { type: string } title: { type: string } description: { type: string } instructorId: { type: string } instructorName: { type: string } category: { type: string } level: { type: string } duration: { type: string } color: { type: string } rating: { type: number } isPublished: { type: boolean } createdAt: { type: string } UpdateCourse: type: object properties: title: { type: string } description: { type: string } category: { type: string } level: { type: string } duration: { type: string } color: { type: string } rating: { type: number } isPublished: { type: boolean } EnrollRequest: type: object required: [studentId] properties: studentId: { type: string } # ── Assignment schemas ────────────────────────────────────────────────── Assignment: type: object required: [id, courseId, courseName, title, description, dueDate, maxScore] properties: id: { type: string } courseId: { type: string } courseName: { type: string } title: { type: string } description: { type: string } dueDate: { type: string } maxScore: { type: integer } CreateAssignment: type: object required: [id, courseId, courseName, title, dueDate, maxScore] properties: id: { type: string } courseId: { type: string } courseName: { type: string } title: { type: string } description: { type: string } dueDate: { type: string } maxScore: { type: integer } Submission: type: object required: [id, assignmentId, studentId, studentName, answer, status, submittedAt] properties: id: { type: string } assignmentId: { type: string } studentId: { type: string } studentName: { type: string } answer: { type: string } score: { type: integer } status: { type: string, enum: [pending, submitted, graded] } submittedAt: { type: string } SubmitRequest: type: object required: [id, studentId, studentName, answer, submittedAt] properties: id: { type: string } studentId: { type: string } studentName: { type: string } answer: { type: string } submittedAt: { type: string } GradeRequest: type: object required: [score] properties: score: { type: integer } # ── Progress schemas ──────────────────────────────────────────────────── ProgressResult: type: object required: [userId, courseId, completedLessons, percentage] properties: userId: { type: string } courseId: { type: string } completedLessons: type: array items: { type: string } percentage: { type: integer } MarkProgressRequest: type: object required: [id, userId, courseId, lessonId, completedAt] properties: id: { type: string } userId: { type: string } courseId: { type: string } lessonId: { type: string } completedAt: { type: string }