# letusflow/rusty-bruhbot architecture

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

- Interactive diagram: https://gitdiagram.com/letusflow/rusty-bruhbot
- Repository: https://github.com/letusflow/rusty-bruhbot

## Overview

##### Project Type and Purpose
- This project is a Discord bot written in Rust with a focus on managing commands and playing sounds.
- The README makes clear that it leverages PocketBase (accessed via its REST API) to store command and sound data.
- External dependencies include audio libraries (Opus and Symphonia) used via the Songbird framework for audio functionality, and the bot is containerized with Docker.

##### File Structure
- The file tree lists typical elements of a Rust project (Cargo.toml, Cargo.lock). The source code is in the src folder with dedicated modules:
- main.rs: likely contains the application entry point and bootstrapping logic.
- command_manager.rs: probably responsible for managing bot commands.
- events.rs: likely handles Discord event subscriptions (e.g., message events, connection events).
- player.rs: focused on audio playback functionalities.
- The use of environment configuration (.env-file support in the README) signals externalized configuration of secrets like DISCORD_TOKEN and POCKETBASE_API.

##### Extract Additional Insights from the README
- The README clearly outlines the external integration with PocketBase. It even documents the PocketBase schema used for storing 'sounds' and their associated commands.
- Dependencies such as Opus and the Songbird library are referenced for audio functionality.
- Deployment steps in the README illustrate that the entire bot is run as a Docker container and communicates with PocketBase via REST API.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Docker Container"
        dockerfile["Dockerfile"]:::docker
        dockerignore[".dockerignore"]:::docker
        subgraph "Discord Bot Core"
            main["Main (main.rs)"]:::internal
            commandManager["Command Manager (command_manager.rs)"]:::internal
            eventsHandler["Events Handler (events.rs)"]:::internal
            player["Audio Processing (player.rs)"]:::internal
        end
    end

    discordApi["Discord API"]:::external
    pocketbase["PocketBase (REST API)"]:::external
    audioLibs["Audio Libraries (Songbird: Opus & Symphonia)"]:::external

    discordApi -->|"sendsEvents"| eventsHandler
    main -->|"bootstraps"| eventsHandler
    eventsHandler -->|"triggersCmd"| commandManager
    commandManager -->|"fetchesData"| pocketbase
    commandManager -->|"activatesAudio"| player
    player -->|"usesLibraries"| audioLibs

    click main "https://github.com/letusflow/rusty-bruhbot/blob/main/src/main.rs"
    click commandManager "https://github.com/letusflow/rusty-bruhbot/blob/main/src/command_manager.rs"
    click eventsHandler "https://github.com/letusflow/rusty-bruhbot/blob/main/src/events.rs"
    click player "https://github.com/letusflow/rusty-bruhbot/blob/main/src/player.rs"
    click dockerfile "https://github.com/letusflow/rusty-bruhbot/tree/main/Dockerfile"
    click dockerignore "https://github.com/letusflow/rusty-bruhbot/blob/main/.dockerignore"

    classDef internal fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef external fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef docker fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
```
