# def-try/aiobus architecture

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

- Interactive diagram: https://gitdiagram.com/def-try/aiobus
- Repository: https://github.com/def-try/aiobus

## Overview

##### Main Components

a) Discord Interface Layer
- Discord API gateway connection
- Bot's client interface
- Permission requirements (referenced in invite link)

b) Core Bot Structure
- Main entry point (main.py)
- Utilities module (utilities.py)
- Configuration system (config directory)

c) Modular Cog System
- Cogs into functional groups:
- Core Functions (basic.py)
- Communication (interchat.py, adminhelp.py)
- Entertainment (fun/, actions_commands.py)
- Moderation Tools (starboard.py)
- AI Integration (ai.py)
- Media Handling (media.py)
- Utility Functions (util.py)

d) Localization System
- Multi-language support structure
- Both en-US and ru localization paths
- JSON-based string management

##### Relationship Flows

- Discord API ↔️ Main Bot Process
- Main Process ↔️ Cog Modules
- Cogs ↔️ Localization System
- User Commands ↔️ Appropriate Cogs
- Inter-cog Communications (especially for features like interchat)

##### Specific Features

- GPT integration for AI responses
- Interchat system for cross-channel communication
- Starboard functionality
- Media processing capabilities
- Administrative help system

##### Technical Details to Note

- Python-based architecture
- Discord.py framework usage
- Configuration management
- Error handling flow
- GitHub workflow integration

##### Support Systems (Localization, Configuration)

This architecture should reflect the bot's current state while allowing for the planned additions mentioned in the TODO section, such as the moderation cog and starboard updates.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Discord
        DG[Discord Gateway]
        DC[Discord Client]
    end

    subgraph "Bot Interface"
        MI["Main Interface"]:::core
        CF["Config System"]:::core
        UT["Core Utilities"]:::core
    end

    subgraph "Cog Management"
        CL["Cog Loader"]:::core
    end

    subgraph "Core Cogs"
        BC["Basic Commands"]:::core
        CM["Config Manager"]:::core
    end

    subgraph "Communication Cogs"
        IC["Interchat System"]:::communication
        AH["Admin Help"]:::communication
    end

    subgraph "Entertainment"
        FM["Fun Module"]:::entertainment
        AC["Action Commands"]:::entertainment
    end

    subgraph "Moderation"
        SB["Starboard"]:::moderation
    end

    subgraph "Special Features"
        AI["AI Integration"]:::ai
        MH["Media Handler"]:::media
        UF["Utility Functions"]:::utility
    end

    subgraph "Localization"
        LS["String Manager"]:::support
        EN["English (en-US)"]:::support
        RU["Russian (ru)"]:::support
    end

    subgraph "CI/CD"
        WF["Workflows"]:::cicd
        PL["Pylint"]:::cicd
        RF["Reformat"]:::cicd
    end

    DG <--> DC
    DC <--> MI
    MI --> CF
    MI --> UT
    MI --> CL

    CL --> BC
    CL --> CM
    CL --> IC
    CL --> AH
    CL --> FM
    CL --> AC
    CL --> SB
    CL --> AI
    CL --> MH
    CL --> UF

    BC --> LS
    CM --> LS
    IC --> LS
    AH --> LS
    FM --> LS
    AC --> LS
    SB --> LS
    AI --> LS
    MH --> LS
    UF --> LS

    LS --> EN
    LS --> RU

    WF --> PL
    WF --> RF

    %% Click Events
    click MI "https://github.com/Def-Try/aiobus/blob/main/main.py"
    click UT "https://github.com/Def-Try/aiobus/blob/main/utilities.py"
    click CF "https://github.com/Def-Try/aiobus/blob/main/config/__init__.py"
    click BC "https://github.com/Def-Try/aiobus/blob/main/cogs/basic.py"
    click CM "https://github.com/Def-Try/aiobus/blob/main/cogs/configurator.py"
    click IC "https://github.com/Def-Try/aiobus/blob/main/cogs/interchat.py"
    click AH "https://github.com/Def-Try/aiobus/blob/main/cogs/adminhelp.py"
    click FM "https://github.com/Def-Try/aiobus/blob/main/cogs/fun/__init__.py"
    click AC "https://github.com/Def-Try/aiobus/blob/main/cogs/actions_commands.py"
    click SB "https://github.com/Def-Try/aiobus/blob/main/cogs/starboard.py"
    click AI "https://github.com/Def-Try/aiobus/blob/main/cogs/ai.py"
    click MH "https://github.com/Def-Try/aiobus/blob/main/cogs/media.py"
    click UF "https://github.com/Def-Try/aiobus/blob/main/cogs/util.py"
    click EN "https://github.com/Def-Try/aiobus/tree/main/localisation/en-US"
    click RU "https://github.com/Def-Try/aiobus/tree/main/localisation/ru"
    click WF "https://github.com/Def-Try/aiobus/tree/main/.github/workflows"
    click PL "https://github.com/Def-Try/aiobus/blob/main/.github/workflows/pylint.yml"
    click RF "https://github.com/Def-Try/aiobus/blob/main/.github/workflows/reformat.yml"

    %% Styling
    classDef core fill:#3498db
    classDef communication fill:#2ecc71
    classDef entertainment fill:#f1c40f
    classDef moderation fill:#e74c3c
    classDef ai fill:#9b59b6
    classDef media fill:#e67e22
    classDef utility fill:#95a5a6
    classDef support fill:#7f8c8d
    classDef cicd fill:#34495e
```
