Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

LearnHub — Full Stack E-Learning Platform

A full-featured Udemy-style learning platform built with Node.js, React, and PostgreSQL.

Features

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

Tech Stack

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)

Project Structure

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

Getting Started

Prerequisites

  • Node.js v20+
  • PostgreSQL 15+

Backend Setup

cd learnhub-backend
npm install

Create .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=7d

Create 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 dev

Frontend Setup

cd learnhub-frontend
npm install
npm run dev

Open http://localhost:5173

API Endpoints

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

Database Schema

7 tables: users, categories, courses, lessons, enrollments, lesson_progress, reviews, discussions

Roadmap

  • Cloud image and video upload (S3 / Cloudinary)
  • Stripe payment integration
  • Email notifications
  • Admin dashboard
  • Mobile app

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages