modulepackage
0.0.0-20250121163815-cbab4b0c71fc
Repository: https://github.com/htanmo/lms.git
Documentation: pkg.go.dev
# README
Learning Management System (LMS) API
A simple Learning Management System (LMS) API that allows users to manage courses, enrollments, and track student progress with role-based access for admins, instructors, and students.
Features
- User Registration and Authentication
- Role-based access control (Admin, Instructor, Student)
- Course management (create, update, delete)
- Course enrollment for students
- Progress tracking for students
Authentication
- JWT authentication for all roles.
- Roles:
admin
,instructor
,student
.
Endpoints
User Authentication
Public Routes
-
POST /api/v1/register
- Register a new user- Request Body:
{ "name": "string", "email": "string", "password": "string", "role": "admin|instructor|student" }
- Request Body:
-
POST /api/v1/login
- Login a user- Request Body:
{ "email": "string", "password": "string" }
- Request Body:
Courses
Public and Protected Routes
-
GET /api/v1/courses
- Get all available courses (Public) -
GET /api/v1/courses/{id}
- Get details of a specific course -
POST /api/v1/admin/courses
- Create a new course (Admin/Instructor)- Request Body:
{ "title": "string", "description": "string", "instructor_id": 1 }
- Request Body:
-
PUT /api/v1/admin/courses/{id}
- Update course (Instructor/Admin)- Request Body:
{ "title": "string", "description": "string", "instructor_id": 1 }
- Request Body:
-
DELETE /api/v1/admin/courses/{id}
- Delete course (Instructor/Admin)
Enrollments
Student Routes
POST /api/v1/student/courses/{id}/enroll
- Enroll a student in a courseGET /api/v1/student/courses/{id}/progress
- Get student progress for a specific course
Database Schema
Users
id
- Integer (Primary Key)name
- Stringemail
- String (Unique)password_hash
- Stringrole
- Enum (admin, instructor, student)
Courses
id
- Integer (Primary Key)title
- Stringdescription
- Stringinstructor_id
- Integer (Foreign Key to Users)
Enrollments
id
- Integer (Primary Key)course_id
- Integer (Foreign Key to Courses)student_id
- Integer (Foreign Key to Users)progress
- Integer (Percentage)
Authentication Flow
- Upon registration or login, users receive a JWT token.
- This token is required to access protected endpoints (courses, enrollments).
- Admins and instructors have higher privileges, such as managing courses.
Roles
- Admin: Can manage all users and courses.
- Instructor: Can create, update, and delete courses.
- Student: Can enroll in courses and track progress.
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author