Skip to main content

Documentation 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.

The LMS Backend runs as a local Node.js server on port 4000. You will clone the repository, install dependencies, set up your environment variables, start the server with nodemon, verify it is healthy, and then register your first user account.
You need Node.js 18 or later, npm, and a running MongoDB instance (local or Atlas) before you begin.
1

Clone the repository and install dependencies

Clone the repository and install all npm dependencies:
git clone https://github.com/Pragyat-Nikunj/Learning-Management-System-backend.git
cd Learning-Management-System-backend
npm install
The install pulls in Express 5, Mongoose, Stripe, Razorpay, Cloudinary, Multer, Helmet, and the rest of the security middleware declared in package.json.
2

Create your .env file

Create a .env file in the project root and fill in your credentials:
touch .env
Open .env in your editor. At minimum you must set MONGO_URI, SECRET_KEY, and PORT before the server will start. Stripe and Cloudinary keys are required for payment and upload features respectively.See Environment Setup for a full description of every variable.
Never commit your .env file. The repository’s .gitignore excludes it by default — confirm this before pushing.
3

Start the development server

Start the server with hot reload via nodemon:
npm run dev
When the server is ready you will see:
Server is running at 4000 in development mode
MONGODB CONNECTED SUCCESSFULLY
The server listens at http://localhost:4000. In development mode, Morgan logs every incoming request to your terminal and Mongoose logs all database queries.
4

Verify the server with the healthcheck endpoint

Confirm the server and database are both healthy:
curl http://localhost:4000/api/v1/healthcheck
A healthy response looks like this:
{
  "status": "OK",
  "timeStamp": "2026-05-07T10:00:00.000Z",
  "services": {
    "databases": {
      "status": "healthy",
      "details": {
        "isConnected": true,
        "readyState": "connected",
        "host": "localhost",
        "name": "lms"
      }
    },
    "server": {
      "status": "healthy",
      "uptime": 4.21,
      "memoryUsage": {
        "rss": 52428800,
        "heapTotal": 20971520,
        "heapUsed": 15728640,
        "external": 1048576
      }
    }
  }
}
If databases.status is "unhealthy", check that your MONGO_URI in .env is correct and that your MongoDB instance is reachable.
5

Register your first user

Create a user account by posting to the signup endpoint:
curl -X POST http://localhost:4000/api/v1/user/signup \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Ada Lovelace",
    "email": "ada@example.com",
    "password": "securepassword123",
    "role": "student"
  }'
A successful response sets a token HTTP-only cookie and returns:
{
  "success": true,
  "message": "Account created successfully",
  "user": {
    "_id": "...",
    "name": "Ada Lovelace",
    "email": "ada@example.com",
    "role": "student",
    "avatar": "default-avatar.png",
    "enrolledCourses": [],
    "createdCourses": []
  },
  "token": "<signed-jwt>"
}
The token cookie is sent automatically by the server and must be included in subsequent requests to protected endpoints. Use curl -b cookies.txt -c cookies.txt or a client like Postman that handles cookies automatically.
To create an instructor account, set "role": "instructor" in the request body. Instructor accounts can create courses and add lectures.

What to do next

Environment Setup

Full reference for every environment variable — database, auth, payments, and media storage.

API Reference

Explore all endpoints with complete request/response documentation.

Authentication

Understand how JWT cookies work and how to call protected routes.

Payments

Set up Stripe Checkout and test webhooks with the Stripe CLI.

Build docs developers (and LLMs) love