# g0oce/timetable_bot architecture

> Architecture diagram of the GitHub repository g0oce/timetable_bot, 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/g0oce/timetable_bot
- Repository: https://github.com/g0oce/timetable_bot

## Overview

##### Main Components
a. Entry Point & Core Application:
- main.py acts as the central launcher for the application.
b. Bot/Interface Component:
- bot.py likely manages the bot’s operations (handling user interactions, initiating tasks, etc.).
c. Data Management:
- JSON files like schedule.json, faculties.json, and faculty_ids.json store the data used by the bot.
d. HTML Processing:
- html_to_object.py and load_html.py are modules that likely handle parsing or converting HTML content into usable Python objects.
e. Output/Markup Handling:
- markup.py probably formats outgoing messages, helping to style or otherwise prepare responses.
f. Dependency & Environment Setup:
- requirements.txt (referenced in the README for creating a virtual environment) defines external libraries and dependencies.
g. Version Control/Configuration:
- .gitignore ensures that unnecessary or sensitive files are excluded from version control.

##### Relationships and Interactions
- main.py serves as the application entry point, initializing the required modules and components.
- The bot component (bot.py) receives input from end users and then calls on markup.py to format messages.
- When the bot needs to provide timetable details or related information, it accesses data stored in the JSON files.
- If HTML content needs to be integrated (for scraping or rendering purposes), main.py will leverage html_to_object.py and load_html.py to transform raw HTML into structured objects.
- All these operations rely on Python libraries as defined in requirements.txt, so ensuring an isolated Python virtual environment is critical.
- Data flows from the JSON files -> HTML processing modules as needed -> main logic in main.py -> messaging and presentation via bot.py and markup.py.

##### Important Architectural Design Patterns
- Modular Design: Each Python file represents a clear module addressing a distinct aspect of functionality (data access, HTML processing, bot operations, message formatting).
- Separation of Concerns: The system distinguishes between interface (bot.py, markup.py) and data processing (html_to_object.py, load_html.py, JSON files) and the application logic (main.py).
- Dependency Management & Environment Isolation: The README’s instructions for setting up a Python virtual environment emphasize organized dependency management.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Application Core
    subgraph "Application Core"
        MAIN["main.py"]:::module
        BOT["bot.py"]:::module
        MARKUP["markup.py"]:::module
    end

    %% Data Storage
    subgraph "Data Storage"
        SCHEDULE["schedule.json"]:::data
        FACULTIES["faculties.json"]:::data
        FACULTY_IDS["faculty_ids.json"]:::data
    end

    %% HTML Processing
    subgraph "HTML Processing"
        HTMLOBJ["html_to_object.py"]:::module
        LOADHTML["load_html.py"]:::module
    end

    %% Environment & Version Control
    ENV["requirements.txt"]:::env
    GIT[".gitignore"]:::config

    %% Relationships
    MAIN -->|"initiates"| BOT
    MAIN -->|"retrieves_data"| SCHEDULE
    MAIN -->|"retrieves_data"| FACULTIES
    MAIN -->|"retrieves_data"| FACULTY_IDS
    MAIN -->|"parses_HTML"| HTMLOBJ
    MAIN -->|"parses_HTML"| LOADHTML
    BOT -->|"formats_message"| MARKUP
    ENV -->|"supports"| MAIN
    ENV -->|"supports"| BOT
    ENV -->|"supports"| MARKUP
    ENV -->|"supports"| HTMLOBJ
    ENV -->|"supports"| LOADHTML

    %% Click Events
    click MAIN "https://github.com/g0oce/timetable_bot/blob/master/main.py"
    click BOT "https://github.com/g0oce/timetable_bot/blob/master/bot.py"
    click MARKUP "https://github.com/g0oce/timetable_bot/blob/master/markup.py"
    click SCHEDULE "https://github.com/g0oce/timetable_bot/blob/master/schedule.json"
    click FACULTIES "https://github.com/g0oce/timetable_bot/blob/master/faculties.json"
    click FACULTY_IDS "https://github.com/g0oce/timetable_bot/blob/master/faculty_ids.json"
    click HTMLOBJ "https://github.com/g0oce/timetable_bot/blob/master/html_to_object.py"
    click LOADHTML "https://github.com/g0oce/timetable_bot/blob/master/load_html.py"
    click ENV "https://github.com/g0oce/timetable_bot/blob/master/requirements.txt"
    click GIT "https://github.com/g0oce/timetable_bot/blob/master/.gitignore"

    %% Styles
    classDef module fill:#f9f,stroke:#333,stroke-width:2px;
    classDef data fill:#cff,stroke:#333,stroke-width:2px;
    classDef env fill:#fcf,stroke:#333,stroke-width:2px;
    classDef config fill:#fea,stroke:#333,stroke-width:2px;
```
