{"id":28703043,"url":"https://github.com/rooseveltalej/automatic-class-schedule-generation-system","last_synced_at":"2026-05-17T02:41:15.242Z","repository":{"id":298929198,"uuid":"876341082","full_name":"rooseveltalej/Automatic-Class-Schedule-Generation-System","owner":"rooseveltalej","description":"Proyecto 3 - Lenguajes de Programación","archived":false,"fork":false,"pushed_at":"2025-06-13T16:24:32.000Z","size":95,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-13T17:36:32.842Z","etag":null,"topics":["prolog-implementation","python3","react"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rooseveltalej.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-21T20:00:19.000Z","updated_at":"2025-06-13T16:24:36.000Z","dependencies_parsed_at":"2025-06-13T17:36:35.674Z","dependency_job_id":"56e1f6ca-fb2b-4e07-aeb4-f6a149dfb7b5","html_url":"https://github.com/rooseveltalej/Automatic-Class-Schedule-Generation-System","commit_stats":null,"previous_names":["rooseveltalej/automatic-class-schedule-generation-system"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rooseveltalej/Automatic-Class-Schedule-Generation-System","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rooseveltalej%2FAutomatic-Class-Schedule-Generation-System","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rooseveltalej%2FAutomatic-Class-Schedule-Generation-System/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rooseveltalej%2FAutomatic-Class-Schedule-Generation-System/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rooseveltalej%2FAutomatic-Class-Schedule-Generation-System/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rooseveltalej","download_url":"https://codeload.github.com/rooseveltalej/Automatic-Class-Schedule-Generation-System/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rooseveltalej%2FAutomatic-Class-Schedule-Generation-System/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017151,"owners_count":26085983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["prolog-implementation","python3","react"],"created_at":"2025-06-14T13:06:32.438Z","updated_at":"2025-10-13T22:10:14.272Z","avatar_url":"https://github.com/rooseveltalej.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Automatic Class Schedule Generation System\n\nThis project provides a robust solution for the automatic generation of class schedules, specifically designed for the Computer Engineering program at the Costa Rica Institute of Technology, San Carlos Campus. The system leverages a Prolog backend for constraint logic and an interactive React frontend for user interaction.\n\n## Table of Contents\n- [General Description](#general-description)\n- [Key Features](#key-features)\n- [System Architecture](#system-architecture)\n  - [Backend](#backend)\n  - [Frontend](#frontend)\n- [Data Structure](#data-structure)\n- [Installation and Setup](#installation-and-setup)\n  - [Prerequisites](#prerequisites)\n  - [Backend Setup](#backend-setup)\n  - [Frontend Setup](#frontend-setup)\n- [Usage Guide](#usage-guide)\n  - [API Endpoints](#api-endpoints)\n- [Technical Challenges](#technical-challenges)\n- [Future Enhancements](#future-enhancements)\n\n## General Description\n\nThe core of this system is a logic engine programmed in Prolog, capable of solving the complex constraints of assigning courses, professors, classrooms, and time slots to generate up to 3 viable, conflict-free schedule solutions. User interaction is handled through a modern web application that consumes a RESTful API service developed in FastAPI (Python).\n\n## Key Features\n\n* **Automatic Schedule Generation**: Creates complete and logically conflict-free schedules.\n* **Two Generation Modes**:\n    1.  **By Courses**: Allows the user to select a set of courses and generates possible schedules for that selection.\n    2.  **By Semester**: Automatically generates a schedule for all courses of a given semester (odd or even).\n* **Intuitive User Interface**: Developed with React and TypeScript, it offers a fluid user experience for selecting courses and visualizing the generated schedules.\n* **Clear Visualization**: Displays up to 3 schedule options in an easy-to-read weekly calendar component (`react-big-calendar`).\n* **Dynamic Data Management**: Professor and course information is dynamically loaded from an SQLite database into the Prolog engine when the server starts.\n\n## System Architecture\n\n### Backend\n\nThe backend is built with **Python** and the **FastAPI** framework, providing a RESTful API for communication with the frontend.\n\n* **API Server**: `app.py` contains the API endpoints. It uses FastAPI for high performance.\n* **Scheduling Logic**: The `scheduling.pl` file contains all the constraint logic and rules in **Prolog**. It defines the rules to avoid conflicts between schedules, classrooms, and professors.\n* **Database**: **SQLite** (`scheduling.db`) is used to persist course and professor information. Initial data is hardcoded in `app.py` for a first-time setup.\n* **Python-Prolog Integration**: The `pyswip` library is used as a bridge to make queries from Python to the Prolog engine. On startup, the server loads data from SQLite and asserts it as facts in the Prolog knowledge base.\n\n### Frontend\n\nThe frontend is a Single Page Application (SPA) developed with **React** and **TypeScript**, using **Vite** as the build tool.\n\n* **Main Components**:\n    * `HomePage.tsx`: Allows users to select individual courses to generate a custom schedule.\n    * `SemesterSchedulePage.tsx`: Offers the option to generate a full schedule for an odd or even semester.\n    * `ScheduleDisplay.tsx`: Renders the generated schedule options in a visual calendar.\n    * `CourseSelection.tsx`: Manages the course selection by the user.\n* **Backend Communication**: `axios` is used to make requests to the backend API to fetch course data and the generated schedules.\n* **Styling**: The interface is styled with **TailwindCSS** for a modern and responsive design.\n\n## Data Structure\n\n* **Professors**: Name, ID, available schedules, and the courses they can teach (max 3 per semester).\n* **Courses**: Name, required classroom type, credits, and the semester it belongs to.\n* **Classrooms**: Name, number, and capacity.\n* **Schedules**: Time slots are managed from Monday to Friday, from 7:00-11:30 and 12:30-16:00.\n\n## Installation and Setup\n\n### Prerequisites\n\n* Python 3.8+\n* SWI-Prolog\n* Node.js and npm (or yarn)\n\n### Backend Setup\n\n1.  **Clone the repository:**\n    ```bash\n    git clone https://github.com/rooseveltalej/Automatic-Class-Schedule-Generation-System\n    cd Automatic-Class-Schedule-Generation-System/backend\n    ```\n\n2.  **Create a virtual environment and install dependencies:**\n    ```bash\n    python -m venv venv\n    source venv/bin/activate  # On Windows: venv\\Scripts\\activate\n    pip install -r requirements.txt\n    ```\n    Dependencies include `fastapi`, `uvicorn`, and `pyswip`.\n\n3.  **Start the backend server:**\n    ```bash\n    uvicorn app:app --reload\n    ```\n    The server will be available at `http://127.0.0.1:8000`.\n\n4.  **Initialize the Database and Prolog (only the first time!):**\n    Once the server is running, open your browser and visit the following URLs in order to populate the database and load the data into Prolog.\n    -   `http://127.0.0.1:8000/insert_professors/`\n    -   `http://127.0.0.1:8000/insert_courses/`\n    -   `http://127.0.0.1:8000/load_professors_into_prolog/`\n    -   `http://127.0.0.1:8000/load_courses_into_prolog/`\n\n    *Note: The last two endpoints must be executed every time the server is restarted to load the data into Prolog's memory*.\n\n### Frontend Setup\n\n1.  **Navigate to the frontend folder:**\n    ```bash\n    cd ../frontend\n    ```\n\n2.  **Install dependencies:**\n    ```bash\n    npm install\n    ```\n\n3.  **Start the React application:**\n    ```bash\n    npm run dev\n    ```\n    The application will be available at `http://localhost:5173` (or the port Vite assigns).\n\n## Usage Guide\n\nOnce both the backend and frontend servers are running, you can access the application through the frontend URL.\n\n1.  **Generate schedule by courses**: On the home page, select the courses you want and click \"Generate Schedule\". Up to 3 compatible schedule options will be displayed.\n2.  **Generate schedule by semester**: Go to the \"Semester Schedule\" page, choose between odd or even semester, and click \"Get Schedule\".\n\n### API Endpoints\n\nThe FastAPI backend exposes several endpoints for data management and schedule generation:\n\n* `GET /get_courses/`: Returns a list of all available courses from the database.\n* `GET /get_professors/`: Returns a list of all professors.\n* `GET /get_schedule/?courses=\u003ccourse1\u003e\u0026courses=\u003ccourse2\u003e`: Generates a schedule for a specified list of courses.\n* `GET /generate_schedule/?parity=\u003codd|even\u003e`: Generates a schedule for all courses in an odd or even semester.\n* `GET /clear_prolog_facts/`: Deletes all `course` and `professor` facts from the Prolog session.\n* `GET /list_prolog_facts/`: Lists the facts currently loaded in Prolog for debugging purposes.\n\n## Technical Challenges\n\n* **Constraint Logic in Prolog**: The efficient implementation of constraint logic programming in Prolog.\n* **Backend-Frontend Integration**: Integration of the Prolog backend with a user-friendly frontend.\n* **Schedule Optimization**: Optimization of the schedule generation to provide the best possible solutions.\n\n## Future Enhancements\n\n* Implementation of additional constraints (e.g., professor preferences, room equipment).\n* Extension to handle multiple academic programs or departments.\n* Development of a web-based interface for wider accessibility.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frooseveltalej%2Fautomatic-class-schedule-generation-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frooseveltalej%2Fautomatic-class-schedule-generation-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frooseveltalej%2Fautomatic-class-schedule-generation-system/lists"}