A full-stack MERN application for online learning. Instructors create and manage courses, students enroll, track progress, and leave reviews. Built with a premium, Udemy-inspired dark-themed UI.
- JWT-based authentication (register, login, logout)
- Role-based access control — Instructor and Student roles
- Protected routes on both frontend and backend
- Create, edit, and delete courses
- Add, edit, reorder, and delete lessons within courses
- Dashboard with total enrollments, average ratings, course analytics
- Publish/unpublish courses
- Browse and search courses by keyword, category, level, and rating
- Enroll and unenroll from courses
- Watch lessons with embedded video player
- Track progress — mark lessons as complete, see % completed per course
- Rate and review courses (one review per course)
- Personal dashboard with enrolled courses and progress bars
- Premium dark-themed design with glassmorphism effects
- Responsive layout (desktop, tablet, mobile)
- Smooth animations and micro-interactions
- Interactive star ratings, progress bars, and more
| Layer | Technology |
|---|---|
| Frontend | React.js + Vite + Plain CSS |
| Backend | Node.js + Express.js |
| Database | MongoDB + Mongoose |
| Auth | JWT + bcryptjs |
learnhub/
├── client/ # React frontend (Vite)
│ └── src/
│ ├── components/ # Reusable UI components
│ ├── context/ # Auth context (Context API)
│ ├── pages/ # Page components
│ ├── utils/ # API utility
│ ├── App.jsx # Root with routing
│ └── index.css # Global design system
├── server/ # Express backend
│ ├── config/ # Database config
│ ├── controllers/ # Route handlers
│ ├── middleware/ # Auth & role middleware
│ ├── models/ # Mongoose schemas
│ ├── routes/ # Express routes
│ └── server.js # Entry point
├── package.json # Root scripts (concurrently)
└── README.md
User → role: instructor / student
Course → ref: User (instructor), category, lessons[]
Lesson → ref: Course, title, videoUrl, order
Enrollment → ref: User + Course, completedLessons[], progress%
Review → ref: User + Course, rating, comment
- Node.js v18+ — Download
- MongoDB — Local install or MongoDB Atlas (cloud)
- Git — Download
git clone <your-repo-url>
cd learnhubcp server/.env.example server/.envEdit server/.env with your values:
PORT=5000
MONGO_URI=mongodb://localhost:27017/learnhub
JWT_SECRET=your_super_secret_jwt_key_here
JWT_EXPIRE=7dUsing MongoDB Atlas? Replace
MONGO_URIwith your Atlas connection string:mongodb+srv://<username>:<password>@cluster0.xxxxx.mongodb.net/learnhub
# Install all dependencies (root, server, client)
npm run install-allOr install individually:
# Root dependencies
npm install
# Server dependencies
cd server && npm install
# Client dependencies
cd ../client && npm install# From root — runs both server and client concurrently
npm run devOr run separately:
# Terminal 1: Backend (port 5000)
npm run server
# Terminal 2: Frontend (port 5173)
npm run clientNavigate to http://localhost:5173
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /register |
Public | Register a new user |
| POST | /login |
Public | Login, returns JWT |
| GET | /me |
Required | Get current user |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| GET | / |
Public | List courses (search/filter/page) |
| GET | /:id |
Public | Get course details |
| POST | / |
Instructor | Create course |
| PUT | /:id |
Instructor | Update course (owner only) |
| DELETE | /:id |
Instructor | Delete course + cascade |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| GET | / |
Public | Get course lessons |
| POST | / |
Instructor | Add lesson |
| PUT | /:lessonId |
Instructor | Edit lesson |
| DELETE | /:lessonId |
Instructor | Delete lesson |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /:courseId/enroll |
Student | Enroll in course |
| DELETE | /:courseId/unenroll |
Student | Unenroll from course |
| GET | /my |
Student | My enrollments |
| GET | /:courseId/check |
Auth | Check enrollment |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| PUT | /:enrollmentId/complete/:lessonId |
Student | Mark complete |
| PUT | /:enrollmentId/uncomplete/:lessonId |
Student | Mark incomplete |
| GET | /:enrollmentId |
Auth | Get progress |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| GET | /courses/:courseId |
Public | Get course reviews |
| POST | /courses/:courseId |
Student | Add review |
| PUT | /:reviewId |
Student | Edit review |
| DELETE | /:reviewId |
Student | Delete review |
The UI features a premium dark theme with:
- Deep purple (#6C3CE1) primary + teal (#00C9A7) accent palette
- Glassmorphism effects on cards and navigation
- Smooth micro-animations and transitions
- Inter font from Google Fonts
- Fully responsive design (desktop, tablet, mobile)
| Skill | Implementation |
|---|---|
| Role-based Auth | Instructor / Student middleware |
| Complex MongoDB | User → Course → Lesson → Enrollment → Review |
| REST API Design | 5 models, 6 route groups, full CRUD |
| Business Logic | Progress tracking, enrollment system |
| React | Dashboards, protected routes, Context API |
| Real Product Feel | Udemy-style course platform with premium UI |
MIT License — feel free to use this project for learning and portfolios.