A full-featured Udemy-style learning platform built with Node.js, React, and PostgreSQL.
Students
- Browse and search courses by keyword and level
- Enroll in courses
- Watch video lessons with progress tracking
- Mark lessons as complete with progress bar
- Post questions and replies in per-lesson discussions
- Leave star ratings and written reviews
Instructors
- Create and manage courses with full metadata
- Add text and video lessons
- Set free preview lessons visible without enrollment
- View enrolled student counts and ratings
- Publish, draft, or archive courses
Platform
- JWT authentication with role system (student / instructor / admin)
- Protected routes on frontend and backend
- REST API with consistent JSON responses
- Role-based access control on every endpoint
| Layer | Technology |
|---|---|
| Frontend | React 18, Vite, Tailwind CSS v3 |
| State | Zustand, TanStack Query |
| Backend | Node.js, Express.js |
| Database | PostgreSQL with raw SQL (pg) |
| Auth | JWT (jsonwebtoken + bcryptjs) |
| Dev Tools | Nodemon, Postman |
Image and video upload support will be added after deployment using cloud storage (S3 or Cloudinary)
LearnHub/
├── learnhub-backend/
│ ├── src/
│ │ ├── config/
│ │ │ ├── db.js
│ │ │ ├── env.js
│ │ │ └── schema.sql
│ │ ├── controllers/
│ │ ├── middleware/
│ │ ├── models/
│ │ ├── routes/
│ │ ├── services/
│ │ └── utils/
│ ├── package.json
│ └── server.js
│
├── learnhub-frontend/
│ ├── public/
│ ├── src/
│ │ ├── api/
│ │ ├── assets/
│ │ ├── components/
│ │ │ ├── common/
│ │ │ ├── course/
│ │ │ └── layout/
│ │ ├── pages/
│ │ │ ├── auth/
│ │ │ ├── instructor/
│ │ │ └── student/
│ │ ├── store/
│ │ ├── utils/
│ │ ├── App.jsx
│ │ └── main.jsx
│ ├── package.json
│ └── vite.config.js
│
└── README.md- Node.js v20+
- PostgreSQL 15+
cd learnhub-backend
npm installCreate .env file:
PORT=5000
NODE_ENV=development
DB_HOST=localhost
DB_PORT=5432
DB_NAME=learnhub
DB_USER=postgres
DB_PASSWORD=your_postgres_password
JWT_SECRET=your_jwt_secret_key
JWT_EXPIRES_IN=7dCreate the database and run the schema:
psql -U postgres -c "CREATE DATABASE learnhub;"
psql -U postgres -d learnhub -f src/config/schema.sql
npm run devcd learnhub-frontend
npm install
npm run devOpen http://localhost:5173
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /api/auth/register | — | Register student or instructor |
| POST | /api/auth/login | — | Login and receive JWT |
| GET | /api/auth/me | ✓ | Get own profile |
| GET | /api/courses | — | List published courses |
| POST | /api/courses | Instructor | Create a course |
| PUT | /api/courses/:id | Instructor | Update course |
| DELETE | /api/courses/:id | Instructor | Delete course |
| GET | /api/courses/instructor/me | Instructor | Get own courses |
| GET | /api/lessons/course/:id | — | Get lessons for a course |
| POST | /api/lessons | Instructor | Add lesson to course |
| PUT | /api/lessons/reorder | Instructor | Reorder lessons |
| DELETE | /api/lessons/:id | Instructor | Delete lesson |
| POST | /api/lessons/:id/progress | Student | Mark lesson complete |
| GET | /api/lessons/progress/:courseId | Student | Get course progress |
| POST | /api/enrollments/:courseId | Student | Enroll in course |
| DELETE | /api/enrollments/:courseId | Student | Unenroll from course |
| GET | /api/enrollments/my/courses | Student | Get enrolled courses |
| GET | /api/enrollments/:courseId/check | ✓ | Check enrollment status |
| GET | /api/enrollments/:courseId/students | Instructor | Get course students |
| GET | /api/reviews/:courseId | — | Get course reviews |
| POST | /api/reviews/:courseId | Student | Submit review |
| DELETE | /api/reviews/:courseId | Student | Delete review |
| GET | /api/discussions/lesson/:id | ✓ | Get lesson discussions |
| POST | /api/discussions | ✓ | Post question or reply |
| PUT | /api/discussions/:id | ✓ | Edit post |
| DELETE | /api/discussions/:id | ✓ | Delete post |
7 tables: users, categories, courses, lessons, enrollments, lesson_progress, reviews, discussions
- Cloud image and video upload (S3 / Cloudinary)
- Stripe payment integration
- Email notifications
- Admin dashboard
- Mobile app