A comprehensive e-learning platform built with React.js, Node.js, Express.js, and MongoDB. This platform allows users to enroll in courses, watch videos, complete assignments, and track their learning progress.
- User Authentication: JWT-based secure authentication
- Role-based Access Control: Student, Instructor, and Admin roles
- User Profiles: Customizable user profiles with avatar support
- Password Management: Secure password hashing and change functionality
- Course Creation: Instructors can create and manage courses
- Course Categories: Organized course categories (Programming, Design, Business, etc.)
- Course Reviews: Students can rate and review courses
- Course Publishing: Draft and publish course functionality
- Video Lessons: Support for video-based learning content
- Multiple Content Types: Video, text, quiz, assignment, and document lessons
- Progress Tracking: Track learning progress and completion
- Course Enrollment: Easy course enrollment system
- Certificates: Automatic certificate generation upon course completion
- Student Dashboard: Track enrolled courses and progress
- Instructor Dashboard: Manage courses and view student analytics
- Admin Dashboard: System-wide user and course management
- React.js - User interface library
- React Router - Client-side routing
- React Query - Server state management
- React Hook Form - Form handling
- Tailwind CSS - Utility-first CSS framework
- Lucide React - Icon library
- React Hot Toast - Notifications
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - NoSQL database
- Mongoose - MongoDB object modeling
- JWT - Authentication tokens
- bcryptjs - Password hashing
- Express Validator - Input validation
- Helmet - Security middleware
online-Elearning/
βββ backend/
β βββ config/
β β βββ database.js
β β βββ jwt.js
β βββ controllers/
β β βββ authController.js
β β βββ courseController.js
β β βββ enrollmentController.js
β β βββ lessonController.js
β β βββ userController.js
β βββ middleware/
β β βββ auth.js
β β βββ validation.js
β βββ models/
β β βββ User.js
β β βββ Course.js
β β βββ Lesson.js
β β βββ Enrollment.js
β βββ routes/
β β βββ auth.js
β β βββ courses.js
β β βββ enrollments.js
β β βββ lessons.js
β β βββ users.js
β βββ package.json
β βββ server.js
β βββ env.example
βββ frontend/
β βββ public/
β βββ src/
β β βββ components/
β β β βββ layout/
β β β βββ ui/
β β βββ context/
β β β βββ AuthContext.js
β β βββ pages/
β β β βββ auth/
β β β βββ dashboard/
β β β βββ instructor/
β β β βββ student/
β β β βββ admin/
β β βββ services/
β β β βββ api.js
β β β βββ authService.js
β β β βββ courseService.js
β β β βββ enrollmentService.js
β β β βββ lessonService.js
β β β βββ userService.js
β β βββ App.js
β β βββ index.js
β β βββ index.css
β βββ package.json
β βββ tailwind.config.js
β βββ postcss.config.js
βββ package.json
- Node.js (v14 or higher)
- MongoDB (local installation or MongoDB Atlas account)
- npm or yarn package manager
-
Clone the repository
git clone <repository-url> cd online-Elearning
-
Install dependencies
# Install root dependencies npm install # Install backend dependencies npm run install-server # Install frontend dependencies npm run install-client
-
Environment Setup
Backend Environment (.env)
cd backend cp env.example .envEdit the
.envfile with your configuration:# Database Configuration MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/elearning?retryWrites=true&w=majority # JWT Configuration JWT_SECRET=your_super_secret_jwt_key_here_make_it_long_and_random JWT_EXPIRE=7d # Server Configuration PORT=5000 NODE_ENV=development # Client Configuration CLIENT_URL=http://localhost:3000
Frontend Environment (optional)
cd frontend # Create .env file if you need custom API URL echo "REACT_APP_API_URL=http://localhost:5000/api" > .env
- Create a free account at MongoDB Atlas
- Create a new cluster
- Create a database user
- Get your connection string
- Add your connection string to the
MONGODB_URIin your.envfile
- Install MongoDB locally
- Start MongoDB service
- Use local connection string:
mongodb://localhost:27017/elearning
# Run both frontend and backend concurrently
npm run dev
# Or run them separately:
# Backend only (http://localhost:5000)
npm run server
# Frontend only (http://localhost:3000)
npm run client# Build frontend for production
npm run build
# Start production server
npm startThe application includes role-based authentication with three user types:
- Student:
student@demo.com/password123 - Instructor:
instructor@demo.com/password123 - Admin:
admin@demo.com/password123
- Browse and enroll in courses
- Watch lessons and track progress
- Add notes and complete assignments
- Rate and review courses
- View personal dashboard
- Create and manage courses
- Add lessons and content
- View student enrollments
- Publish/unpublish courses
- Access instructor dashboard
- Manage all users and courses
- View system-wide analytics
- Change user roles and status
- Access admin dashboard
POST /api/auth/register- Register new userPOST /api/auth/login- User loginGET /api/auth/profile- Get user profilePUT /api/auth/profile- Update profilePOST /api/auth/change-password- Change password
GET /api/courses- Get all courses (with filters)GET /api/courses/:id- Get course by IDPOST /api/courses- Create course (instructor)PUT /api/courses/:id- Update course (instructor)DELETE /api/courses/:id- Delete course (instructor)
POST /api/enrollments/course/:courseId- Enroll in courseGET /api/enrollments/my-enrollments- Get user enrollmentsPUT /api/enrollments/:id/progress- Update progress
GET /api/lessons/course/:courseId- Get course lessonsGET /api/lessons/:id- Get lesson by IDPOST /api/lessons/course/:courseId- Create lesson (instructor)POST /api/lessons/:id/complete- Mark lesson complete
- Modern Design: Clean, professional interface
- Responsive: Mobile-first responsive design
- Accessibility: WCAG compliant components
- Dark Mode Ready: Prepared for dark mode implementation
- Reusable UI Components: Button, Input, Card, Modal, etc.
- Form Handling: Robust form validation and error handling
- Loading States: Comprehensive loading and error states
- Toast Notifications: User-friendly notifications
# Build the frontend
cd frontend
npm run build
# Deploy the build folder to your hosting service# Ensure your environment variables are set
# Deploy the backend folder to your hosting serviceMake sure to set all required environment variables in your hosting platform:
MONGODB_URIJWT_SECRETNODE_ENV=productionCLIENT_URL(your frontend URL)
- User registration and login
- Course browsing and enrollment
- Lesson viewing and progress tracking
- Instructor course creation
- Admin user management
- Responsive design on mobile devices
Use tools like Postman or Insomnia to test API endpoints:
- Import the API collection
- Set up environment variables
- Test authentication flows
- Verify CRUD operations
- ESLint: JavaScript linting
- Prettier: Code formatting
- Conventional Commits: Commit message format
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
- Verify MongoDB URI is correct
- Check network access in MongoDB Atlas
- Ensure database user has proper permissions
- Verify
CLIENT_URLin backend environment - Check CORS configuration in server.js
- Verify JWT_SECRET is set
- Check token expiration settings
- Clear browser localStorage if needed
- Clear node_modules and reinstall dependencies
- Check Node.js version compatibility
- Verify environment variables are set
- User guides and tutorials will be available in the application
- Video tutorials for instructors on course creation
- Student guides for maximizing learning experience
For support and questions:
- Create an issue in the GitHub repository
- Check the documentation for common solutions
- Review the troubleshooting section
This project is licensed under the MIT License - see the LICENSE file for details.
- React.js team for the amazing framework
- Express.js community for the robust backend framework
- MongoDB for the flexible database solution
- Tailwind CSS for the utility-first CSS framework
- All open-source contributors who made this project possible
Happy Learning! π