The Schedule Optimization Project is a tool designed to generate optimized work schedules for agents, considering constraints like availability, preferences, and training days. It consists of a Flask-based backend for scheduling logic and a Vue.js-powered frontend for user interaction. The backend communicates with the frontend via REST APIs, exchanging data such as agent schedules and configuration parameters.
graph TD
A[User] -->|Interacts With| E[Frontend - Vue.js]
E -->|Sends HTTP Requests| B[Backend - Flask]
B -->|Returns Schedule as JSON Responses| E
B -->|Reads/Writes| C[Configuration File - config.json]
B -->|Uses| D[Google OR-Tools]
D -->|Optimizes| F[Schedule]
F -->|Returns Optimized Schedule| B
E -->|Displays Schedule| A
C -->|Defines| G[Agents, Shifts, Constraints]
G -->|Used By| B
- Frontend: Vue.js, JavaScript, HTML, CSS
- Backend: Flask, Python
- Optimization Library: Google OR-Tools
- Configuration: JSON
- Build Tools: Node.js, npm
- Testing: Pytest (backend), Jest (frontend)
- Separation of Concerns: The project separates the frontend and backend, allowing independent development and testing.
- RESTful API: The backend exposes REST APIs for communication, ensuring a clean interface between the frontend and backend.
- Configurable Design: The use of config.json allows users to customize agent preferences, vacations, and constraints without modifying the code.
- Vue.js for Interactivity: The frontend leverages Vue.js for dynamic and reactive user interfaces.
- Google OR-Tools: The backend uses OR-Tools for efficient constraint-based scheduling.
The project is divided into two main components: Frontend and Backend.
- Main Entry Point:
frontend/src/main.js- Initializes the Vue.js application and mounts it to the DOM.
- Purpose: Main application component that manages user input and displays schedules.
- Key Features: Reactive data binding, API calls to the backend.
- Purpose: Displays the generated schedule in a tabular format.
- Key Features: Dynamic rendering of schedules, color-coded cells for vacations.
- Main Entry Point:
backend/app.py- Contains the Flask application and API endpoints.
- Purpose: Handles API requests and communicates with the optimization engine.
- Key Features: RESTful API design, JSON-based communication.
- Purpose: Performs constraint-based scheduling.
- Key Features: Efficient optimization algorithms.
backend/app.pynow keeps the HTTP/API layer and delegates optimization to the solver package.backend/solver/engine.pyorchestrates solve flow (context creation, constraint registry execution, objective, solve, extraction).backend/solver/context.pycentralizes runtime model data shared by constraint modules.backend/solver/registry.pyregisters and applies constraint groups in deterministic order.- Constraint groups are split into:
backend/solver/constraints/hard.pybackend/solver/constraints/soft.pybackend/solver/constraints/mixed.py
- Objective assembly is isolated in
backend/solver/objective.py.
The three planning modes share the same _build_planning_payload() pipeline, vacation
catalog, constraints, and objective:
- new generation starts without seeded assignments;
- continuity generation locks assignments from the previous seven days;
- existing-schedule optimization locks current assignments in strict mode, or treats them as high-priority preservation targets in soft mode.
Full and half vacations are therefore available to every mode. Mode-specific inputs only provide continuity or preservation context; they do not select a different solver or relax staffing and workload rules.
backend/
│ ├── app.py # Backend entry point
│ ├── config.json # Configuration file
│ └── tests/ # Backend unit tests
│
frontend/
├── src/ # Frontend source code
│ ├── main.js # Frontend entry point
│ ├── App.vue # Main frontend component
│ └── PlanningTable.vue # Component displaying the schedule
└── tests/ # Frontend unit tests
- Description: Generates a schedule based on the provided time period.
- Request Body: A JSON object specifying the time period for which the schedule should be generated.
- Response: Returns the generated schedule in JSON format.
- Description: Retrieves the schedule for the previous week.
- Request Body: A JSON object specifying the start date of the schedule to be generated to retrieve the previous 7 days.
- Response: Returns a JSON object containing the previous week's schedule.
Error Handling: The backend handles errors related to user data (ex. invalid constraints) and returns clear error messages to the frontend (we try, at least).
Scalability: Although designed for medium-sized teams, the project can be extended to handle more complex schedules by adjusting constraints and optimizing algorithms.
Testing:
- Backend : Unit tests for the API and optimization algorithms are in backend/tests/.
- Frontend : Tests for Vue.js components are in frontend/tests/.