Skip to content

roht2103/timetableGenerator

Repository files navigation

NEP-Based AI Timetable Generator πŸŽ“

A full-stack MERN application for generating conflict-free academic timetables for multiple classes, divisions, teachers, labs, and NEP elective groups while respecting various constraints.

πŸš€ Features

Admin Dashboard

  • Academic Structure Management: Define working days and daily lecture slots
  • Class/Division Management: Manage multiple years (FY, SY, TY) and divisions (A, B, C, etc.)
  • Classroom & Lab Management: Track rooms with type and capacity
  • Teacher Management: Manage teacher availability by day/time slot and max hours per week
  • Subject Management: Handle theory, lab, and elective subjects with credit hours
  • Elective Batch Management: Group students into multiple electives with parallel room allocation

Timetable Generation

  • Constraint-Based Scheduling Engine with:
    • Lab allocation (continuous 2-3 slot blocks)
    • Elective scheduling (parallel room allocation)
    • Core subject allocation
    • Conflict resolution using backtracking

Outputs

  • Class-wise timetable view
  • Teacher-wise timetable (TODO)
  • Room occupancy chart (TODO)
  • Export as PDF/Excel (TODO)

πŸ› οΈ Tech Stack

Frontend

  • React 18.2.0
  • React Router DOM 6.20.0
  • TailwindCSS 3.3.6
  • Axios for API calls

Backend

  • Node.js with Express.js 4.18.2
  • MongoDB with Mongoose ODM 8.0.0
  • CORS enabled
  • dotenv for environment variables

πŸ“ Project Structure

timetableGenerator/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”‚   β”œβ”€β”€ timetableController.js
β”‚   β”‚   β”‚   β”œβ”€β”€ teacherController.js
β”‚   β”‚   β”‚   β”œβ”€β”€ subjectController.js
β”‚   β”‚   β”‚   β”œβ”€β”€ classController.js
β”‚   β”‚   β”‚   β”œβ”€β”€ roomController.js
β”‚   β”‚   β”‚   └── electiveController.js
β”‚   β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”‚   β”œβ”€β”€ Teacher.js
β”‚   β”‚   β”‚   β”œβ”€β”€ Subject.js
β”‚   β”‚   β”‚   β”œβ”€β”€ Class.js
β”‚   β”‚   β”‚   β”œβ”€β”€ Classroom.js
β”‚   β”‚   β”‚   β”œβ”€β”€ ElectiveGroup.js
β”‚   β”‚   β”‚   └── Timetable.js
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   └── scheduler/
β”‚   β”‚   β”‚       β”œβ”€β”€ constraintSolver.js
β”‚   β”‚   β”‚       β”œβ”€β”€ labAllocator.js
β”‚   β”‚   β”‚       β”œβ”€β”€ electiveAllocator.js
β”‚   β”‚   β”‚       └── conflictChecker.js
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”‚   β”œβ”€β”€ timetableRoutes.js
β”‚   β”‚   β”‚   β”œβ”€β”€ teacherRoutes.js
β”‚   β”‚   β”‚   β”œβ”€β”€ classRoutes.js
β”‚   β”‚   β”‚   β”œβ”€β”€ subjectRoutes.js
β”‚   β”‚   β”‚   β”œβ”€β”€ roomRoutes.js
β”‚   β”‚   β”‚   └── electiveRoutes.js
β”‚   β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”‚   └── database.js
β”‚   β”‚   └── app.js
β”‚   β”œβ”€β”€ package.json
β”‚   └── .env.example
β”‚
└── frontend/
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ pages/
    β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx
    β”‚   β”‚   β”œβ”€β”€ ManageTeachers.jsx
    β”‚   β”‚   β”œβ”€β”€ ManageSubjects.jsx
    β”‚   β”‚   β”œβ”€β”€ ManageClasses.jsx
    β”‚   β”‚   β”œβ”€β”€ ManageRooms.jsx
    β”‚   β”‚   β”œβ”€β”€ ManageElectives.jsx
    β”‚   β”‚   β”œβ”€β”€ GenerateTimetable.jsx
    β”‚   β”‚   └── ViewTimetable.jsx
    β”‚   β”œβ”€β”€ components/
    β”‚   β”‚   β”œβ”€β”€ TimetableGrid.jsx
    β”‚   β”‚   β”œβ”€β”€ FileUploader.jsx
    β”‚   β”‚   └── TeacherLoadChart.jsx
    β”‚   β”œβ”€β”€ utils/
    β”‚   β”‚   └── api.js
    β”‚   β”œβ”€β”€ App.js
    β”‚   └── index.js
    β”œβ”€β”€ package.json
    └── tailwind.config.js

πŸ—„οΈ Database Schema

Teachers

{
  name: String,
  department: String,
  availability: Map<String, [String]>,  // e.g., { Monday: ["9-10", "10-11"] }
  maxHoursPerWeek: Number
}

Subjects

{
  name: String,
  type: Enum['theory', 'lab', 'elective'],
  creditHours: Number,
  teacherId: ObjectId (ref: Teacher)
}

Classes

{
  name: String,
  year: Enum['FY', 'SY', 'TY', 'Final Year'],
  division: String,
  strength: Number
}

Classrooms

{
  name: String,
  type: Enum['classroom', 'lab'],
  capacity: Number
}

ElectiveGroups

{
  groupName: String,
  classIds: [ObjectId],
  subjectIds: [ObjectId],
  teacherIds: [ObjectId],
  roomIds: [ObjectId]
}

Timetable

{
  classId: ObjectId,
  weekSchedule: {
    Monday: [{ slot, subject, room, teacher }],
    Tuesday: [...],
    ...
  },
  generatedAt: Date
}

πŸš€ Installation & Setup

Prerequisites

  • Node.js (v16 or higher)
  • MongoDB (local or Atlas)
  • npm or yarn

Backend Setup

  1. Navigate to backend directory:
cd backend
  1. Install dependencies:
npm install
  1. Create .env file:
cp .env.example .env
  1. Update .env with your MongoDB URI:
PORT=8080
MONGODB_URI=mongodb://localhost:27017/timetable-generator
NODE_ENV=development
  1. Start the backend server:
npm run dev

The backend will run on http://localhost:8080

Frontend Setup

  1. Navigate to frontend directory:
cd frontend
  1. Install dependencies:
npm install
  1. Create .env file:
cp .env.example .env
  1. Update .env with backend API URL:
REACT_APP_API_URL=http://localhost:8080/api
  1. Start the development server:
npm start

The frontend will run on http://localhost:3000

πŸ“‘ API Endpoints

Teachers

  • GET /api/teachers - Get all teachers
  • GET /api/teachers/:id - Get single teacher
  • POST /api/teachers - Create teacher
  • PUT /api/teachers/:id - Update teacher
  • DELETE /api/teachers/:id - Delete teacher

Subjects

  • GET /api/subjects - Get all subjects
  • GET /api/subjects/:id - Get single subject
  • POST /api/subjects - Create subject
  • PUT /api/subjects/:id - Update subject
  • DELETE /api/subjects/:id - Delete subject

Classes

  • GET /api/classes - Get all classes
  • GET /api/classes/:id - Get single class
  • POST /api/classes - Create class
  • PUT /api/classes/:id - Update class
  • DELETE /api/classes/:id - Delete class

Rooms

  • GET /api/rooms - Get all rooms
  • GET /api/rooms/:id - Get single room
  • POST /api/rooms - Create room
  • PUT /api/rooms/:id - Update room
  • DELETE /api/rooms/:id - Delete room

Electives

  • GET /api/electives - Get all elective groups
  • GET /api/electives/:id - Get single elective group
  • POST /api/electives - Create elective group
  • PUT /api/electives/:id - Update elective group
  • DELETE /api/electives/:id - Delete elective group

Timetable

  • POST /api/timetable/generate - Generate timetable
  • GET /api/timetable - Get all timetables
  • GET /api/timetable/class/:classId - Get timetable by class
  • DELETE /api/timetable/:id - Delete timetable

🎯 Usage Flow

  1. Setup Academic Structure

    • Add all teachers with their availability
    • Add all classrooms and labs
    • Add all classes and divisions
    • Add all subjects (theory, lab, elective)
  2. Configure Elective Groups

    • Create elective groups for each class
    • Assign subjects, teachers, and rooms to groups
  3. Generate Timetable

    • Click "Generate Timetable" button
    • System will allocate slots following constraints:
      • Labs get continuous time blocks
      • Electives run in parallel
      • No teacher/room/class conflicts
  4. View & Export

    • View generated timetables by class
    • Export to PDF or Excel (coming soon)

πŸ”§ Current Status

βœ… Completed

  • Full MERN stack boilerplate
  • MongoDB models with proper schemas
  • Express API routes and controllers
  • React pages with TailwindCSS UI
  • CRUD operations for all entities
  • Placeholder scheduler services

🚧 To Implement

  • Actual timetable generation logic in scheduler services
  • Teacher availability constraint checking
  • Lab continuous slot allocation algorithm
  • Elective parallel scheduling logic
  • Backtracking for conflict resolution
  • PDF/Excel export functionality
  • Teacher-wise timetable view
  • Room occupancy charts

🀝 Contributing

This is a project scaffold. To implement the timetable generation logic:

  1. Complete constraintSolver.js - Main scheduling algorithm
  2. Implement labAllocator.js - Lab session scheduling
  3. Implement electiveAllocator.js - Elective group scheduling
  4. Complete conflictChecker.js - Validation logic

πŸ“ License

ISC

πŸ‘¨β€πŸ’» Author

Built with ❀️ for educational institutions implementing NEP guidelines.


Note: This is a boilerplate structure. The timetable generation logic (constraint solver, backtracking algorithm) needs to be implemented in the scheduler service files.

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages