Every user account in the LMS Backend carries aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Pragyat-Nikunj/Learning-Management-System-backend/llms.txt
Use this file to discover all available pages before exploring further.
role field that controls which actions they can take. The role is stored on the User document and is verified at the controller level — endpoints check req.id against resource ownership or rely on the role value to gate access. There are three roles: student, instructor, and admin.
Role assignment
Therole field is defined in the user schema with an explicit allow-list and a default of 'student':
models/user.model.js
POST /api/v1/user/signup, the request body may include a role field. If omitted, the account is created as a student:
controllers/user.controller.js
Role is set at account creation time. There is no public endpoint to change your own role after sign-up. Role escalation requires direct database access or an admin-level operation.
Role capabilities
student — default role
student — default role
Students are the primary consumers of course content. After creating an account and signing in they can:
Enrolled courses are stored on the user document as an array of
| Action | Endpoint |
|---|---|
| View published courses | GET /api/v1/courses/published |
| Search courses by keyword | GET /api/v1/courses/search |
| View course details and lecture list | GET /api/v1/courses/:courseId |
| Purchase a course via Stripe | POST /api/v1/payments/create-checkout-session |
| List all purchased courses | GET /api/v1/payments/purchased-courses |
| Check purchase status for a course | GET /api/v1/payments/courses/:courseId/purchase-status |
| Track lecture-level progress | PATCH /api/v1/progress/:courseId/lectures/:lectureId |
| Mark a course as completed | POST /api/v1/progress/:courseId/complete |
| Reset progress on a course | POST /api/v1/progress/:courseId/reset |
| Manage their own profile and avatar | GET / PATCH /api/v1/user/profile |
{ course, enrolledAt } objects. The virtual field totalEnrolledCourses returns the count.instructor — course creators
instructor — course creators
Instructors have all student capabilities plus the ability to create and manage courses. Authorization at the controller level verifies that the requesting user (
Created courses are tracked on the user document in a
req.id) matches the course.instructor field before allowing mutations.| Action | Endpoint |
|---|---|
| Create a new course (with thumbnail) | POST /api/v1/courses |
| List courses they have created | GET /api/v1/courses/my-courses |
| Update course details or thumbnail | PATCH /api/v1/courses/:courseId |
| Add a lecture with video to a course | POST /api/v1/courses/:courseId/lectures |
createdCourses array of Course ObjectIds.admin — platform management
admin — platform management
The
admin role is defined in the schema and is a valid value that can be assigned to a user. Admin-specific route middleware is not present in the current public route definitions — admin operations are distinguished by the role value on the user document and can be used by controllers to gate privileged actions.If you are building admin tooling, check the
role field on the authenticated user’s document (User.findById(req.id)) and return a 403 if the role is not 'admin'.Role comparison table
| Capability | student | instructor | admin |
|---|---|---|---|
| Browse & search published courses | Yes | Yes | Yes |
| Purchase courses via Stripe | Yes | Yes | Yes |
| Track and reset course progress | Yes | Yes | Yes |
| Manage own profile and avatar | Yes | Yes | Yes |
| Forgot / reset password | Yes | Yes | Yes |
| Create new courses | No | Yes | Yes |
| Add lectures to own courses | No | Yes | Yes |
| Update own course details | No | Yes | Yes |
| List own created courses | No | Yes | Yes |
| Platform-level admin operations | No | No | Yes |
User document fields related to roles
The user schema stores role-relevant data that is returned onGET /api/v1/user/profile:
models/user.model.js
enrolledCourses is populated with title, thumbnail, and description when you fetch your profile, so a single request gives you the full list of courses a student is enrolled in.