# adroit-abhik/adroit-scheduler architecture

> Architecture diagram of the GitHub repository adroit-abhik/adroit-scheduler, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adroit-abhik/adroit-scheduler
- Repository: https://github.com/adroit-abhik/adroit-scheduler

## Overview

1. **What this repository is**
   - A single Django monolith for university timetable generation.
   - The core idea is to collect academic resources and then produce a timetable using a **genetic algorithm** that balances hard and soft scheduling constraints.

2. **Top-level application boundary**
   - `M1/` is the Django project configuration layer: settings, root URL routing, and WSGI entrypoint.
   - `mm1/` is the main application containing the domain logic, data models, forms, view handlers, admin registration, and tests.

3. **Persistence and runtime**
   - The project uses **SQLite** via `db.sqlite3`, so the architecture is self-contained and local-file backed.
   - The runtime dependency profile is minimal: **Python 3.6+** and **Django 2+**.

4. **Domain model layer**
   - `mm1/models.py` and the migrations define the core scheduling entities.
   - The file names and migration history indicate administrative entities such as departments, courses, instructors/mentors, rooms, and sections/classes.
   - `0002_section_num_class_in_week.py` shows that section-level weekly load is part of the schema, which matters for timetable generation constraints.

5. **Schema evolution**
   - The `mm1/migrations/` directory shows the data model is Django-ORM managed and has evolved at least twice.
   - That means the timetable logic depends on persisted relational state, not on in-memory or file-based configuration.

6. **User-facing CRUD workflow**
   - The templates `addep.html`, `adcrs.html`, `adins.html`, `addrm.html`, and `addsec.html` suggest separate create/edit screens for each scheduling entity.
   - The list pages `deptlist.html`, `crslist.html`, `instlist.html`, `rmlist.html`, and `seclist.html` indicate a classic admin workflow: define resources first, then generate schedules from them.

7. **Timetable generation flow**
   - The main output pages are `timetable.html` and `timetable(1).html`.
   - The timetable generation is likely triggered from a dedicated route/view in `mm1/views.py`, which reads persisted entities, runs the optimization logic, and renders the schedule result into the template.

8. **Optimization boundary**
   - The README is explicit that the timetable is generated by a **genetic algorithm**.
   - This means the architectural boundary is between:
     - deterministic data collection/storage in Django models, and
     - heuristic optimization that assigns courses, rooms, teachers, and time slots while respecting constraints.

9. **Constraint semantics**
   - Hard constraints listed in the README include unique class timing, room capacity, no double-booked rooms, unique teacher timing, and correct teacher-course assignment.
   - Soft constraints include matching section requirements, department alignment, and even weekly distribution.
   - These constraints are the core business rules that the optimization engine must satisfy or optimize against.

10. **Presentation layer**
    - `templates/base.html` is the shared layout shell, and the remaining templates extend it for forms, lists, and timetable output.
    - Styling is split between project-local CSS in `static/CSS/style.css` and the copied Django admin assets under `assets/admin/`, which suggests the project reuses standard admin UI resources.

11. **Django admin and form handling**
    - `mm1/admin.py` exposes the domain entities to Django admin.
    - `mm1/forms.py` likely provides structured input forms for the add/edit screens, separating validation from view rendering.

12. **Routing and request flow**
    - `M1/urls.py` is the project-level router; `mm1/urls.py` holds application routes.
    - The request path is therefore: browser → Django URL resolver → `mm1.views` → ORM/forms → template rendering → timetable or CRUD page.

13. **What is not present**
    - There is no sign of a separate API service, background worker, message queue, or external database.
    - The architecture is therefore a compact, single-process web app with all major logic inside the Django app.

14. **Best diagram focus**
    - Show four main blocks: **UI templates**, **Django views/forms**, **ORM + SQLite models**, and **genetic timetable optimizer**.
    - The optimizer should be drawn as consuming model data and producing a rendered timetable, with admin CRUD feeding the data store upstream.

Main entry points: [`mm1/views.py`](https://github.com/adroit-abhik/adroit-scheduler/blob/master/mm1/views.py) (Scheduler), [`mm1/models.py`](https://github.com/adroit-abhik/adroit-scheduler/blob/master/mm1/models.py) (Domain models), [`templates/base.html`](https://github.com/adroit-abhik/adroit-scheduler/blob/master/templates/base.html) (Base layout), [`manage.py`](https://github.com/adroit-abhik/adroit-scheduler/blob/master/manage.py) (manage.py)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_project["Django project"]
  node_manage_py["manage.py<br/>launcher<br/>[manage.py]"]
  node_m1_settings["Settings<br/>config<br/>[settings.py]"]
  node_m1_urls["Project routes<br/>router<br/>[urls.py]"]
  node_m1_wsgi["WSGI<br/>entrypoint<br/>[wsgi.py]"]
end

subgraph group_group_app["Main app"]
  node_mm1_apps["App config<br/>django app<br/>[apps.py]"]
  node_mm1_urls["App routes<br/>router<br/>[urls.py]"]
  node_mm1_views["Scheduler<br/>view layer<br/>[views.py]"]
  node_mm1_forms["Forms<br/>validation<br/>[forms.py]"]
  node_mm1_models[("Domain models<br/>orm models<br/>[models.py]")]
  node_mm1_admin["Admin<br/>[admin.py]"]
  node_mm1_migrations["Migrations<br/>schema evolution<br/>[0001_initial.py]"]
end

subgraph group_group_ui["Presentation"]
  node_base_tpl["Base layout<br/>template<br/>[base.html]"]
  node_crud_templates["CRUD pages<br/>templates<br/>[addep.html]"]
  node_timetable_tpl["Timetable pages<br/>templates<br/>[timetable.html]"]
  node_index_tpl["Home page<br/>template<br/>[index.html]"]
  node_style_css["Styles<br/>css<br/>[style.css]"]
end

subgraph group_group_data["Storage"]
  node_db_sqlite[("SQLite DB<br/>database<br/>[db.sqlite3]")]
end

node_manage_py -->|"starts"| node_m1_wsgi
node_manage_py -->|"loads"| node_m1_settings
node_m1_urls -->|"includes"| node_mm1_urls
node_m1_wsgi -->|"configures"| node_m1_settings
node_mm1_urls -->|"dispatches"| node_mm1_views
node_mm1_views -->|"validates"| node_mm1_forms
node_mm1_views -->|"reads/writes"| node_mm1_models
node_mm1_views -->|"renders"| node_timetable_tpl
node_mm1_views -->|"renders"| node_crud_templates
node_crud_templates -->|"extends"| node_base_tpl
node_timetable_tpl -->|"extends"| node_base_tpl
node_index_tpl -->|"extends"| node_base_tpl
node_base_tpl -->|"styles"| node_style_css
node_mm1_admin -->|"registers"| node_mm1_models
node_mm1_models -->|"persists to"| node_db_sqlite
node_mm1_migrations -->|"evolves"| node_mm1_models
node_mm1_migrations -->|"applies to"| node_db_sqlite
node_mm1_apps -->|"contains"| node_mm1_models

click node_manage_py "https://github.com/adroit-abhik/adroit-scheduler/blob/master/manage.py"
click node_m1_settings "https://github.com/adroit-abhik/adroit-scheduler/blob/master/M1/settings.py"
click node_m1_urls "https://github.com/adroit-abhik/adroit-scheduler/blob/master/M1/urls.py"
click node_m1_wsgi "https://github.com/adroit-abhik/adroit-scheduler/blob/master/M1/wsgi.py"
click node_mm1_apps "https://github.com/adroit-abhik/adroit-scheduler/blob/master/mm1/apps.py"
click node_mm1_urls "https://github.com/adroit-abhik/adroit-scheduler/blob/master/mm1/urls.py"
click node_mm1_views "https://github.com/adroit-abhik/adroit-scheduler/blob/master/mm1/views.py"
click node_mm1_forms "https://github.com/adroit-abhik/adroit-scheduler/blob/master/mm1/forms.py"
click node_mm1_models "https://github.com/adroit-abhik/adroit-scheduler/blob/master/mm1/models.py"
click node_mm1_admin "https://github.com/adroit-abhik/adroit-scheduler/blob/master/mm1/admin.py"
click node_mm1_migrations "https://github.com/adroit-abhik/adroit-scheduler/blob/master/mm1/migrations/0001_initial.py"
click node_db_sqlite "https://github.com/adroit-abhik/adroit-scheduler/blob/master/db.sqlite3"
click node_base_tpl "https://github.com/adroit-abhik/adroit-scheduler/blob/master/templates/base.html"
click node_crud_templates "https://github.com/adroit-abhik/adroit-scheduler/blob/master/templates/addep.html"
click node_timetable_tpl "https://github.com/adroit-abhik/adroit-scheduler/blob/master/templates/timetable.html"
click node_index_tpl "https://github.com/adroit-abhik/adroit-scheduler/blob/master/templates/index.html"
click node_style_css "https://github.com/adroit-abhik/adroit-scheduler/blob/master/static/CSS/style.css"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_manage_py,node_m1_settings,node_m1_urls,node_m1_wsgi toneBlue
class node_mm1_apps,node_mm1_urls,node_mm1_views,node_mm1_forms,node_mm1_models,node_mm1_admin,node_mm1_migrations toneAmber
class node_base_tpl,node_crud_templates,node_timetable_tpl,node_index_tpl,node_style_css toneMint
class node_db_sqlite toneRose
```

## Components

### Django project

Project configuration and entrypoints

- [manage.py](https://github.com/adroit-abhik/adroit-scheduler/blob/master/manage.py): launcher · Django command entrypoint · `manage.py`
- [Settings](https://github.com/adroit-abhik/adroit-scheduler/blob/master/M1/settings.py): config · Project settings and Django configuration · `M1/settings.py`
- [Project routes](https://github.com/adroit-abhik/adroit-scheduler/blob/master/M1/urls.py): router · Root URL routing for the site · `M1/urls.py`
- [WSGI](https://github.com/adroit-abhik/adroit-scheduler/blob/master/M1/wsgi.py): entrypoint · Deployment entrypoint · `M1/wsgi.py`

### Main app

Domain logic, persistence, and request handling

- [App config](https://github.com/adroit-abhik/adroit-scheduler/blob/master/mm1/apps.py): django app · Application registration · `mm1/apps.py`
- [App routes](https://github.com/adroit-abhik/adroit-scheduler/blob/master/mm1/urls.py): router · Application URL patterns · `mm1/urls.py`
- [Scheduler](https://github.com/adroit-abhik/adroit-scheduler/blob/master/mm1/views.py): view layer · CRUD handlers and timetable generation flow · `mm1/views.py`
- [Forms](https://github.com/adroit-abhik/adroit-scheduler/blob/master/mm1/forms.py): validation · Structured input and validation for entity screens · `mm1/forms.py`
- [Domain models](https://github.com/adroit-abhik/adroit-scheduler/blob/master/mm1/models.py): orm models · Departments, courses, instructors, rooms, sections, and timetable data · `mm1/models.py`
- [Admin](https://github.com/adroit-abhik/adroit-scheduler/blob/master/mm1/admin.py): django admin · Model registration for Django admin · `mm1/admin.py`
- [Migrations](https://github.com/adroit-abhik/adroit-scheduler/blob/master/mm1/migrations/0001_initial.py): schema evolution · Managed database schema history · `mm1/migrations/0001_initial.py`

### Presentation

Templates and static assets

- [Base layout](https://github.com/adroit-abhik/adroit-scheduler/blob/master/templates/base.html): template · Shared page shell · `templates/base.html`
- [CRUD pages](https://github.com/adroit-abhik/adroit-scheduler/blob/master/templates/addep.html): templates · Department, course, instructor, room, and section forms/lists · `templates/addep.html`
- [Timetable pages](https://github.com/adroit-abhik/adroit-scheduler/blob/master/templates/timetable.html): templates · Rendered schedule output · `templates/timetable.html`
- [Home page](https://github.com/adroit-abhik/adroit-scheduler/blob/master/templates/index.html): template · Landing page · `templates/index.html`
- [Styles](https://github.com/adroit-abhik/adroit-scheduler/blob/master/static/CSS/style.css): css · Project styling · `static/CSS/style.css`

### Storage

Local SQLite database and schema evolution

- [SQLite DB](https://github.com/adroit-abhik/adroit-scheduler/blob/master/db.sqlite3): database · Local file-backed persistence · `db.sqlite3`

## Connections

- manage.py → WSGI: starts · Launches the Django application
- manage.py → Settings: loads · Uses project settings
- Project routes → App routes: includes · Routes requests into the app
- WSGI → Settings: configures · Reads Django configuration
- App routes → Scheduler: dispatches · Maps requests to handlers
- Scheduler → Forms: validates · Processes entity input through forms
- Scheduler → Domain models: reads/writes · Loads scheduling resources and saved timetable data
- Scheduler → Timetable pages: renders · Produces timetable output pages
- Scheduler → CRUD pages: renders · Serves create/list workflows
- CRUD pages → Base layout: extends · Shares the common layout
- Timetable pages → Base layout: extends · Uses the shared layout shell
- Home page → Base layout: extends · Uses the shared layout shell
- Base layout → Styles: styles · Applies site styling
- Admin → Domain models: registers · Exposes domain entities to admin
- Domain models → SQLite DB: persists to · Stores scheduler state in SQLite
- Migrations → Domain models: evolves · Tracks schema changes for the domain model
- Migrations → SQLite DB: applies to · Materializes schema in the database
- App config → Domain models: contains · App boundary for the main domain package
