# f-wllr/discordbot architecture

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

- Interactive diagram: https://gitdiagram.com/f-wllr/discordbot
- Repository: https://github.com/f-wllr/discordbot

## Overview

##### Project type and purpose
- This is a single‐module Java application implementing a Discord bot.
- It uses the JDA (Java Discord API) library to connect to Discord, listen to events, and execute commands such as a “helloWorld” command.

##### File structure
- pom.xml: Maven build config; pulls in JDA and any other dependencies.
- src/main/java/com/fwllr/discordBot/Main.java: Bootstraps the bot, loads token, activity, and channel IDs, and starts the JDA instance.
- botListeners.java: Implements JDA’s event listener interfaces for handling onMessage, onGuildMemberJoin, etc.
- commands/helloWorld.java: Illustrates the Command‐pattern submodule for individual bot commands.

##### README for additional insights
- Configuration is hard-coded in Main.java (botToken, activity, logChannelID, welcomeChannelID).
- No database or external persistence—state is minimal and in-memory.
- Deployment is via a self‐contained Java 17 JAR.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External actors and services
    subgraph "External Actors/Services"
        U["Discord Users"]:::external
        S["Discord Servers"]:::external
        API_WS["Discord API WebSocket"]:::external
        API_REST["Discord API REST"]:::external
    end

    %% Bot application components
    subgraph "Bot Application"
        RootSrc["Root Source Package"]:::core
        Config["Configuration Store"]:::config
        Main["Main Module\n(initializes JDA)"]:::core
        Listeners["Event Dispatcher\n/ Listener Layer"]:::core
        subgraph "Commands\n(Command Handlers)"
            Commands["commands package"]:::core
            Hello["helloWorld Command"]:::core
        end
    end

    %% Build and deployment
    subgraph "Build & Deployment"
        Maven["Maven\n(pom.xml)"]:::config
        JAR["Shaded JAR"]:::core
        Runtime["Java 17 Runtime"]:::core
        Docs["Project Documentation\n(readme.md)"]:::config
    end

    %% Data flow
    U -->|"send MESSAGE_CREATE"| API_WS
    S -->|"GUILD_MEMBER_JOIN"| API_WS
    API_WS -->|"onEvent()"| Main
    Main -->|"register botListeners"| Listeners
    Listeners -->|"dispatch to"| Hello
    Commands --> Hello
    Hello -->|"sendMessage()"| API_REST
    API_REST -->|"message delivered"| U
    Config --> Main

    %% Build flow
    Maven --> JAR --> Runtime
    Runtime --> Main
    Docs -.-> Main

    %% Package hierarchy
    RootSrc --> Main
    RootSrc --> Listeners
    RootSrc --> Commands

    %% Click events
    click Main "https://github.com/f-wllr/discordbot/blob/master/src/main/java/com/fwllr/discordBot/Main.java"
    click Listeners "https://github.com/f-wllr/discordbot/blob/master/src/main/java/com/fwllr/discordBot/botListeners.java"
    click Commands "https://github.com/f-wllr/discordbot/tree/master/src/main/java/com/fwllr/discordBot/commands/"
    click Hello "https://github.com/f-wllr/discordbot/blob/master/src/main/java/com/fwllr/discordBot/commands/helloWorld.java"
    click Maven "https://github.com/f-wllr/discordbot/blob/master/pom.xml"
    click Docs "https://github.com/f-wllr/discordbot/blob/master/readme.md"
    click RootSrc "https://github.com/f-wllr/discordbot/tree/master/src/main/java/com/fwllr/discordBot"

    %% Styles
    classDef external fill:#bbdefb,stroke:#0d47a1,color:#0d47a1;
    classDef core fill:#c8e6c9,stroke:#2e7d32,color:#2e7d32;
    classDef config fill:#fff9c4,stroke:#f57f17,color:#f57f17;
```
