# masterprg/kakaoo architecture

> Architecture diagram of the GitHub repository masterprg/kakaoo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/masterprg/kakaoo
- Repository: https://github.com/masterprg/kakaoo

## Overview

##### Project Type and Purpose
- The project is a Django-based web application designed for scheduling university courses. It uses three specialized algorithms – a Graph Coloring algorithm, a Genetic Algorithm, and a Penalty Genetic Algorithm – to group lessons, arrange them throughout the week, and handle conflicts.
- This places the project in the full-stack web application category, with both a presentation layer (front end via HTML templates and static resources) and a business logic layer (scheduler algorithms and Django backend).

##### Analyzing the File Structure
- Top-Level Files and Directories:
- “app/”: Contains the Django project.
- “app/app/”: Contains the core Django configuration files such as settings.py, asgi.py, wsgi.py, and urls.py.
- “app/manage.py”: The management script to run commands like migrations and starting the server.
- “app/scheduler/”: The dedicated Django app for scheduling, holding models, views, URLs, admin definitions, and migrations.
- “app/scheduler/Graph.py”, “app/scheduler/genetic_algorithm.py”, etc.: These files house the scheduling algorithms (graph coloring, genetic, penalty genetic) that form the core business logic.
- “app/templates/” and “app/static/”: These directories contain the HTML templates and static assets (CSS, JS) used by the front end.

##### Key Architectural Components
a. Presentation Layer:
- Client/browser sends HTTP requests.
- Django views in the scheduler app render HTML using templates under “app/templates/”.
- Static files (CSS/JS) under “app/static/scheduler/” provide UI styling and interactions.
b. Application Layer (Backend):
- Django Core: Configured from “app/app/” with URL configurations directing to the scheduler app via “app/scheduler/urls.py”.
- Scheduler App: Contains routes, views, and models to handle user operations such as adding courses, professors, and linking them.
- Business Logic: Scheduler-specific algorithms (Graph.py, genetic_algorithm.py, etc.) manage the complex scheduling operations.
c. Data Layer:
- Django Models under “app/scheduler/models.py” define the database structure for courses, professors, and schedule relationships.
- Migrations in “app/scheduler/migrations/” ensure that the database schema stays in sync with the models.

##### Relationships and Interactions
- The browser communicates with the Django server, which uses its URL routing system to dispatch requests.
- Views use the scheduler’s models to retrieve/update data in the database.
- When a scheduling operation is triggered, the view calls the appropriate algorithm module (Graph Coloring, Genetic Algorithm, Penalty Genetic Algorithm) to determine optimal scheduling.
- The outcomes are passed back to views, which then render the schedule using templates.
- Admin interfaces (configured in “app/scheduler/admin.py”) allow management of courses and professors.

##### Important Architectural Patterns
- MVC (or MTV in Django terms): Templates (View), Models (Data), and Views (Controller in Django) are clearly separated.
- Layered Architecture: Distinct separation between presentation (templates, static files), business logic (views and algorithm modules), and data persistence (models and migrations).
- Algorithm Isolation: The scheduling logic is modularized into separate files, making it easier to maintain or replace.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client"
        Browser["Browser (Client)"]:::client
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        Templates["Templates (HTML)"]:::presentation
        Static["Static Assets (CSS/JS)"]:::presentation
    end

    %% Backend Layer
    subgraph "Backend"
        DjangoCore["Django Core (Project Configuration)"]:::backend
        SchedulerApp["Scheduler App (Routing, Views, Models, Admin)"]:::backend
    end

    %% Business Logic Layer
    subgraph "Business Logic"
        GraphAlgo["Graph Coloring Algorithm"]:::logic
        GeneticAlgo["Genetic Algorithm Module"]:::logic
        PenaltyAlgo["Penalty Genetic Algorithm"]:::logic
    end

    %% Data Layer
    subgraph "Data Layer"
        DB["Database (Models & Migrations)"]:::data
    end

    %% Connections (Vertical Flow)
    Browser -->|"HTTP-request"| DjangoCore
    DjangoCore -->|"URL-routing"| SchedulerApp

    SchedulerApp -->|"Executes"| GraphAlgo
    SchedulerApp -->|"Executes"| GeneticAlgo
    SchedulerApp -->|"Executes"| PenaltyAlgo

    SchedulerApp -->|"Data-access"| DB

    SchedulerApp -->|"Renders"| Templates
    Templates -->|"Delivered-HTML"| Browser

    %% Static Assets served to Browser
    Static ---|"Serves CSS/JS"| Browser

    %% Click Events
    click DjangoCore "https://github.com/masterprg/kakaoo/tree/main/app/app/"
    click SchedulerApp "https://github.com/masterprg/kakaoo/tree/main/app/scheduler/"
    click GraphAlgo "https://github.com/masterprg/kakaoo/blob/main/app/scheduler/Graph.py"
    click GeneticAlgo "https://github.com/masterprg/kakaoo/blob/main/app/scheduler/genetic_algorithm.py"
    click Templates "https://github.com/masterprg/kakaoo/tree/main/app/templates/"
    click Static "https://github.com/masterprg/kakaoo/tree/main/app/static/scheduler/"

    %% Styles
    classDef client fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef presentation fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef backend fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef logic fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef data fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
```
