A full-stack course selling application with user authentication, course management, and purchase functionality.
This is a complete course selling platform that allows:
- Users to browse, purchase, and view courses
- Admins to create, edit, and manage courses
- Secure authentication with JWT tokens
- Modern, responsive UI with React and Tailwind CSS
Live demo โ course-hub-gamma.vercel.app
Course-Hub/
โโโ backend/ # Backend API Server
โ โโโ routes/ # API Routes
โ โ โโโ user.js # User authentication & purchases
โ โ โโโ admin.js # Admin authentication & course management
โ โ โโโ course.js # Course purchasing
โ โโโ middleware/ # Authentication middleware
โ โ โโโ user.js # User JWT verification
โ โ โโโ admin.js # Admin JWT verification
โ โโโ db.js # MongoDB schemas & models
โ โโโ seed.js # Demo course data seeding
โ โโโ index.js # Main server file
โ โโโ config.js # Environment configuration
โ โโโ .env # Environment variables
โ โโโ package.json # Backend dependencies
โโโ frontend/ # React Frontend
โโโ src/
โ โโโ components/
โ โ โโโ Auth/ # Login & Signup components
โ โ โโโ User/ # User dashboard & course listing
โ โ โโโ Admin/ # Admin dashboard
โ โ โโโ Layout/ # Navigation components
โ โโโ context/ # React Context for authentication
โ โโโ services/ # API service layer
โ โโโ App.js # Main React app
โโโ public/ # Static assets
โโโ package.json # Frontend dependencies
โโโ tailwind.config.js # Tailwind CSS configuration
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - Database
- Mongoose - ODM for MongoDB
- JWT - Authentication tokens
- bcrypt - Password hashing
- Zod - Input validation
- CORS - Cross-origin resource sharing
- React 18 - UI framework
- React Router - Client-side routing
- Axios - HTTP client
- Tailwind CSS - Styling framework
- Lucide React - Icon library
- Node.js (v14 or higher)
- MongoDB (local or cloud instance)
- npm or yarn
cd backend
npm installCreate a .env file in the backend directory:
MONGODB_URI=mongodb://localhost:27017/course-selling-app
JWT_ADMIN_PASSWORD=your-secret-admin-key
JWT_USER_PASSWORD=your-secret-user-keynpm startThe backend will run on http://localhost:3000
cd ../frontend
npm installnpm startThe frontend will run on http://localhost:3001
- Email:
admin@demo.com - Password:
admin123
- Visit
/signupto create new user or admin accounts - Choose between User and Admin roles during signup
- User registration and login
- Browse available courses
- View course details
- Purchase courses
- View purchased courses in dashboard
- Track spending and course statistics
- Admin registration and login
- Create new courses
- Edit existing courses
- View all courses
- Track course statistics
- Course management dashboard
- Responsive design (mobile & desktop)
- JWT-based authentication
- Role-based access control
- Modern UI with Tailwind CSS
- Error handling and loading states
- Form validation
POST /api/v1/user/signup- Register new userPOST /api/v1/user/signin- User loginGET /api/v1/user/purchases- Get user's purchased courses
POST /api/v1/admin/signup- Register new adminPOST /api/v1/admin/signin- Admin loginPOST /api/v1/admin/course- Create new coursePUT /api/v1/admin/course/:id- Update courseGET /api/v1/admin/course/bulk- Get all courses
POST /api/v1/course/purchase- Purchase a courseGET /api/v1/course/preview- Course preview
{
email: String (unique),
password: String (hashed),
firstName: String,
lastName: String
}{
email: String (unique),
password: String (hashed),
firstName: String,
lastName: String
}{
title: String,
description: String,
price: Number,
imageUrl: String (optional),
creatorId: ObjectId (references Admin)
}{
userId: ObjectId (references User),
courseId: ObjectId (references Course)
}- Login page with user/admin toggle
- Signup page with role selection
- Form validation and error handling
- Landing page with featured courses
- Course listing with search and filters
- Course purchase flow
- User dashboard with purchased courses
- Statistics and progress tracking
- Admin dashboard with course statistics
- Course creation/editing forms
- Course management grid
- Revenue and student metrics
The application automatically seeds 8 demo courses on first startup:
- Complete Web Development Bootcamp
- Python for Data Science & Machine Learning
- iOS & Swift - The Complete iOS App Development
- Angular - The Complete Guide
- Node.js - The Complete Guide
- Docker & Kubernetes: The Practical Guide
- React Native - The Practical Guide
- AWS Certified Solutions Architect
- Password hashing with bcrypt
- JWT token authentication
- Role-based access control
- Input validation with Zod
- CORS protection
- Add course deletion functionality
- Implement payment integration
- Add course ratings and reviews
- Implement search and filtering
- Add course categories
- Implement user profiles
- Add course progress tracking
- Set production environment variables
- Build and deploy to cloud platform (Heroku, AWS, etc.)
- Configure production MongoDB instance
- Run
npm run buildto create production build - Deploy build folder to static hosting (Netlify, Vercel, etc.)
- Configure API endpoint for production