- Project Overview
- Purpose & Vision
- Technology Stack
- Project Architecture
- Database Models
- Authentication System
- Course Management
- Payment System
- Refund Management
- Sales & Discount System
- User Management
- Admin Panel
- API Endpoints
- Security Features
- Installation & Setup
EduLearn is a Learning Management System (LMS) built with Next.js 14 and modern web technologies. It provides a platform for online education with role-based access for students, teachers, and administrators.
- Role-Based Access Control: Separate interfaces for Students, Teachers, and Admins
- Payment Processing: Integrated with Razorpay for course purchases
- Refund System: Automated refund processing with approval workflows
- Dynamic Pricing: Sales and coupon management
- User Management: Complete admin panel for user oversight
- Online Education Platform: Enable teachers to create and sell courses
- Student Learning Hub: Provide students with course access and progress tracking
- Administrative Control: Complete platform management through admin panel
- Secure Transactions: Handle payments and refunds securely
- Students: Purchase and access courses
- Teachers: Create, manage, and sell courses
- Administrators: Oversee platform operations and user management
- Next.js 14 (App Router)
- React 18
- TypeScript
- Tailwind CSS
- Shadcn/UI Components
- Lucide React Icons
- Next.js API Routes
- MongoDB with Mongoose
- NextAuth.js for Authentication
- Razorpay for Payments
- ESLint & Prettier
- TypeScript Compiler
- Environment Variables
learning-management-system/
βββ email-templates/ # Email Templates
βββ public/ # Static assets
βββ src/
β βββ app/ # Next.js App Router
β β βββ (auth)/ # Auth-protected routes
β β β βββ admin/ # Admin panel pages
β β β βββ student/ # Student dashboard
β β β βββ teacher/ # Teacher dashboard
β β βββ api/ # Backend API Routes
β β β βββ admin/ # Admin operations
β β β βββ auth/ # Authentication
β β β βββ courses/ # Course CRUD
β β β βββ coupons/ # Coupon management
β β β βββ payments/ # Payment processing
β β β βββ refund/ # Refund processing
β β β βββ request-refund/ # Refund requests
β β β βββ sales/ # Sales management
β β βββ refund/ # Refund UI pages
β β βββ globals.css # Global styles
β βββ components/ # Reusable UI components
β β βββ ui/ # Shadcn UI components
β β βββ animations/ # Animation components
β βββ lib/ # Utility libraries
β β βββ auth.ts # NextAuth configuration
β β βββ dbConnect.ts # MongoDB connection
β β βββ utils.ts # Helper functions
β βββ models/ # Mongoose schemas
β β βββ admin.ts
β β βββ coupon.ts
β β βββ course.ts
β β βββ payment.ts
β β βββ refund.ts
β β βββ request-refund.ts
β β βββ sales.ts
β β βββ student.ts
β β βββ teacher.ts
β βββ types/ # TypeScript definitions
βββ middleware.ts # Next.js middleware
βββ package.json # Dependencies
{
name: String, // Full name
email: String, // Unique email
password: String, // Hashed password
role: "student", // User role
purchasedCourses: [ObjectId], // Course references
isActive: Boolean, // Account status
createdAt: Date,
updatedAt: Date
}
{
name: String, // Full name
email: String, // Unique email
password: String, // Hashed password
role: "teacher", // User role
coursesCreated: [ObjectId], // Created courses
isActive: Boolean, // Account status
createdAt: Date,
updatedAt: Date
}
{
name: String, // Full name
email: String, // Unique email
password: String, // Hashed password
role: "admin", // User role
isActive: Boolean, // Account status
createdAt: Date,
updatedAt: Date
}
{
name: String, // Course title
description: String, // Course description
price: Number, // Course price
teacher: ObjectId, // Teacher reference
category: String, // Course category
level: String, // Difficulty level
thumbnail: String, // Course image
isPublished: Boolean, // Publication status
totalStudents: Number, // Enrollment count
totalRevenue: Number, // Total earnings
createdAt: Date,
updatedAt: Date
}
{
student: ObjectId, // Student reference
course: ObjectId, // Course reference
amount: Number, // Payment amount
razorpayPaymentId: String, // Razorpay payment ID
razorpayOrderId: String, // Razorpay order ID
status: String, // Payment status
createdAt: Date,
updatedAt: Date
}
{
teacher: ObjectId, // Teacher reference
course: ObjectId, // Course reference
amount: Number, // Sale price
saleTime: Date, // Sale start time
expiryTime: Date, // Sale end time
createdAt: Date,
updatedAt: Date
}
{
code: String, // Coupon code
discountPercentage: Number, // Percentage discount
discountAmount: Number, // Fixed discount
expiresAt: Date, // Expiry date
course: ObjectId, // Course reference (optional)
createdBy: ObjectId, // Creator reference
isActive: Boolean, // Coupon status
createdAt: Date,
updatedAt: Date
}
// Refund Request
{
courseId: ObjectId, // Course reference
studentId: ObjectId, // Student reference
amount: Number, // Refund amount
reason: String, // Refund reason
refundReasonCategory: String, // Category
requestStatus: String, // pending/accepted/rejected
createdAt: Date,
updatedAt: Date
}
// Processed Refund
{
courseId: ObjectId, // Course reference
studentId: ObjectId, // Student reference
amount: Number, // Refund amount
refundId: String, // Razorpay refund ID
status: String, // Refund status
refundMethod: String, // Refund method
createdAt: Date,
updatedAt: Date
}
- NextAuth.js Integration: Secure authentication
- Role-Based Access: Student, Teacher, Admin roles
- Protected Routes: Middleware-based route protection
- Session Management: JWT-based sessions
// Role-based route protection in middleware
export function middleware(request: NextRequest) {
// Check authentication and redirect based on role
// Protect /admin/* routes for admins only
// Protect /teacher/* routes for teachers only
// Protect /student/* routes for students only
}
- Course Creation: Teachers can create courses
- Course Publishing: Draft and published states
- Course Pricing: Dynamic pricing with sales
- Student Enrollment: After successful payment
GET /api/courses # Get all courses
POST /api/courses # Create new course (teacher)
GET /api/courses/[id] # Get specific course
PUT /api/courses/[id] # Update course (teacher)
- Razorpay Integration: Secure payment processing
- Order Creation: Generate payment orders
- Payment Verification: Signature verification
- Course Enrollment: Automatic after payment
- Student selects course
- System creates Razorpay order
- Student completes payment
- Payment verification
- Course access granted
POST /api/payments/create-order # Create payment order
POST /api/payments/verify # Verify payment
- Refund Requests: Students can request refunds
- Admin Approval: Admin reviews and approves/rejects
- Automated Processing: Direct Razorpay refund processing
- Course Access Removal: Automatic after refund
- Student submits refund request
- Admin reviews request
- If approved, automatic refund processing
- Course access revoked
- Student notified
POST /api/request-refund # Submit refund request
GET /api/request-refund # Get refund requests (admin)
POST /api/refund # Process approved refund
- Time-Based Sales: Limited-time price reductions
- Coupon System: Discount codes for courses
- Dynamic Pricing: Automatic price calculations
// Sales management
POST /api/sales # Create sale (teacher)
GET /api/sales # Get active sales
// Coupon management
POST /api/coupons # Create coupon (teacher)
POST /api/coupons/validate # Validate coupon code
- User Listing: View all students, teachers, admins
- Account Suspension: Suspend/activate user accounts
- Profile Viewing: Access user profiles
- Course Oversight: View teacher courses
- Course Purchase: Buy courses with payment
- Course Access: View purchased courses
- Refund Requests: Request refunds for courses
- Course Creation: Create and manage courses
- Sales Management: Create sales and coupons
- Revenue Tracking: View earnings and analytics
- User Management: Suspend/activate accounts, view profiles
- Course Oversight: Monitor all courses on platform
- Refund Management: Review and process refund requests
- Platform Analytics: User and course statistics
/admin/dashboard # Admin dashboard
/admin/users # User management
/admin/users/profile/[id] # User profile view
/admin/courses/teacher/[id] # Teacher's courses
GET /api/auth/[...nextauth] # NextAuth endpoints
GET /api/courses # List courses
POST /api/courses # Create course
GET /api/courses/[id] # Get course details
PUT /api/courses/[id] # Update course
DELETE /api/courses/[id] # Delete course
POST /api/payments # Create payment order
POST /api/payments/verify # Verify payment
POST /api/request-refund # Request refund
GET /api/request-refund # Get requests (admin)
POST /api/refund # Process refund
GET /api/admin/users # Get all users
PUT /api/admin/users/[id] # Update user status
POST /api/sales # Create sale
GET /api/sales # Get sales
POST /api/coupons # Create coupon
POST /api/coupons/validate # Validate coupon
- Input Validation: Zod schema validation
- Authentication: NextAuth.js with JWT
- Role-Based Access: Route and API protection
- Payment Security: Razorpay signature verification
- Environment Variables: Sensitive data protection
- Node.js (v18 or higher)
- MongoDB database
- npm or pnpm package manager
MONGODB_URI=your-mongodb-connection-string
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-nextauth-secret
RAZORPAY_KEY_ID=your-razorpay-key-id
RAZORPAY_KEY_SECRET=your-razorpay-key-secret
# 1. Clone the repository
git clone https://github.com/0xshariq/learning-management-system.git
cd learning-management-system
# 2. Install dependencies
npm install
# 3. Set up environment variables
cp .env.example .env.local
# Edit .env.local with your configuration
# 4. Run the development server
npm run dev
# 5. Open browser
# Navigate to http://localhost:3000
# Build the application
npm run build
# Start production server
npm start
This project is licensed under the MIT License.
- Email: [email protected]
- Live Demo: https://learning-management-system-taupe-eta.vercel.app/
- GitHub: https://github.com/0xshariq/edulearn-lms
This documentation covers the actual features implemented in the EduLearn Learning Management System. Refer to the source code for detailed implementation.