|
1 | | -# Mini LMS Backend |
| 1 | +# Learning Management System (LMS) Backend |
2 | 2 |
|
3 | | -A production-ready Learning Management System (LMS) backend built with Node.js, Express, and PostgreSQL. |
| 3 | +## 📌 Project Overview |
| 4 | +A scalable backend platform designed for managing courses, teachers, and students, inspired by real-world learning management systems. This project provides a robust API for course creation, student enrollment, assignment management, and submissions. |
4 | 5 |
|
5 | | -## Tech Stack |
6 | | -- **Runtime**: Node.js (LTS) |
7 | | -- **Framework**: Express.js |
8 | | -- **Database**: PostgreSQL |
9 | | -- **ORM**: Prisma |
10 | | -- **Auth**: JWT & bcrypt |
11 | | -- **Validation**: Joi |
12 | | -- **Testing**: Jest & Supertest |
| 6 | +## 🚀 Tech Stack |
| 7 | +- **Runtime:** Node.js |
| 8 | +- **Framework:** Express.js |
| 9 | +- **Database:** PostgreSQL (via Prisma ORM) |
| 10 | +- **Language:** JavaScript (ES6 modules) |
| 11 | +- **Authentication:** JWT (JSON Web Tokens) |
| 12 | +- **Validation:** Joi |
| 13 | +- **Security:** Helmet, CORS, bcrypt |
13 | 14 |
|
14 | | -## Prerequisites |
| 15 | +## ✨ Features |
| 16 | +- **User Authentication:** Secure signup and login for Students and Teachers. |
| 17 | +- **Role-Based Access Control (RBAC):** Distinct permissions for Teachers (create courses/assignments) and Students (enroll/submit work). |
| 18 | +- **Course Management:** CRUD operations for courses. |
| 19 | +- **Assignment System:** Create, view, and submit assignments. |
| 20 | +- **Enrollment Management:** Track student course enrollments. |
| 21 | +- **Secure & Optimized:** Centralized error handling, input validation, and optimized SQL queries. |
| 22 | + |
| 23 | +## 🛠️ Setup & Installation |
| 24 | + |
| 25 | +### Prerequisites |
15 | 26 | - Node.js (v18+) |
16 | | -- PostgreSQL |
| 27 | +- PostgreSQL installed and running |
17 | 28 |
|
18 | | -## Setup |
| 29 | +### Installation Steps |
19 | 30 |
|
20 | | -1. **Clone and Install** |
| 31 | +1. **Clone the Repository** |
21 | 32 | ```bash |
22 | | - git clone <repo_url> |
23 | | - cd learning_management_system |
24 | | - ./setup.sh |
| 33 | + git clone <repository-url> |
| 34 | + cd Learning_management_system |
25 | 35 | ``` |
26 | 36 |
|
27 | | -2. **Database Setup** |
28 | | - Update `.env` with your database URL: |
| 37 | +2. **Run Setup Script** |
| 38 | + This script installs dependencies, sets up the environment file, and generates the Prisma client. |
| 39 | + ```bash |
| 40 | + ./setup.sh |
29 | 41 | ``` |
30 | | - DATABASE_URL="postgresql://user:password@localhost:5432/lms_db?schema=public" |
| 42 | + |
| 43 | +3. **Configure Environment Variables** |
| 44 | + Open `.env` and update the `DATABASE_URL` with your PostgreSQL credentials: |
| 45 | + ```env |
| 46 | + DATABASE_URL="postgresql://USER:PASSWORD@localhost:5432/lms_db?schema=public" |
| 47 | + JWT_SECRET="your_super_secret_key" |
| 48 | + PORT=3000 |
31 | 49 | ``` |
32 | 50 |
|
33 | | - Run migrations: |
| 51 | +4. **Initialize Database** |
| 52 | + Run the migration to create tables: |
34 | 53 | ```bash |
35 | 54 | npx prisma migrate dev --name init |
36 | 55 | ``` |
37 | 56 |
|
38 | | -3. **Run Server** |
| 57 | +5. **Start the Server** |
39 | 58 | ```bash |
40 | 59 | npm run dev |
41 | 60 | ``` |
42 | 61 |
|
43 | | -## API Documentation |
| 62 | +## 📖 API Documentation (Brief) |
44 | 63 |
|
45 | | -### Auth |
46 | | -- `POST /auth/register` - Register a new user (Role: TEACHER, STUDENT) |
47 | | -- `POST /auth/login` - Login |
| 64 | +| Method | Endpoint | Description | Auth Required | |
| 65 | +| :--- | :--- | :--- | :--- | |
| 66 | +| **POST** | `/auth/register` | Register a new user | No | |
| 67 | +| **POST** | `/auth/login` | Login user | No | |
| 68 | +| **POST** | `/courses` | Create a new course | Yes (Teacher) | |
| 69 | +| **GET** | `/courses` | List all courses | Yes | |
| 70 | +| **POST** | `/courses/:id/enroll` | Enroll in a course | Yes (Student) | |
| 71 | +| **POST** | `/assignments` | Create assignment | Yes (Teacher) | |
| 72 | +| **POST** | `/assignments/:id/submit` | Submit assignment | Yes (Student) | |
48 | 73 |
|
49 | | -### Courses |
50 | | -- `GET /courses` - List all courses |
51 | | -- `POST /courses` - Create a course (Teacher only) |
52 | | -- `POST /courses/:id/enroll` - Enroll in a course (Student only) |
53 | | -- `GET /courses/:id/assignments` - Get assignments for a course |
54 | | -- `POST /courses/:id/assignments` - Create assignment (Teacher only) |
| 74 | +## ✅ Fulfillment of Requirements |
55 | 75 |
|
56 | | -### Assignments & Submissions |
57 | | -- `POST /assignments/:id/submit` - Submit an assignment (Student only) |
58 | | -- `GET /assignments/:id/submissions` - Get submissions (Teacher only) |
| 76 | +This project successfully implements the "Learning Management Backend Platform" requirements as follows: |
59 | 77 |
|
60 | | -## Testing |
61 | | -Run unit and integration tests: |
62 | | -```bash |
63 | | -npm test |
64 | | -``` |
| 78 | +- **Scalable Backend Platform:** Built with Node.js and Express to handle concurrent requests efficiently. |
| 79 | +- **RESTful APIs:** Clean and structured API endpoints for managing users, courses, assignments, and submissions. |
| 80 | +- **Role-Based Access Control (RBAC):** Middleware (`authMiddleware.js`) ensures strict separation between Teacher and Student capabilities. |
| 81 | +- **Relational SQL Schema:** Designed using Prisma with PostgreSQL to define clear relationships between Users, Courses, Enrichments, and Assignments. |
| 82 | +- **Data Integrity & Performance:** Uses Foreign Keys and optimized queries (via Prisma) to ensure data consistency. |
| 83 | +- **Input Validation & Error Handling:** Uses `Joi` for strict input validation and a centralized error handling middleware in `app.js`. |
| 84 | +- **Developer Experience:** Includes a `setup.sh` script, organized project structure, and clear documentation for easy onboarding. |
| 85 | +- **Clean Code & Git:** Modular code structure (controllers, services, routes) and standard `.gitignore` for a clean repository. |
0 commit comments