Skip to content

MarufPulok/Class-Routine_Optimizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ“ Class Routine Optimizer

A modern, intelligent timetable generation system built with Django, MongoDB, and Genetic Algorithms. Class Routine Optimizer helps educational institutions automatically generate optimal class schedules that satisfy both hard and soft constraints.

Class Routine Optimizer Django MongoDB Genetic Algorithm SQLite

✨ Features

For Administrators

πŸ“š Data Management - Comprehensive CRUD operations for all timetable components:

  • πŸ‘¨β€πŸ« Instructor Management - Add, edit, and manage faculty members
  • 🏫 Room Management - Manage classrooms with seating capacity tracking
  • ⏰ Meeting Time Management - Configure available time slots and days
  • πŸ“– Course Management - Create courses with instructor assignments and student capacity
  • πŸ›οΈ Department Management - Organize courses by departments
  • πŸ“‹ Section Management - Manage class sections with course assignments

🧬 Genetic Algorithm Optimization - Advanced algorithm that:

  • Satisfies hard constraints (no conflicts, room capacity, instructor availability)
  • Optimizes soft constraints (preferred times, balanced schedules)
  • Configurable population size and mutation rates
  • Generates optimal timetables automatically

πŸ“Š Timetable Generation - Intelligent scheduling system:

  • Automatic conflict detection and resolution
  • Multi-constraint optimization
  • Real-time generation progress
  • Export to PDF format

πŸ“„ PDF Export - Download generated timetables as professional PDF documents

Authentication & Security

πŸ” Django Authentication - Secure user authentication system πŸ”’ JWT Token Support - RESTful API with JWT authentication πŸ‘€ User Profiles - Manage user profiles with additional information πŸ›‘οΈ Role-Based Access - Secure admin dashboard access

API Features

🌐 RESTful API - Complete REST API for all operations πŸ“– API Documentation - Interactive API docs with drf-spectacular (Swagger/ReDoc) πŸ”Œ CORS Support - Configured for frontend integration πŸ“ Serializers - Comprehensive data validation and serialization

πŸ› οΈ Tech Stack

Backend

  • Django 5.1 - Modern Python web framework
  • Django REST Framework - Powerful REST API toolkit
  • MongoDB - NoSQL database for flexible data storage (via mongoengine)
  • SQLite - Relational database for Django's built-in features
  • mongoengine - MongoDB ODM for Python
  • JWT Authentication - Secure token-based authentication

Services & Tools

  • drf-spectacular - OpenAPI 3.0 schema generation
  • python-decouple - Environment variable management
  • xhtml2pdf - PDF generation from HTML templates
  • Pillow - Image processing
  • django-cors-headers - CORS handling for API

Architecture

  • Repository Pattern - Data access abstraction layer
  • Service Layer - Business logic separation
  • Strategy Pattern - Pluggable generation algorithms
  • Factory Pattern - Dynamic strategy creation

πŸš€ Getting Started

Prerequisites

  • Python 3.8+ (Python 3.13 recommended)
  • MongoDB (local installation or MongoDB Atlas)
  • pip (Python package manager)
  • Virtual environment (recommended)

Installation

  1. Clone the repository
git clone https://github.com/yourusername/Class-Routine_Optimizer.git
cd Class-Routine_Optimizer
  1. Create and activate virtual environment
python -m venv venv

# On macOS/Linux
source venv/bin/activate

# On Windows
venv\Scripts\activate
  1. Install dependencies
cd projttgs
pip install -r requirements.txt
  1. Set up environment variables

Create a .env file in the projttgs directory:

# Django Settings
SECRET_KEY=your-secret-key-here
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1

# MongoDB Configuration
MONGODB_NAME=class_routine_db
MONGODB_HOST=localhost
MONGODB_PORT=27017
MONGODB_USER=
MONGODB_PASSWORD=
MONGODB_AUTH_SOURCE=admin

# CORS Settings (for frontend integration)
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000
  1. Set up the database
# Run Django migrations (for SQLite)
python manage.py migrate

# MongoDB will be automatically connected when the server starts
  1. Create a superuser (optional)
python manage.py createsuperuser
  1. Run the development server
python manage.py runserver
  1. Open your browser

Navigate to http://127.0.0.1:8000/

πŸ“ Project Structure

Class-Routine_Optimizer/
β”œβ”€β”€ projttgs/                    # Main project directory
β”‚   β”œβ”€β”€ accounts/                # User authentication and profiles
β”‚   β”‚   β”œβ”€β”€ services/           # Authentication and user services
β”‚   β”‚   β”œβ”€β”€ repositories/       # Data access layer
β”‚   β”‚   └── serializers.py      # API serializers
β”‚   β”‚
β”‚   β”œβ”€β”€ core/                    # Core utilities and base classes
β”‚   β”‚   β”œβ”€β”€ repositories/       # Base repository pattern
β”‚   β”‚   β”œβ”€β”€ services/           # Base service classes
β”‚   β”‚   └── exceptions.py       # Custom exceptions
β”‚   β”‚
β”‚   β”œβ”€β”€ routine/                 # Timetable generation app
β”‚   β”‚   β”œβ”€β”€ models.py           # MongoDB models (mongoengine)
β”‚   β”‚   β”œβ”€β”€ repositories/       # Data repositories
β”‚   β”‚   β”‚   β”œβ”€β”€ course_repository.py
β”‚   β”‚   β”‚   β”œβ”€β”€ department_repository.py
β”‚   β”‚   β”‚   β”œβ”€β”€ instructor_repository.py
β”‚   β”‚   β”‚   β”œβ”€β”€ meeting_time_repository.py
β”‚   β”‚   β”‚   β”œβ”€β”€ room_repository.py
β”‚   β”‚   β”‚   └── section_repository.py
β”‚   β”‚   β”œβ”€β”€ services/           # Business logic services
β”‚   β”‚   β”‚   β”œβ”€β”€ routine_generation_service.py
β”‚   β”‚   β”‚   β”œβ”€β”€ timetable_service.py
β”‚   β”‚   β”‚   └── pdf_generation_service.py
β”‚   β”‚   β”œβ”€β”€ strategies/         # Generation algorithms
β”‚   β”‚   β”‚   β”œβ”€β”€ base_strategy.py
β”‚   β”‚   β”‚   └── genetic_algorithm_strategy.py
β”‚   β”‚   β”œβ”€β”€ factories/          # Factory pattern implementations
β”‚   β”‚   β”‚   └── generation_factory.py
β”‚   β”‚   └── serializers.py      # API serializers
β”‚   β”‚
β”‚   β”œβ”€β”€ projttgs/               # Django project settings
β”‚   β”‚   β”œβ”€β”€ settings.py         # Main configuration
β”‚   β”‚   β”œβ”€β”€ urls.py             # URL routing
β”‚   β”‚   └── wsgi.py             # WSGI configuration
β”‚   β”‚
β”‚   β”œβ”€β”€ templates/              # HTML templates
β”‚   β”œβ”€β”€ static/                 # Static files (CSS, JS, images)
β”‚   β”œβ”€β”€ requirements.txt        # Python dependencies
β”‚   └── manage.py               # Django management script
β”‚
└── README.md                   # Project documentation

🎨 Key Features Implementation

Genetic Algorithm Strategy

The timetable generation uses a sophisticated genetic algorithm that:

  • Population Initialization - Creates diverse initial schedules
  • Fitness Evaluation - Scores schedules based on constraint satisfaction
  • Selection - Chooses best-performing schedules for reproduction
  • Crossover - Combines features from parent schedules
  • Mutation - Introduces random variations to explore solution space
  • Convergence - Iteratively improves until optimal solution is found

Repository Pattern

Data access is abstracted through repositories:

  • Separation of Concerns - Business logic separated from data access
  • Testability - Easy to mock and test
  • Flexibility - Can switch data sources without changing business logic

Service Layer Architecture

Business logic is encapsulated in service classes:

  • RoutineGenerationService - Orchestrates timetable generation
  • TimetableService - Manages timetable operations
  • PDFGenerationService - Handles PDF export functionality

πŸ”§ Available Scripts

# Run development server
python manage.py runserver

# Run migrations
python manage.py migrate

# Create migrations
python manage.py makemigrations

# Create superuser
python manage.py createsuperuser

# Collect static files
python manage.py collectstatic

# Run tests
python manage.py test

# Access Django shell
python manage.py shell

# Access Django shell with MongoDB models
python manage.py shell_plus

πŸ“ API Documentation

Once the server is running, access the interactive API documentation:

πŸ—„οΈ Database Schema

The application uses a hybrid database approach:

MongoDB (via mongoengine)

  • Room - Classroom information
  • Instructor - Faculty members
  • MeetingTime - Available time slots
  • Course - Course details with instructor assignments
  • Department - Academic departments
  • Section - Class sections with course assignments

SQLite (Django ORM)

  • User - Django authentication users
  • Profile - User profile information
  • Sessions - Django session management

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is open source and available under the MIT License.

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

Maruf Hossain

πŸ™ Acknowledgments

  • Built with Django and Django REST Framework
  • Genetic algorithm implementation for constraint optimization
  • MongoDB for flexible data storage
  • UI components styled with Bootstrap
  • PDF generation powered by xhtml2pdf

⭐ Star History

If you find this project helpful, please consider giving it a star!


Note: This project uses both MongoDB (for timetable data) and SQLite (for Django's built-in features). Make sure MongoDB is running before starting the development server.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published