A full-stack course management application built with React, Node.js, Express, and PostgreSQL/Prisma. Features JWT authentication, role-based access control, complete course CRUD operations, and enrollment management.
- User Registration with email verification
- Secure Login with JWT tokens
- Role-Based Access Control (ADMIN / USER)
- Password hashing with bcrypt
- Automatic token expiration handling
- Browse all available courses
- Create courses (Admin only)
- Update course details (Admin only)
- Delete courses (Admin only)
- View course details
- Responsive course cards
- Enroll in available courses
- View enrolled courses
- Track enrollment history
- Prevent duplicate enrollments
- Clean, modern design with Tailwind CSS
- Responsive layouts for all devices
- Navigation bar with user menu
- Protected routes for authenticated users
- Admin panel for course management
- Swagger documentation
- Interactive API testing
- Runtime: Node.js
- Framework: Express.js
- Database: PostgreSQL
- ORM: Prisma
- Authentication: JWT + bcrypt
- Validation: Zod
- API Docs: Swagger/OpenAPI
- Library: React 19
- Build Tool: Vite
- Styling: Tailwind CSS
- HTTP Client: Axios
- Routing: React Router v7
Course-Management-System/
βββ backend/
β βββ prisma/
β β βββ schema.prisma # Database schema
β βββ src/
β β βββ config/
β β β βββ db.js # Database connection
β β β βββ swagger.js # Swagger configuration
β β βββ controllers/ # Business logic
β β β βββ auth.controller.js
β β β βββ course.controller.js
β β β βββ enrollment.controller.js
β β βββ middleware/ # Express middleware
β β β βββ auth.middleware.js
β β β βββ role.middleware.js
β β β βββ error.middleware.js
β β βββ routes/ # API routes
β β β βββ auth.routes.js
β β β βββ course.routes.js
β β β βββ enrollment.routes.js
β β βββ validations/
β β β βββ auth.validation.js
β β βββ app.js
β β βββ server.js
β βββ .env
β βββ package.json
β βββ README.md
β
βββ frontend/
βββ src/
β βββ components/
β β βββ Navbar.jsx # Navigation bar
β β βββ CourseCard.jsx # Course display card
β β βββ Footer.jsx # Footer component
β βββ pages/
β β βββ Login.jsx # Login page
β β βββ Register.jsx # Registration page
β β βββ Dashboard.jsx # Main courses page
β β βββ CourseDetail.jsx # Single course view
β β βββ MyEnrollments.jsx # User's courses
β β βββ AdminPanel.jsx # Admin management
β βββ routes/
β β βββ ProtectedRoute.jsx # Auth-protected routes
β βββ services/
β β βββ api.js # API client configuration
β βββ App.jsx
β βββ main.jsx
βββ package.json
βββ vite.config.js
- Node.js 16+
- PostgreSQL 12+
- Git
- Navigate to backend
cd backend- Install dependencies
npm install- Configure environment variables (
.envfile provided)
DATABASE_URL="postgresql://postgres:Ankit@ 123@localhost:5432/course_management"
JWT_SECRET="supersecretkey"
PORT=5001- Initialize database
npx prisma migrate dev --name init
npx prisma db push- Start development server
npm run devBackend runs on: http://localhost:5001
- Navigate to frontend
cd frontend- Install dependencies
npm install- Start development server
npm run devFrontend runs on: http://localhost:5173
POST /api/v1/auth/register - Register new user
POST /api/v1/auth/login - Login user
GET /api/v1/courses - Get all courses
GET /api/v1/courses/:id - Get single course
POST /api/v1/courses - Create course (Admin)
PUT /api/v1/courses/:id - Update course (Admin)
DELETE /api/v1/courses/:id - Delete course (Admin)
POST /api/v1/enrollments/:courseId - Enroll in course
GET /api/v1/enrollments/my-courses - Get user enrollments
GET /api-docs - Swagger UI
- Register: User creates account with email and password
- Login: Credentials validated, JWT token issued
- Token Storage: Token saved in localStorage
- Requests: Token automatically attached to all API requests
- Token Expiration: 1 day validity, automatic redirect on expiration
The Course Management System includes advanced authentication and account security features to enhance user protection and improve authentication reliability.
To ensure only valid users can register, the system supports Email OTP Verification using the Brevo Email API.
- OTP sent to user's registered email
- Secure email verification flow
- Prevents fake account registrations
- OTP validation before account activation
- Environment-based API key management
User Registration
β
Generate OTP
β
Send OTP via Brevo API
β
User Enters OTP
β
OTP Validation
β
Account Verified Successfully
BREVO_API_KEY=your_brevo_api_key
BREVO_SENDER_EMAIL=your_verified_email
BREVO_SENDER_NAME=Course Management SystemThe application supports secure password reset functionality through email verification.
- Forgot password request API
- Secure reset token generation
- Password reset email delivery
- Token expiration handling
- Secure password update flow
User Clicks Forgot Password
β
Enter Registered Email
β
Generate Reset Token
β
Send Reset Link via Email
β
User Opens Reset Link
β
Create New Password
β
Password Updated Successfully
Authenticated users can securely change their password from their account dashboard.
- Verify old password before update
- Secure password hashing using bcrypt
- Protected route access
- JWT authentication required
User Logged In
β
Enter Current Password
β
Enter New Password
β
Verify Existing Password
β
Hash New Password
β
Password Updated Successfully
- Secure JWT Authentication
- Password Hashing using bcrypt
- Email Verification System
- Protected Password Reset Flow
- Token Expiration Handling
- Input Validation using Zod
- Centralized Error Handling
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/auth/send-otp | Send email OTP |
| POST | /api/v1/auth/verify-otp | Verify email OTP |
| POST | /api/v1/auth/forgot-password | Send otp |
| POST | /api/v1/auth/reset-password | Reset password |
| PUT | /api/v1/auth/change-password | Change current password |
- OTP Expiration Timer
- Resend OTP Feature
- Multi-Factor Authentication (MFA)
- Refresh Token Authentication
- Redis-based OTP Storage
- Rate Limiting for OTP APIs
- Queue-Based Email Delivery System
- β Create, read, update, delete courses
- β View admin panel
- β Manage all courses
- β View all enrollments
- β Browse courses
- β Enroll in courses
- β View enrolled courses
- β View course details
- β Cannot create/edit/delete courses
-
Register
- Click "Register" on login page
- Fill in name, email, password
- Select USER role
- Click Register
-
Login
- Enter email and password
- Click Login button
-
Browse Courses
- View courses on Dashboard
- Click "View Details" for more info
- Click "Enroll" to enroll
-
Manage Enrollments
- Click "My Enrollments" in navbar
- View all enrolled courses
- Click course to view details
-
Setup
- During registration, select ADMIN role
- Login with admin credentials
-
Manage Courses
- Click "Admin Panel" in navbar
- Create new courses
- Edit existing courses
- Delete courses
# Register
curl -X POST http://localhost:5001/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{"name":"John","email":"john@example.com","password":"123456","role":"USER"}'
# Login
curl -X POST http://localhost:5001/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"john@example.com","password":"123456"}'
# Get Courses
curl http://localhost:5001/api/v1/courses-
Backend Feature
- Create controller in
src/controllers/ - Add routes in
src/routes/ - Update Prisma schema if needed
- Run migration:
npx prisma migrate dev
- Create controller in
-
Frontend Feature
- Create component in
src/components/ - Create page in
src/pages/ - Update routes in
App.jsx - Add API calls to
src/services/api.js
- Create component in
# Create migration
npx prisma migrate dev --name feature_name
# Reset database (dev only)
npx prisma migrate reset| Issue | Solution |
|---|---|
| Database connection failed | Check PostgreSQL running, verify DATABASE_URL |
| Token expired | Login again, token valid for 1 day |
| CORS error | Ensure frontend URL is http://localhost:5173 |
| Port 5001 in use | Change PORT in .env or kill process |
| Dependencies not found | Run npm install in both folders |
| Database tables missing | Run npx prisma migrate dev |
- Payment gateway integration (Stripe/Razorpay)
- Course ratings and reviews
- Video hosting and streaming
- Student progress tracking
- Email notifications
- Advanced search and filters
- Course categories and tags
- Instructor profiles
- Certificate generation
- Mobile application
- Unit and E2E tests
- Performance optimization
ISC
Contributions are welcome! Please feel free to submit issues or pull requests.
For issues or questions:
- Check the troubleshooting section
- Review API documentation at
/api-docs - Check console for error messages
- Create an issue in the repository
Happy Learning! π
Swagger Docs:
http://localhost:5000/api-docs- Redis Caching
- Docker Containerization
- Microservices Architecture
- Rate Limiting
- Load Balancing
- CI/CD Pipeline
Ankit Bowade