Backend API for a comprehensive Learning Management System (LMS) / University Management Project.
"---Always Work Hard and Trust the Process---"
- ✨ Core Features
- 🛠️ Tech Stack
- 🏁 Getting Started
- 🔑 Environment Variables
- ⚡ API Endpoints
- 📚 Learn More
- 🤝 Contributing
- 📜 License
This server provides all the essential backend logic for a modern university portal:
- 🔐 Secure Authentication: Full JWT (Access & Refresh Tokens) flow with
bcryptpassword hashing. - 👮 Role-Based Access Control: Distinct roles (Student, Faculty, Admin) with protected routes using custom middleware.
- 📁 File Uploads: Integrated
multerandcloudinaryfor handling profile pictures and course materials. - ✉️ Email Service: Uses
nodemailerfor password resets and notifications. - 🛡️ Robust Validation:
- Zod / Joi: For complex schema validation on request bodies.
- Mongoose: Built-in and custom schema validations.
- ⚙️ Full User Management: Complete CRUD operations for all user roles.
- 🔑 Secure Password Handling: Features for changing, forgetting, and resetting passwords.
This project is built with a modern, type-safe, and efficient stack, as seen in package.json.
| Category | Technology |
|---|---|
| Backend Framework | Express.js |
| Language | TypeScript |
| Database | MongoDB (with Mongoose ODM) |
| Authentication | jsonwebtoken (JWT), bcrypt |
| Data Validation | zod, joi, validator |
| File Handling | multer, cloudinary |
| Email Service | nodemailer |
| API Utilities | http-status, cors, cookie-parser |
| Dev Environment | ts-node-dev, eslint |
Follow these instructions to get the server up and running on your local machine.
You must have the following installed:
- Node.js (v18.x or later recommended)
- npm (or yarn)
- A MongoDB database instance (local or cloud-hosted like MongoDB Atlas)
-
Clone the repository:
git clone [https://github.com/ashiq72/lms-server.git](https://github.com/ashiq72/lms-server.git) cd lms-server -
Install dependencies:
npm install
(Or
yarn install) -
Set up Environment Variables:
- Create a
.envfile in the root of the project. - Use the
.env.examplefile (if available) or the section below as a guide. - Fill in all required values, especially
DATABASE_URLandJWT_SECRET_KEY.
- Create a
-
For Development (with hot-reloading):
npm run start:dev
This will start the server using
ts-node-dev. -
For Production:
# 1. Build the TypeScript code into JavaScript npm run build # 2. Start the optimized server npm run start
-
To Run Linter:
npm run lint
To run this project, you will need to create a .env file with the following variables:
# Server Configuration
PORT=5000
NODE_ENV=development
# Database
DATABASE_URL="your-mongodb-connection-string"
# JWT Authentication
JWT_SECRET_KEY="your-access-token-secret"
JWT_EXPIRES_IN="1d"
JWT_REFRESH_SECRET_KEY="your-refresh-token-secret"
JWT_REFRESH_EXPIRES_IN="7d"
# Cloudinary (for file uploads)
CLOUDINARY_CLOUD_NAME="..."
CLOUDINARY_API_KEY="..."
CLOUDINARY_API_SECRET="..."
# Nodemailer (for emails)
NODEMAILER_HOST="..."
NODEMAILER_PORT="..."
NODEMAILER_USER="..."
NODEMAILER_PASS="..."
# Frontend URL
CORS_ORIGIN="http://localhost:3000"