# atomic09/yuukadiscordbot architecture

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

- Interactive diagram: https://gitdiagram.com/atomic09/yuukadiscordbot
- Repository: https://github.com/atomic09/yuukadiscordbot

## Overview

##### Project type and purpose
- This is a Python-based Discord bot (YuukaDiscordBot) that offers a rich set of slash and context commands to interact with users on Discord.
- Its purpose is to manage voice‐channel activities (attendance, kicking, countdowns), fetch and process media (memes, YouTube info, image searches), integrate AI chat, TTS, and other utilities.

##### File structure
- Top-level files:
- main.py – bootstraps the bot, loads configuration and cogs
- requirements.txt / runtime.txt – dependency and runtime declarations
- Dockerfile / Procfile – containerization and Heroku deployment directives
- .github/workflows/docker-image.yml – CI/CD pipeline for building/pushing Docker images
- cogs/ – each Python file is a “cog,” i.e., a plugin encapsulating a command or related set of commands
- utils/ – shared helper modules (e.g., chatgpt.py, img_processing.py, ytdlp.py) and a subfolder for a voice-conversion model (rvc)
- Configuration files (.gitignore, LICENSE, CONTRIBUTING.md, etc.)

##### README for additional insights
- Lists all slash commands and context commands
- Specifies required permissions (Administrator)
- Mentions instability of the new audio features (v2.1)

##### Components and their interactions
a. Main components
- Discord Gateway (Discord API)
- Bot Core (main.py)
- Cog Modules (cogs/)
- Utility Libraries (utils/)
- External Services:
– OpenAI / ChatGPT API
– YouTube Data API
– Reddit API (for memes)
– Text‐to‐Speech / RVC model
– QR‐code, image‐processing services
b. Relationships / data flow
- The Bot Core connects to the Discord Gateway via a WebSocket
- Incoming events/commands are routed by the bot framework to the appropriate Cog
- Cogs make calls to utils modules to perform tasks (e.g., fetch meme, generate TTS)
- Utils contact external APIs or local ML models (rvc) and return results to the cogs
- Cogs send responses back to Discord via the Gateway
c. Architectural patterns
- Plugin architecture (each cog is a self‐contained command module)
- Layered separation:
– Entry point (main.py)
– Command handlers (cogs/)
– Business logic & external integrations (utils/)
- Containerized deployment (Docker), CI/CD integration via GitHub Actions
d. Key technologies
- discord.py or a similar Discord library
- Python 3.x, Docker, Heroku
- External SDKs / APIs: OpenAI, YouTube Data API, Reddit
- ML model file (utils/rvc/Hayase-Yuuka.pth) for voice conversion

- Below it, group the “Cogs” blocks in a row or grid, each labeled by feature (attendance, ai, youtube, meme, etc.)
- “chatgpt.py”
- “video_processing.py / ytdlp.py”
- “img_processing.py / deepfryer”
- “rvc model / speech_synthesis.py”
- Discord API (bi-directional)
- OpenAI
- YouTube Data API
- Reddit API
- Any auxiliary services (QR-code, TTS engines)
- Blue rectangles = Internal code components
- Orange boundary = Deployment container

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Container Boundary
    subgraph "Docker Container / Heroku Dyno"
        direction TB
        BotCore["Bot Core\n(main.py)"]:::internal
        subgraph "Cogs (Commands)"
            direction TB
            Attendance["attendance.py"]:::internal
            Absent["absent.py"]:::internal
            Announce["announce.py"]:::internal
            CountDis["countdis.py"]:::internal
            Kick["kick.py"]:::internal
            MemeCog["meme.py"]:::internal
            YouTubeCog["youtube.py"]:::internal
            AICog["ai.py"]:::internal
            TTSCog["tts.py"]:::internal
            GetChat["getchat.py"]:::internal
            DeepFry["deepfry.py"]:::internal
            QRCode["qrcode.py"]:::internal
            ImageInfo["imageinfo.py"]:::internal
        end
        subgraph "Utils (Helpers & ML Models)"
            direction TB
            ChatGPTUtil["chatgpt.py"]:::internal
            YTDLP["ytdlp.py"]:::internal
            VideoProc["video_processing.py"]:::internal
            GetMemeUtil["get_meme.py"]:::internal
            ImgProc["img_processing.py"]:::internal
            DeepFryerUtil["deepfryer.py"]:::internal
            TTSynth["speech_synthesis.py"]:::internal
            TTSCheck["tts_language_check.py"]:::internal
            CountdownUtil["countdown.py"]:::internal
            subgraph "RVC Model"
                direction TB
                RVCModel["Hayase-Yuuka.pth"]:::internal
                RVCGen["gen_rvc_audio.py"]:::internal
            end
        end
        DockerfileNode["Dockerfile"]:::internal
        ProcfileNode["Procfile"]:::internal
        CI[".github/workflows/docker-image.yml"]:::internal
        Requirements["requirements.txt"]:::internal
        Runtime["runtime.txt"]:::internal
    end

    %% External Services
    DiscordAPI["Discord API / Gateway"]:::external
    OpenAI["OpenAI / ChatGPT API"]:::external
    YouTubeAPI["YouTube Data API"]:::external
    RedditAPI["Reddit API"]:::external
    QRService["QR-code Service"]:::external
    TTSService["TTS Engine"]:::external

    %% Connections
    DiscordAPI -->|"WebSocket events"| BotCore
    BotCore -->|"routes slash/context"| Attendance
    BotCore --> Absent
    BotCore --> Announce
    BotCore --> CountDis
    BotCore --> Kick
    BotCore --> MemeCog
    BotCore --> YouTubeCog
    BotCore --> AICog
    BotCore --> TTSCog
    BotCore --> GetChat
    BotCore --> DeepFry
    BotCore --> QRCode
    BotCore --> ImageInfo

    Attendance -->|"calls util"| CountdownUtil
    CountDis --> CountdownUtil
    AICog --> ChatGPTUtil
    YouTubeCog --> YTDLP
    YouTubeCog --> VideoProc
    MemeCog --> GetMemeUtil
    DeepFry --> ImgProc
    DeepFry --> DeepFryerUtil
    TTSCog --> TTSCheck
    TTSCog --> TTSynth
    RVCGen --> RVCModel

    ChatGPTUtil -->|HTTP REST call| OpenAI
    YTDLP -->|HTTP REST call| YouTubeAPI
    GetMemeUtil -->|HTTP REST call| RedditAPI
    QRCode -->|HTTP REST call| QRService
    TTSynth -->|ML inference| RVCGen
    TTSynth -->|HTTP REST call| TTSService

    OpenAI -->|response| AICog
    YouTubeAPI -->|response| YouTubeCog
    RedditAPI -->|response| MemeCog
    QRService -->|response| QRCode
    TTSService -->|response| TTSCog
    RVCGen -->|audio data| TTSCog

    BotCore -->|"responses"| DiscordAPI

    %% Click Events
    click BotCore "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/main.py"
    click Attendance "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/cogs/attendance.py"
    click Absent "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/cogs/absent.py"
    click Announce "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/cogs/announce.py"
    click CountDis "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/cogs/countdis.py"
    click Kick "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/cogs/kick.py"
    click MemeCog "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/cogs/meme.py"
    click YouTubeCog "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/cogs/youtube.py"
    click AICog "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/cogs/ai.py"
    click TTSCog "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/cogs/tts.py"
    click GetChat "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/cogs/getchat.py"
    click DeepFry "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/cogs/deepfry.py"
    click QRCode "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/cogs/qrcode.py"
    click ImageInfo "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/cogs/imageinfo.py"
    click ChatGPTUtil "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/utils/chatgpt.py"
    click YTDLP "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/utils/ytdlp.py"
    click VideoProc "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/utils/video_processing.py"
    click GetMemeUtil "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/utils/get_meme.py"
    click ImgProc "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/utils/img_processing.py"
    click DeepFryerUtil "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/utils/deepfryer.py"
    click TTSynth "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/utils/speech_synthesis.py"
    click TTSCheck "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/utils/tts_language_check.py"
    click CountdownUtil "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/utils/countdown.py"
    click RVCModel "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/utils/rvc/Hayase-Yuuka.pth"
    click RVCGen "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/utils/rvc/gen_rvc_audio.py"
    click DockerfileNode "https://github.com/atomic09/yuukadiscordbot/tree/yuuka-v2/Dockerfile"
    click ProcfileNode "https://github.com/atomic09/yuukadiscordbot/tree/yuuka-v2/Procfile"
    click CI "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/.github/workflows/docker-image.yml"
    click Requirements "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/requirements.txt"
    click Runtime "https://github.com/atomic09/yuukadiscordbot/blob/yuuka-v2/runtime.txt"

    %% Styles
    classDef internal fill:#AED6F1,stroke:#21618C,stroke-width:1px
    classDef external fill:#A9DFBF,stroke:#1D8348,stroke-width:1px
    classDef boundary stroke:#E67E22,stroke-width:2px,stroke-dasharray: 5 5
```
