A comprehensive MERN stack application for managing lecture scheduling with role-based access control for admins and instructors. The system prevents scheduling conflicts by ensuring no instructor has two lectures on the same date.
- Instructor Management: View list of all registered instructors
- Course Management: Add courses with details (Name, Level, Description, Image)
- Lecture Management: Add multiple lectures/batches to courses and assign to instructors
- Conflict Prevention: Automatic validation ensures no instructor is assigned multiple lectures on the same date
- Course Deletion: Remove courses and all associated lectures
- My Lectures Dashboard: View all assigned lectures
- Lecture Details: See course information, dates, times, and descriptions
- Schedule Overview: Get a clear view of your teaching schedule
- User Authentication: JWT-based authentication with role-based access control
- Conflict Detection: Backend validation prevents scheduling conflicts
- Responsive Design: Works seamlessly on desktop and mobile devices
- Real-time Feedback: Clear error messages and validation feedback
- Frontend: React 18 + Vite
- Backend: Node.js + Express
- Database: MongoDB
- Authentication: JWT (JSON Web Tokens)
- Styling: CSS3 with responsive design
- Node.js (v16 or higher)
- MongoDB (running locally or remote connection string)
- npm or yarn
cd server
npm installCreate a .env file in the server directory:
MONGODB_URI=mongodb://localhost:27017/lecture-scheduling
JWT_SECRET=your_jwt_secret_key_here
PORT=5000
NODE_ENV=development
Start the backend server:
npm run devThe backend will run on http://localhost:5000
cd client
npm installStart the frontend development server:
npm run devThe frontend will run on http://localhost:3000
For testing the admin functionality:
Email: admin@example.com
Password: admin123
Role: Admin
To create an instructor account:
- Click "Register" on the login page
- Fill in the details
- Select "Instructor" as the role
POST /api/auth/register- Register a new userPOST /api/auth/login- Login userGET /api/auth/profile- Get current user profileGET /api/auth/instructors- Get all instructors (Protected)
GET /api/courses- Get all courses (Protected)POST /api/courses- Create a new course (Protected, Admin only)GET /api/courses/:id- Get course by ID (Protected)PUT /api/courses/:id- Update course (Protected, Admin only)DELETE /api/courses/:id- Delete course (Protected, Admin only)
GET /api/lectures- Get all lectures (Protected)POST /api/lectures- Add new lecture (Protected, Admin only)GET /api/lectures/course/:courseId- Get lectures by course (Protected)GET /api/lectures/instructor/my-lectures- Get my lectures (Protected)PUT /api/lectures/:id- Update lecture (Protected, Admin only)DELETE /api/lectures/:id- Delete lecture (Protected, Admin only)GET /api/lectures/availability/check- Check instructor availability (Protected, Admin only)
The system implements a sophisticated conflict detection mechanism:
-
Date-based Check: When assigning a lecture to an instructor on a specific date, the system checks if the instructor already has any lecture scheduled that day.
-
Time-based Check: If needed, the system can validate time slot conflicts to prevent overlapping lectures.
-
Real-time Validation: The frontend provides immediate feedback when a conflict is detected.
-
Backend Enforcement: All validations are also performed on the backend to ensure data integrity.
βββ server/
β βββ src/
β β βββ models/
β β β βββ User.js
β β β βββ Course.js
β β β βββ Lecture.js
β β βββ controllers/
β β β βββ authController.js
β β β βββ courseController.js
β β β βββ lectureController.js
β β βββ routes/
β β β βββ authRoutes.js
β β β βββ courseRoutes.js
β β β βββ lectureRoutes.js
β β βββ middleware/
β β β βββ auth.js
β β βββ utils/
β β β βββ scheduleValidator.js
β β βββ server.js
β βββ package.json
β βββ .env
β
βββ client/
β βββ src/
β β βββ components/
β β β βββ Navbar.jsx
β β β βββ Navbar.css
β β β βββ ProtectedRoute.jsx
β β βββ context/
β β β βββ AuthContext.jsx
β β βββ pages/
β β β βββ LoginPage.jsx
β β β βββ RegisterPage.jsx
β β β βββ AdminDashboard.jsx
β β β βββ CoursesPage.jsx
β β β βββ InstructorDashboard.jsx
β β β βββ *.css files
β β βββ services/
β β β βββ api.js
β β βββ App.jsx
β β βββ main.jsx
β β βββ index.css
β β βββ App.css
β βββ index.html
β βββ vite.config.js
β βββ package.json
- Register an admin account
- Register instructor accounts
- Login as admin
- Create courses with different levels
- Add instructors to the system
- Add lectures to courses with different dates
- Try to assign the same instructor multiple lectures on the same date (should fail)
- Login as instructor
- View all assigned lectures
- Verify schedule information
- Try to assign a lecture to an instructor who already has a lecture on that date
- System should display an error message
- The conflict check happens both in frontend and backend
- Displays list of all instructors
- Shows instructor details and join dates
- Course management interface
- Add new courses form
- Add lectures to courses modal
- Course cards with actions
- Instructor selection dropdown
- Table view of assigned lectures
- Displays course name, level, lecture title, date, time
- Sortable by date
-
User Registration/Login
- User submits credentials
- Backend validates and creates JWT token
- Token stored in localStorage
- Frontend redirects based on user role
-
Adding Lecture
- Admin selects course and instructor
- Admin chooses date and time
- Frontend checks availability
- Backend performs conflict validation
- Lecture created or error returned
-
Viewing Schedule
- Instructor views dashboard
- Frontend fetches assigned lectures
- Backend returns filtered lectures for logged-in instructor
- UI displays formatted schedule
- Database: Ensure MongoDB is running before starting the backend
- Environment Variables: Update the
.envfile with your actual MongoDB connection string - JWT Secret: Change the JWT_SECRET in production
- CORS: The frontend makes requests to the backend API with proper CORS configuration
Ensure MongoDB is running:
- Local: `mongod` command
- Remote: Update MONGODB_URI in .env
Backend: npm run dev will use port 5000
Frontend: npm run dev will use port 3000
If ports are busy, update vite.config.js or use PORT=xxxx
The vite.config.js includes proxy configuration to handle CORS
If issues persist, check the baseURL in client/src/services/api.js
This project is open source and available under the MIT License.
- Email notifications for lecture assignments
- Lecture recordings management
- Student enrollment system
- Payment integration for courses
- Video conferencing integration
- Advanced analytics and reporting
- Mobile app version
- Dark mode support
For issues or questions, please create an issue in the repository.