# jojofr1/joseta architecture

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

- Interactive diagram: https://gitdiagram.com/jojofr1/joseta
- Repository: https://github.com/jojofr1/joseta

## Overview

##### Main Components
- Bot Core: The entry point is the JosetaBot class, which initializes the bot, sets up essential services, and connects with Discord via JDA.
- Command Handling: Located under src/joseta/commands, various subdirectories handle different types of commands. For example:
- Admin commands (admin folder)
- Moderation commands (moderation folder)
- Miscellaneous commands (misc folder)
The Command and CommandExecutor abstraction represents how commands are defined and executed.
- Event Listeners: Found under src/joseta/events, these classes (like AutoResponse, WelcomeMessage, RulesAcceptEvent, etc.) act as event listeners triggered by Discord events.
- Configuration and Environment: The secret_template.cfg and possibly classes like Vars.java (and Settings in utils) contain configuration details that dictate how the bot behaves (e.g., API keys and hardcoded values).
- Logging & Build System: Including logback.xml and the gradle setup files, these are used to manage log formatting and project builds (Gradle with the shadowJar task).

##### Relationships
- The Bot Core (JosetaBot) initializes the JDA instance and registers both the command handlers and event listeners.
- Configuration Data flows: Show how configuration from secret_template.cfg and Settings/Vars classes is loaded at startup and influences command behavior and event handling.
- Dependencies: Mark the dependency on external libraries such as JDA and logback.

##### Architectural Patterns and Design Principles
- Modular Organization: The separation between commands and events shows a modular design, which is beneficial for maintainability.
- Separation of Concerns: A clear division between the core bot functionality (initializing the bot and connecting to Discord), command processing (parsing and executing user commands), and event handling.
- Extensibility: Although the project currently focuses on a single server and hardcoded behaviors, the design uses abstraction (e.g., Command interface and CommandExecutor) that would allow extension to multi-server support or easier configuration changes in the future.
- Build & Deployment: Make note of the use of Gradle for build automation, depicted as a separate component that generates the final JosetaBot.jar for deployment.

- Use clear labels for each component:
- “Bot Core (JosetaBot)” for the main application.
- “Event Listener Module” for handling different Discord events.
- “Configuration/Environment” representing secret_template.cfg and related settings.
- “Logging & Build System” to indicate integrations with logback and Gradle.
- Data flow from Discord (via JDA) into the Command and Event processing units.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "External Services"
        A["Discord API"]:::external
        G["JDA Library"]:::external
    end

    subgraph "Runtime Components"
        B["Bot Core (JosetaBot)"]:::runtime
        C["Command Handler Module"]:::runtime
        D["Event Listener Module"]:::runtime
        A -->|"sendsEvents"| B
        B -->|"registers"| C
        B -->|"registers"| D
        B -->|"initializes"| G
    end

    subgraph "Command Modules"
        C1["Admin Commands"]:::runtime
        C2["Moderation Commands"]:::runtime
        C3["Miscellaneous Commands"]:::runtime
        C -->|"contains"| C1
        C -->|"contains"| C2
        C -->|"contains"| C3
    end

    subgraph "Supporting Components"
        E["Configuration/Environment"]:::support
        F["Build & Logging System"]:::support
        E1["Configuration File"]:::support
        E2a["Vars"]:::support
        E2b["Settings"]:::support
        F1["Gradle Build"]:::support
        F2["Logging System"]:::support
        E -->|"loads"| B
        E -->|"includes"| E1
        E -->|"includes"| E2a
        E -->|"includes"| E2b
        F1 -->|"builds"| B
        F2 -->|"configures"| B
        F -->|"contains"| F1
        F -->|"contains"| F2
    end

    click B "https://github.com/jojofr1/joseta/blob/main/src/joseta/JosetaBot.java"
    click C "https://github.com/jojofr1/joseta/tree/main/src/joseta/commands"
    click C1 "https://github.com/jojofr1/joseta/blob/main/src/joseta/commands/admin/AdminCommand.java"
    click C2 "https://github.com/jojofr1/joseta/tree/main/src/joseta/commands/moderation"
    click C3 "https://github.com/jojofr1/joseta/tree/main/src/joseta/commands/misc"
    click D "https://github.com/jojofr1/joseta/tree/main/src/joseta/events"
    click E1 "https://github.com/jojofr1/joseta/blob/main/secret_template.cfg"
    click E2a "https://github.com/jojofr1/joseta/blob/main/src/joseta/Vars.java"
    click E2b "https://github.com/jojofr1/joseta/blob/main/src/joseta/utils/Settings.java"
    click F1 "https://github.com/jojofr1/joseta/blob/main/build.gradle"
    click F2 "https://github.com/jojofr1/joseta/blob/main/src/logback.xml"

    classDef runtime fill:#CCE5FF,stroke:#333,stroke-width:2px;
    classDef external fill:#DFFFE0,stroke:#333,stroke-width:2px;
    classDef support fill:#FFF0B3,stroke:#333,stroke-width:2px;
```
