Skip to content

0xshariq/edulearn-lms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

40 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

EduLearn - Learning Management System

πŸ“‹ Table of Contents


🎯 Project Overview

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.

Key Features

  • 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

🎯 Purpose & Vision

Primary Goals

  1. Online Education Platform: Enable teachers to create and sell courses
  2. Student Learning Hub: Provide students with course access and progress tracking
  3. Administrative Control: Complete platform management through admin panel
  4. Secure Transactions: Handle payments and refunds securely

Target Users

  • Students: Purchase and access courses
  • Teachers: Create, manage, and sell courses
  • Administrators: Oversee platform operations and user management

πŸ› οΈ Technology Stack

Frontend Technologies

  • Next.js 14 (App Router)
  • React 18
  • TypeScript
  • Tailwind CSS
  • Shadcn/UI Components
  • Lucide React Icons

Backend Technologies

  • Next.js API Routes
  • MongoDB with Mongoose
  • NextAuth.js for Authentication
  • Razorpay for Payments

Development Tools

  • ESLint & Prettier
  • TypeScript Compiler
  • Environment Variables

πŸ—οΈ Project Architecture

Folder Structure

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

πŸ—ƒοΈ Database Models

User Models

Student Model

{
  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
}

Teacher Model

{
  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
}

Admin Model

{
  name: String,                    // Full name
  email: String,                   // Unique email
  password: String,                // Hashed password
  role: "admin",                   // User role
  isActive: Boolean,               // Account status
  createdAt: Date,
  updatedAt: Date
}

Course & Transaction Models

Course Model

{
  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
}

Payment Model

{
  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
}

Sales Model

{
  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
}

Coupon Model

{
  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 Models

// 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
}

πŸ” Authentication System

Features

  • NextAuth.js Integration: Secure authentication
  • Role-Based Access: Student, Teacher, Admin roles
  • Protected Routes: Middleware-based route protection
  • Session Management: JWT-based sessions

Implementation

// 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 Management

Features

  • Course Creation: Teachers can create courses
  • Course Publishing: Draft and published states
  • Course Pricing: Dynamic pricing with sales
  • Student Enrollment: After successful payment

API Endpoints

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)

πŸ’³ Payment System

Features

  • Razorpay Integration: Secure payment processing
  • Order Creation: Generate payment orders
  • Payment Verification: Signature verification
  • Course Enrollment: Automatic after payment

Payment Flow

  1. Student selects course
  2. System creates Razorpay order
  3. Student completes payment
  4. Payment verification
  5. Course access granted

API Endpoints

POST /api/payments/create-order  # Create payment order
POST /api/payments/verify        # Verify payment

πŸ”„ Refund Management

Features

  • 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

Refund Process

  1. Student submits refund request
  2. Admin reviews request
  3. If approved, automatic refund processing
  4. Course access revoked
  5. Student notified

API Endpoints

POST /api/request-refund         # Submit refund request
GET  /api/request-refund         # Get refund requests (admin)
POST /api/refund                 # Process approved refund

🏷️ Sales & Discount System

Features

  • Time-Based Sales: Limited-time price reductions
  • Coupon System: Discount codes for courses
  • Dynamic Pricing: Automatic price calculations

Implementation

// 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 Management

Admin Features

  • User Listing: View all students, teachers, admins
  • Account Suspension: Suspend/activate user accounts
  • Profile Viewing: Access user profiles
  • Course Oversight: View teacher courses

Student Features

  • Course Purchase: Buy courses with payment
  • Course Access: View purchased courses
  • Refund Requests: Request refunds for courses

Teacher Features

  • Course Creation: Create and manage courses
  • Sales Management: Create sales and coupons
  • Revenue Tracking: View earnings and analytics

πŸ›‘οΈ Admin Panel

Administrative Features

  • 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 Routes

/admin/dashboard                 # Admin dashboard
/admin/users                     # User management
/admin/users/profile/[id]        # User profile view
/admin/courses/teacher/[id]      # Teacher's courses

πŸ”— API Endpoints

Authentication

GET  /api/auth/[...nextauth]     # NextAuth endpoints

Courses

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

Payments

POST /api/payments  # Create payment order
POST /api/payments/verify        # Verify payment

Refunds

POST /api/request-refund         # Request refund
GET  /api/request-refund         # Get requests (admin)
POST /api/refund                 # Process refund

Admin

GET  /api/admin/users            # Get all users
PUT  /api/admin/users/[id]       # Update user status

Sales & Coupons

POST /api/sales                  # Create sale
GET  /api/sales                  # Get sales
POST /api/coupons                # Create coupon
POST /api/coupons/validate       # Validate coupon

πŸ”’ Security Features

Implemented Security

  • 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

πŸš€ Installation & Setup

Prerequisites

- Node.js (v18 or higher)
- MongoDB database
- npm or pnpm package manager

Environment Variables

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

Installation Steps

# 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

Production Deployment

# Build the application
npm run build

# Start production server
npm start

πŸ“„ License & Contact

License

This project is licensed under the MIT License.

Contact Information


This documentation covers the actual features implemented in the EduLearn Learning Management System. Refer to the source code for detailed implementation.

Releases

No releases published

Packages

No packages published

Languages