An automated college timetable generation system using constraint satisfaction (CSP) and genetic algorithms with intelligent teacher substitution.
- Automated Generation: CSP and genetic algorithm-based timetable generation
- Smart Scheduling: Constraint-based optimization for conflict-free schedules
- Multi-view Display: Calendar view, grid view, and detailed reports
- Export Options: PDF, CSV, and print-friendly formats
- Real-time Updates: Instant timetable updates when resources change
- Teachers: CRUD operations with workload tracking and availability management
- Classes: Manage class groups with student count and coverage tracking
- Subjects: Theory and lab subjects with duration and room requirements
- Rooms: Room allocation with capacity and utilization tracking
- Time Slots: Flexible configuration for teaching hours and breaks
- Teacher Workload: Visual charts showing load distribution across all teachers
- Room Utilization: Pie charts and usage statistics for optimal space planning
- Coverage Reports: Class-wise and subject-wise coverage analysis
- Key Insights: Busiest teachers, most used rooms, popular subjects at a glance
- Load Factor Analysis: Real-time monitoring of teacher and class loads
- Intelligent Substitution: Scoring-based teacher replacement (availability, expertise, workload)
- Bulk Import: CSV import for teachers, subjects, classes, and rooms
- Conflict Detection: Automatic detection of scheduling conflicts
- Load Balancing: Even distribution of workload across teachers
- Multi-period Labs: Support for lab sessions spanning multiple consecutive periods
- Responsive Design: Works seamlessly on desktop, tablet, and mobile devices
- Python 3.11+ (Download from python.org)
- Git (Download from git-scm.com)
- pip (Comes with Python)
git clone https://github.com/coderpurohit/time.git
cd timeFor Windows:
cd backend
start.batFor Mac/Linux:
cd backend
./start.shNote: The script is already executable. If you get a permission error, run: chmod +x start.sh
Or manually:
cd backend
python -m venv venv
venv\Scripts\activate # Windows
source venv/bin/activate # Mac/Linux
pip install -r requirements.txt
python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000The backend will:
- β Create a virtual environment
- β Install all dependencies
- β Initialize the SQLite database
- β Start the server on http://localhost:8000
Open your browser and navigate to:
Main Application:
- π Timetable Management: http://localhost:8000/timetable_page.html
- π Calendar View: http://localhost:8000/calendar_page.html
- π Reports & Analytics: http://localhost:8000/reports_page.html
- π Dashboard: http://localhost:8000/dashboard.html
API Documentation:
- π Swagger UI: http://localhost:8000/docs
- π ReDoc: http://localhost:8000/redoc
# Clone and start in one go
git clone https://github.com/coderpurohit/time.git && cd time/backend && start.batWindows:
- Press
Ctrl + Cin the terminal - Or run:
cd backend && stop.bat
Mac/Linux:
- Press
Ctrl + Cin the terminal
Navigate through the wizard tabs:
- Subjects/Courses: Add subjects with type (theory/lab), duration, and room requirements
- Teachers: Add teachers with max hours per week
- Classes: Add class groups with student count
- Rooms: Add rooms with capacity and type
- Lessons: Define lesson requirements (optional)
- Click "Generate New Schedule" button
- Choose CSP or Genetic algorithm
- System automatically creates conflict-free schedule
- Review Tab: See full timetable grid
- Calendar: Monthly view with daily schedules
- Reports: Analytics and workload distribution
- Export: Download as PDF or CSV
backend/
βββ app/
β βββ api/routers/ # API endpoints
β βββ domain/entities/ # Business entities
β βββ infrastructure/ # Database models
β βββ services/ # Business logic
β βββ solver/ # CSP & Genetic algorithms
βββ timetable.db # SQLite database
βββ requirements.txt # Python dependencies
root/
βββ timetable_page.html # Main timetable interface
βββ calendar_page.html # Calendar view
βββ reports_page.html # Analytics dashboard
βββ dashboard.html # Landing page
βββ *.js # JavaScript modules
Configure in Review tab:
- Teaching hours per day
- Days of the week
- Lunch break timing
- Period duration
The CSP solver enforces:
- No teacher overlap (one class per slot)
- No room overlap (one booking per slot)
- No class overlap (one period per slot)
- Lab sessions span consecutive slots
teachers- Teacher information and availabilitysubjects- Subject details and requirementsrooms- Room capacity and resourcesclass_groups- Class informationtime_slots- Available time slots
timetable_versions- Generated timetablestimetable_entries- Individual schedule entrieslessons- Lesson requirements (optional)
holidays- Holiday calendarsubstitutions- Teacher substitutionsschedule_config- Configuration settings
cd backend
# Start server first
start.bat
# Run tests
python tests/test_api_flow.py
python tests/test_auto_substitution.py
python tests/test_operational.pyIssue: Port 8000 already in use
# Windows: Find and kill process using port 8000
netstat -ano | findstr :8000
taskkill /PID <process_id> /F
# Mac/Linux: Find and kill process using port 8000
lsof -ti:8000 | xargs kill -9Issue: Python not found
- Ensure Python 3.11+ is installed:
python --versionorpython3 --version - Add Python to your system PATH
- Download from python.org
Issue: Module not found errors
cd backend
# Activate virtual environment
venv\Scripts\activate # Windows
source venv/bin/activate # Mac/Linux
# Reinstall dependencies
pip install -r requirements.txtIssue: Changes not showing up
- Hard refresh your browser:
Ctrl + Shift + R(Windows/Linux) orCmd + Shift + R(Mac) - Clear browser cache
- Check browser console for errors (F12)
Issue: API connection errors
- Verify backend is running at http://localhost:8000
- Check CORS settings in
backend/app/main.py - Ensure no firewall blocking port 8000
Issue: Database locked or corrupted
cd backend
# Backup existing database
copy timetable.db timetable.db.backup # Windows
cp timetable.db timetable.db.backup # Mac/Linux
# Reset database
python setup_database.pyIssue: No data showing up
- Check if database exists:
backend/timetable.db - Verify data via API docs: http://localhost:8000/docs
- Try regenerating timetable from the UI
"INFEASIBLE" when generating timetable
- Too many lessons for available time slots
- Conflicting constraints (teacher/room availability)
- Reduce lesson count or increase available time slots
"Unknown Subject" in timetable
- Subject was deleted but still referenced in lessons
- Regenerate timetable after adding/removing subjects
Teachers not balanced
- Ensure all teachers have reasonable max hours per week
- Check lesson assignments in Lessons tab
- Regenerate timetable to redistribute load
Interactive API documentation available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
GET /api/teachers/- List all teachersPOST /api/solvers/generate- Generate timetableGET /api/timetables/latest- Get latest timetablePOST /api/substitutions/auto-assign- Auto-assign substitute
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- OR-Tools for constraint programming
- FastAPI for the backend framework
- Chart.js for data visualization
For questions or support, please open an issue on GitHub.
Made with β€οΈ for educational institutions