Menu
Menu
Close
Close

CourseHen
A system for automatically generating university course timetables using constraint-based optimization. It handles complex scheduling requirements such as professor availability, course prerequisites, cross-department courses, and varied time slot patterns.
Overview
The University Course Scheduler is a system for automatically generating university course timetables using constraint-based optimization. It was developed to handle complex scheduling requirements such as professor availability, course prerequisites, cross-department or cross-program courses, and varied time slot patterns. Instead of manually scheduling classes (which is time-consuming and error-prone), this system uses a solver to produce an optimized schedule that meets all specified constraints and preferences. It can manage scheduling across multiple departments and programs simultaneously, ensuring that resources (professors, rooms, time slots) are utilized effectively without conflicts.
Architecture & Components
The application employs a hybrid architecture combining a Node.js/Express backend with a Python constraint solving engine, plus a React frontend for the user interface. All data is stored in a PostgreSQL relational database. The major components are:
- Database: PostgreSQL is used to store all the academic data and results. Key tables (entities) include Departments, Programs, Courses, Professors, TimeSlots, Semesters, etc., as well as relationships like which courses are in which program, prerequisite mappings, which professors can teach which course, and professors' available times. When a schedule is generated, the results are saved in tables for Schedules and ScheduledCourses (which link a course offering to a professor and time slot) and any Conflicts identified. The database schema is designed with foreign keys to maintain integrity (e.g., a ScheduledCourse links to valid Course, Professor, TimeSlot records).All these components work in concert: for example, an admin uses the React frontend to request a new schedule for next semester; the request goes to Node/Express, which gathers data from Postgres (via Sequelize), calls the Python solver; the solver returns an optimized schedule or any conflicts; Node saves the result to the database and the frontend displays it for the admin to review.
Data Model
The system's data model captures the academic scheduling domain comprehensively. Some key entities and relationships:
From
manual
scheduling
to
automated
optimization
Key Features and Constraints
Some of the advanced features and constraints supported by the University Scheduler include:
1. Multi-Program Course Association
Courses can belong to multiple programs or departments, each potentially with different attributes (e.g., a course can be core in one program and elective in another). The scheduler accounts for cross-program courses so that if a course is required in two programs, the schedule avoids conflicts for students taking both. It also handles specifying the number of class instances needed if two programs both require the course (shared courses).
2. Advanced Scheduling Constraints
The system handles a variety of complex rules:
3. Conflict Detection & Resolution
After generating a schedule, the system automatically identifies any conflicts. For instance, if two courses ended up assigned to the same professor at the same time (which shouldn't happen if constraints are correct, but could if input data had issues) or if a certain course couldn't be scheduled at all due to constraints (unschedulable course). These are logged as Conflict records with explanations. The admin interface highlights conflicts and allows manual resolution: an administrator can override certain assignments or adjust parameters and re-run the solver for just the conflicted parts. This feature ensures that the final schedule presented is feasible and any unresolved issues are clearly flagged.
4. Flexible Time Management
The scheduler supports variable course durations and multiple scheduling patterns. For example, it can schedule courses that meet once per week for 3 hours, or twice a week for 1.5 hours each, etc., depending on how the TimeSlots are configured. It also can accommodate single, double, or triple period classes, and ensures that if a class occupies multiple consecutive slots (like a double-period lab), those slots are available and assigned together. This flexibility is crucial for modeling real university timetables where not all classes have the same format.
Scheduling Algorithm and Integration
At the heart of the system is the constraint solver powered by Google OR-Tools CP-SAT. The Node.js backend gathers all required data and then launches the Python solver process, passing the data via inter-process communication (serialization to JSON). The Python engine formulates the scheduling problem as a Constraint Satisfaction Problem:
The integration between Node and Python is carefully designed: the Node backend uses a child process to run the Python script, feeding it input via stdin and reading results from stdout. This decoupling means the solver could even be swapped out or updated independently of the Node API. When the Python solver finishes, the Node process receives the JSON output, then:
2. Returns the results to the frontend (the admin UI) via the API response. The user can then review the proposed schedule and any conflict alerts.
All communications are secured via JWT auth on the API, so only authorized users can trigger scheduling or view results. The design also ensures that if the Python solver or Node service crashes, it won't bring down the entire system – they are separate components with defined interaction points.
Deployment and Requirements
To run the University Scheduler, one needs both Node.js (for the backend and frontend build) and Python (for the solver). The project specifies using Node v14+ and Python 3.10 (with OR-Tools library installed). PostgreSQL 14 is used as the database. During deployment, environment variables are used to configure database connection details, JWT secrets, and the paths to the Python interpreter if needed.
In a development setup, one would install Node dependencies (for the frontend and backend), Python dependencies (OR-Tools), set up the Postgres database with initial schema (there might be scripts or Sequelize migrations for this), and then start the backend server and frontend dev server. The backend's ability to spawn the Python process assumes the Python environment is accessible on the same host and has the required solver libraries.
The architecture is designed with separation of concerns, so it would be feasible to containerize each piece (frontend, backend, solver, database) for production. The system's modular design and robust constraint-solving approach make it a powerful tool for university administrators to generate and manage course schedules efficiently.
Optimizing
schedules,
maximizing
efficiency
