Learning Management System(Udemy - Coursera)
Learning Management System (LMS)
Welcome to the Learning Management System (LMS) repository! This project is inspired by leading e-learning platforms like Udemy and Coursera. It is designed to provide a comprehensive backend solution for managing users, courses, tutorials, blogs, documentation, reviews, and contact management. The system includes robust authentication, role-based access control, real-time messaging capabilities, Web3/blockchain integration, and scalable architecture.
๐ Features
1. ๐ค User Management
- Registration & Authentication: Secure user registration and login with JWT tokens.
- Role-Based Access Control: Administrator, instructor, and student roles with granular permissions.
- Account Actions:
2. ๐ Course Management
- Course Creation: Instructors can create, edit, and delete courses.
- Categories: Assign courses to categories for streamlined organization.
- Lesson Management: Add lessons to courses with support for pagination.
- Course Enrollment: Track and manage student enrollments.
3. ๐ Tutorials
- Tutorials by Category: Fetch tutorials based on categories.
- CRUD Operations: Create, update, and delete tutorial content.
- Slug-based Routing: Easy-to-read URLs for tutorials.
4. ๐ Blogs
- Blog Management:
- Blog Discovery: Browse blogs by category with pagination.
5. ๐ Documentation
- Documentation Management:
- Knowledge Base: Centralized documentation for system reference.
6. โญ Reviews & Ratings
- Review System:
7. ๐ฌ Real-Time Chat
- Socket.IO Integration: Real-time messaging between users.
- Conversation Management: Create and manage conversations with read receipts.
- Typing Indicators: Real-time typing status updates.
- Online Status: Track user availability.
8. ๐ฌ Contact Management
- Contact Forms:
- Notification System: Alerts for new contact submissions.
9. ๐ Web3 & Blockchain Integration
- Wallet Authentication:
- NFT Certificates:
- Smart Contracts:
- Cryptocurrency Payments:
- Reward System:
10. ๐ก๏ธ Middleware & Security
- Security:
- Logging:
- API Versioning:
- Rate Limiting: Protect against abuse and brute-force attacks.
๐ API Endpoints Examples
User Routes
POST /api/v1/user/register: Register a new user.POST /api/v1/user/login: Authenticate and log in a user.GET /api/v1/user/all: Fetch all users with pagination.POST /api/v1/user/password-reset: Request password reset.POST /api/v1/user/logout: Logout a user.
Course Routes
GET /api/v1/course/all: Get all courses.POST /api/v1/course: Create a new course.GET /api/v1/course/:id: Get a specific course by ID.PUT /api/v1/course/:id: Update a course.DELETE /api/v1/course/:id: Delete a course by ID.POST /api/v1/course/:id/enroll: Enroll in a course.
Tutorial Routes
GET /api/v1/tutorial/category/:category: Fetch tutorials by category.GET /api/v1/tutorial/:slug: Get a specific tutorial.POST /api/v1/tutorial: Create a tutorial.PUT /api/v1/tutorial/:id: Update a tutorial.DELETE /api/v1/tutorial/:id: Delete a tutorial.
Blog Routes
POST /api/v1/blog: Create a blog.GET /api/v1/blog/all: Get all blogs.GET /api/v1/blog/:id: Get a specific blog.PUT /api/v1/blog/:id: Update a blog.DELETE /api/v1/blog/:id: Delete a blog.
Documentation Routes
POST /api/v1/documentation: Add documentation.GET /api/v1/documentation/all: Fetch all documentation.GET /api/v1/documentation/:id: Get specific documentation.PUT /api/v1/documentation/:id: Update documentation.DELETE /api/v1/documentation/:id: Delete documentation.
Review Routes
POST /api/v1/review: Add a review.GET /api/v1/review/all: Fetch all reviews.GET /api/v1/review/:id: Get a specific review.DELETE /api/v1/review/:id: Delete a review.
Chat Routes
GET /api/v1/chat/conversations: Fetch all conversations for a user.GET /api/v1/chat/conversations/user/:recipientId: Get or create conversation with a user.GET /api/v1/chat/conversations/:conversationId/messages: Fetch messages in a conversation.POST /api/v1/chat/conversations/:conversationId/messages: Send a message.- Socket.IO events:
message:new,typing:start,typing:stop,typing:update,message:read
Web3 & Wallet Routes
POST /api/v1/wallet/nonce: Request nonce for wallet login.POST /api/v1/wallet/verify: Verify wallet signature and login.POST /api/v1/web3/certificate/mint: Mint course completion NFT certificate.GET /api/v1/web3/certificate/:tokenId: Retrieve certificate details.POST /api/v1/web3/token/reward: Mint LMSR reward tokens to student.GET /api/v1/web3/token/balance/:address: Get LMSR token balance.POST /api/v1/web3/payment/intent: Create payment intent for course purchase.POST /api/v1/web3/payment/process: Process USDC course payment.GET /api/v1/web3/verification/:studentAddress/:courseId: Verify course completion status.
Contact Routes
POST /api/v1/contact: Submit a contact form.GET /api/v1/contact/all: Fetch all contact submissions.PUT /api/v1/contact/:id: Update a contact submission.DELETE /api/v1/contact/:id: Delete a contact submission.
๐๏ธ Tech Stack
- Programming Language: JavaScript (99.7%), Solidity (Smart Contracts)
- Infrastructure: Docker (0.3%)
- Frameworks & Libraries:
- Frontend: React with Vite (included in chat-frontend subdirectory).
- Blockchain: Ethereum-compatible networks (mainnet, testnets).
๐ Blockchain Setup
Environment Variables for Web3
# Ethereum RPC Configuration
ETHEREUMRPCURL=https://rpc-url-for-your-network
BACKENDWALLETPRIVATEKEY=yourbackendwalletprivate_key
Smart Contract Addresses
CERTIFICATECONTRACTADDRESS=0x...
REWARDTOKENCONTRACT_ADDRESS=0x...
PAYMENTCONTRACTADDRESS=0x...
VERIFICATIONCONTRACTADDRESS=0x...
USDCCONTRACTADDRESS=0x...
Smart Contracts Overview
1. CourseCertificateNFT (ERC-721)
Mints course completion certificates as non-fungible tokens.- mintCertificate(address student, string courseId, uint256 score, string metadataURI)
- certificateData: Maps tokenId to course details
- Events: CertificateMinted
2. LMSToken (ERC-20)
Native reward token for incentivizing course completion.- mintReward(address to, uint256 amount, string reason)
- Total supply managed by owner
- Events: RewardMinted
3. CoursePaymentHandler (ERC-20 USDC Handler)
Handles secure USDC stablecoin payments for course access.- payForCourse(string courseId, uint256 amount)
- Treasury management for payment collection
- Events: CoursePaid
4. VerificationRegistry (Completion Tracker)
Tracks and verifies on-chain course completions.- registerCompletion(address student, string courseId, uint256 score, uint256 certificateTokenId, bytes32 recordHash)
- isCompleted(address student, string courseId)
- Immutable completion records
๐ฅ Installation
- Clone the repository:
git clone https://github.com/Ali-Adel-Nour/LMS.git
- Navigate to the project directory:
cd LMS
- Install dependencies:
npm install
- Set up environment variables:
.env file in the root directory.
- Add the necessary configurations:
# Server Configuration
PORT=5000
NODE_ENV=development
# Database
MONGODB_URI=mongodb://localhost:27017/lms
# Authentication
JWTSECRET=yourjwtsecretkey
# Redis
REDIS_URL=redis://localhost:6379
# Frontend
FRONTEND_URL=http://localhost:5173
# Web3 Configuration
ETHEREUMRPCURL=https://your-rpc-url
BACKENDWALLETPRIVATEKEY=yourwalletprivatekey
CERTIFICATECONTRACTADDRESS=0x...
REWARDTOKENCONTRACT_ADDRESS=0x...
PAYMENTCONTRACTADDRESS=0x...
VERIFICATIONCONTRACTADDRESS=0x...
USDCCONTRACTADDRESS=0x...
- Deploy Smart Contracts (Optional):
cd "lms backend/blockchain"
npm install
npx hardhat deploy
- Install frontend dependencies (for chat frontend):
cd "lms backend/chat-frontend"
npm install
- Start the development server:
# Backend
npm run dev
# Frontend (in another terminal) cd "lms backend/chat-frontend" npm run dev
๐ Deployment
Using Docker
docker build -t lms-app .
docker run -p 5000:5000 --env-file .env lms-app
Docker Compose (with MongoDB and Redis)
docker-compose up -d
๐ Project Structure
LMS/
โโโ lms backend/
โ โโโ controllers/
โ โ โโโ web3Ctrl.js # Web3 controller for blockchain operations
โ โ โโโ ... # Other controllers
โ โโโ routes/
โ โ โโโ web3Routes.js # Web3 API routes
โ โ โโโ walletRoutes.js # Wallet authentication routes
โ โ โโโ ... # Other routes
โ โโโ config/
โ โ โโโ web3Config.js # Web3 provider and signer setup
โ โ โโโ ... # Other configs
โ โโโ models/
โ โ โโโ web3RecordModel.js # Web3 transaction records
โ โ โโโ ... # Other models
โ โโโ services/
โ โ โโโ web3Service.js # Web3 utility functions
โ โ โโโ ... # Other services
โ โโโ blockchain/
โ โ โโโ contracts/ # Solidity smart contracts
โ โ โ โโโ CourseCertificateNFT.sol
โ โ โ โโโ LMSToken.sol
โ โ โ โโโ CoursePaymentHandler.sol
โ โ โ โโโ VerificationRegistry.sol
โ โ โโโ hardhat.config.js # Hardhat configuration
โ โ โโโ deployments/ # Deployment scripts
โ โโโ chat-frontend/ # React chat client
โ โโโ public/
โ โ โโโ metamask.html # Web3 testing interface
โ โโโ app.js
โโโ .env.example # Environment variables template
โโโ package.json # Dependencies and scripts
โโโ README.md # Documentation
๐ป Web3 Integration Examples
Wallet Login
// Client-side: Connect wallet and request nonce
const response = await fetch('/api/v1/wallet/nonce', {
method: 'POST',
body: JSON.stringify({ walletAddress: userWallet })
});
// Sign the nonce with MetaMask const signature = await signer.signMessage(nonceMessage);
// Verify and login const loginResponse = await fetch('/api/v1/wallet/verify', { method: 'POST', body: JSON.stringify({ walletAddress: userWallet, signature }) });
Mint Certificate
// Server-side: Mint certificate NFT
POST /api/v1/web3/certificate/mint
{
"studentWalletAddress": "0x...",
"courseId": "course123",
"score": 95,
"metadataURI": "ipfs://..."
}
Process Payment
// Approve USDC and pay for course
POST /api/v1/web3/payment/intent
{
"courseId": "course123",
"amountUSDC": "99.99"
}
๐ค Contribution
We welcome contributions! Please follow the contribution guidelines to get started.
Steps to Contribute:
- Fork the repository.
- Create a feature branch:
git checkout -b feature/your-feature-name - Make your changes and commit:
git commit -m 'Add your feature' - Push to the branch:
git push origin feature/your-feature-name - Open a pull request.
๐ฎ Future Enhancements
- Advanced Video Integration: Streaming service integration for high-quality video content.
- Multi-Chain Support: Expand to Polygon, Arbitrum, and other EVM-compatible networks.
- DAO Governance: Decentralized governance for course content and platform decisions.
- Notifications: Email and push notifications for courses, reviews, and messages.
- Analytics Dashboard: Track user engagement, course completion rates, and on-chain metrics.
- AI-Powered Recommendations: Suggest courses based on user behavior and blockchain history.
- DeFi Integration: Stake LMSR tokens for platform benefits and rewards.
- Advanced Search: Full-text search with filters and AI-powered suggestions.
- Multi-language Support: Internationalization (i18n) for global users.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Support
For issues, questions, or suggestions, please open an issue on GitHub.
๐ Useful Resources
- MetaMask: https://metamask.io/
- Ethers.js Documentation: https://docs.ethers.org/v6/
- OpenZeppelin Contracts: https://docs.openzeppelin.com/contracts/
- Solidity Documentation: https://docs.soliditylang.org/
๐จโ๐ป Author
Ali Adel Nour GitHub Profile
Last Updated: June 2026 Status: Active Development