Skip to content

Commit 9a22b03

Browse files
Piyush KumarPiyush Kumar
authored andcommitted
Cleanup code and update documentation
1 parent b99f33a commit 9a22b03

3 files changed

Lines changed: 150 additions & 48 deletions

File tree

.gitignore

Lines changed: 86 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,88 @@
1-
node_modules
2-
.env
3-
.DS_Store
4-
dist
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
518
coverage
619

7-
/src/generated/prisma
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (https://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# TypeScript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
.env.test
60+
61+
# parcel-bundler cache (https://parceljs.org/)
62+
.cache
63+
64+
# next.js build output
65+
.next
66+
67+
# nuxt.js build output
68+
.nuxt
69+
70+
# gatsby files
71+
.cache/
72+
public/
73+
74+
# vuepress build output
75+
.vuepress/dist
76+
77+
# Serverless directories
78+
.serverless/
79+
80+
# FuseBox cache
81+
.fusebox/
82+
83+
# DynamoDB Local files
84+
.dynamodb/
85+
86+
# OS metadata
87+
.DS_Store
88+
Thumbs.db

README.md

Lines changed: 61 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,85 @@
1-
# Mini LMS Backend
1+
# Learning Management System (LMS) Backend
22

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

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
1314

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
1526
- Node.js (v18+)
16-
- PostgreSQL
27+
- PostgreSQL installed and running
1728

18-
## Setup
29+
### Installation Steps
1930

20-
1. **Clone and Install**
31+
1. **Clone the Repository**
2132
```bash
22-
git clone <repo_url>
23-
cd learning_management_system
24-
./setup.sh
33+
git clone <repository-url>
34+
cd Learning_management_system
2535
```
2636

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
2941
```
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
3149
```
3250

33-
Run migrations:
51+
4. **Initialize Database**
52+
Run the migration to create tables:
3453
```bash
3554
npx prisma migrate dev --name init
3655
```
3756

38-
3. **Run Server**
57+
5. **Start the Server**
3958
```bash
4059
npm run dev
4160
```
4261

43-
## API Documentation
62+
## 📖 API Documentation (Brief)
4463

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) |
4873

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
5575

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:
5977

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.

src/validations/courseValidation.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ export const createCourseSchema = Joi.object({
55
description: Joi.string().optional()
66
});
77

8-
export const enrollSchema = Joi.object({
9-
// No body params needed strictly if using clean URLs, but maybe useful later
10-
});
8+
9+
export const enrollSchema = Joi.object({});
10+

0 commit comments

Comments
 (0)