A comprehensive Learning Management System built with Next.js 15, React 19, and MongoDB.
- Multi-role Authentication: Student, Teacher, Admin, and Department Head roles
- Course Management: Create, manage, and enroll in courses
- Materials & Assignments: Upload materials and submit assignments
- Messaging System: Direct messaging between users
- News & Announcements: Admin-published news and updates
- File Upload: Cloud-based file storage with Vercel Blob
- Dark/Light Mode: Theme toggle support
- Frontend: Next.js 15, React 19, Tailwind CSS v4
- Backend: Next.js API Routes
- Database: MongoDB with Mongoose
- Authentication: JWT (JSON Web Tokens)
- File Storage: Vercel Blob
- Icons: Lucide React
Create a .env.local file in the root directory with the following variables:
```env
MONGODB_URI=mongodb+srv://:@.mongodb.net/?retryWrites=true&w=majority
JWT_SECRET=your-super-secure-jwt-secret-key-here
BLOB_READ_WRITE_TOKEN=vercel_blob_rw_xxxxxxxxxxxx ```
- Create a free account at MongoDB Atlas
- Create a new cluster (free tier available)
- Click Connect → Connect your application
- Copy the connection string
- Replace
<username>,<password>, and<database>with your credentials
Generate a secure random string using one of these methods:
```bash
openssl rand -hex 32
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))" ```
Option A: Via Vercel Dashboard (Recommended for Production)
- Go to Vercel Dashboard
- Select your project or create a new one
- Navigate to Storage tab
- Click Create Database → Select Blob
- Follow the setup wizard
- The
BLOB_READ_WRITE_TOKENwill be automatically added to your project's environment variables
Option B: Via Vercel CLI
```bash
npm i -g vercel
vercel login
vercel link
vercel blob create my-lms-storage
vercel env pull .env.local ```
```bash
git clone https://github.com/nurfish006/LMS.git cd LMS
npm install
cp .env.example .env.local
npm run dev ```
Open http://localhost:3000 in your browser.
- Push your code to GitHub
- Go to Vercel
- Import your repository
- Add environment variables in the Vercel dashboard:
MONGODB_URIJWT_SECRETBLOB_READ_WRITE_TOKEN(auto-added if you create Blob storage)
- Click Deploy
After registration, users are assigned the student role by default. To create admin or teacher accounts:
- Register a new user
- Connect to your MongoDB database
- Update the user's role:
```javascript // In MongoDB Shell or Compass db.users.updateOne( { email: "admin@example.com" }, { $set: { role: "admin" } } ) ```
Available roles: student, teacher, admin, department_head
``` ├── app/ │ ├── (auth)/ │ │ ├── login/ │ │ └── register/ │ ├── admin/ │ │ ├── messages/ │ │ ├── news/ │ │ └── users/ │ ├── api/ │ │ ├── auth/ │ │ ├── courses/ │ │ ├── materials/ │ │ ├── messages/ │ │ ├── news/ │ │ ├── submissions/ │ │ ├── upload/ │ │ └── users/ │ ├── student/ │ │ ├── assignments/ │ │ ├── courses/ │ │ ├── messages/ │ │ ├── news/ │ │ └── profile/ │ └── teacher/ │ ├── assignments/ │ ├── courses/ │ ├── materials/ │ ├── messages/ │ └── news/ ├── components/ │ ├── ui/ │ ├── admin-nav.tsx │ ├── auth-provider.tsx │ ├── file-upload.tsx │ ├── student-nav.tsx │ ├── teacher-nav.tsx │ └── theme-toggle.tsx ├── lib/ │ ├── auth.ts │ ├── models.ts │ └── mongodb.ts └── public/ ```
POST /api/auth/register- Register new userPOST /api/auth/login- Login userPOST /api/auth/logout- Logout userGET /api/auth/me- Get current user
GET /api/courses- Get all coursesPOST /api/courses- Create course (teacher/admin)
GET /api/materials- Get materialsPOST /api/materials- Upload material (teacher)
GET /api/assignments- Get assignmentsPOST /api/assignments- Create assignment (teacher)
GET /api/submissions- Get submissionsPOST /api/submissions- Submit assignment (student)POST /api/submissions/[id]/grade- Grade submission (teacher)
GET /api/messages- Get messages/conversationsPOST /api/messages- Send message
GET /api/news- Get news articlesPOST /api/news- Create news (admin)DELETE /api/news/[id]- Delete news (admin)
GET /api/users- Get users (admin)DELETE /api/users/[id]- Delete user (admin)
POST /api/upload- Upload file to Vercel BlobDELETE /api/upload- Delete file from Vercel Blob
MIT License - feel free to use this project for educational purposes.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request