# frovahappy/beatriz-dono architecture

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

- Interactive diagram: https://gitdiagram.com/frovahappy/beatriz-dono
- Repository: https://github.com/frovahappy/beatriz-dono

## Overview

##### Project Type and Purpose
- The README clearly states that this is a multipurpose Discord bot. The project is a monorepo with multiple packages, including a core “bot” package (the heart of the Discord integration), shared “libs” (which include canvas drawing utilities and other helper functions), and two website components (a legacy dashboard and a newer website interface).
- The project also supports Docker-based deployment and local development using environment variables.

##### File Structure
- The repository is organized as a monorepo with top-level directories such as:
– packages/libs: A set of shared libraries that include functionalities (like a PaintCanvas module) used by the bot and possibly the websites.
– packages/website-legacy and packages/website: Web components for dashboards or public pages. They include Next.js/React elements and Astro components.
- Build, configuration, and Docker files are at the project root (e.g., Dockerfile, docker-compose.yml, tsconfig.json), suggesting clear separation of deployment concerns.

a. Main Components:
- Discord Bot Service – Represented by the “bot” package. This component contains API endpoints (controllers in the /src/api folder), command/event builders (in /src/core/build), and database communication (in /src/database).
- Web Dashboard / Interfaces – Comprising the “website” and “website-legacy” packages, these provide the frontend interfaces for user interaction and bot configuration.
- External Services – These include Discord (with its API and gateway) and third-party services like Imgur for image hosting. Also mention integration with session management (using secret keys) and potential API gateways.

b. Relationships and Interactions:
- Flow from Discord (external) to the Bot Service: interactions like slash commands, button clicks, and menu actions are captured in the /core/build and /events modules.
- The Bot interacts with the database through the /database folder for storing and retrieving settings, guild info, and other persistent data.
- The Bot uses shared libraries from the libs package for handling tasks (like generating welcome images via PaintCanvas).
- The Web Dashboard components (website and website-legacy) communicate with the Bot’s API endpoints (found under /src/api) to display and change settings.
- Docker layer (Dockerfile, docker-compose files) which containerizes the application for deployment.

c. Architectural Patterns and Design Principles:
- Modular / Monorepo Architecture: Each package (bot, libs, website) is largely self-contained but interfaces with one another.
- Separation of Concerns: Notice how the API layer (controllers and routes) is distinct from core functionalities (command/event builders) and from shared utilities.
- Incorporation of external services (Discord, Imgur) reinforces interfacing via defined API contracts and environment configuration.

d. Technologies and Frameworks:
- Node.js and TypeScript are used throughout, with specific mentions of discord.js (for the Discord integrations) and slack-like components (builders).
- Docker is used for containerization.
- The website components utilize frameworks like Next.js (as seen in website-legacy) and Astro (in website).
- Some testing frameworks are indicated (e.g., Vitest) and Turbo (turbo.json) is used for task running within the monorepo.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Services
    Discord["Discord API"]:::external
    Imgur["Imgur API"]:::external

    %% Deployment Container (Docker)
    Docker["Docker Deployment"]:::docker

    %% Discord Bot Service Package
    subgraph "Discord Bot Service"
        Bot["Bot Service (packages/bot)"]:::service
        API["API Controllers (packages/bot/src/api/controllers)"]:::service
        Builders["Command/Event Builders (packages/bot/src/core/build)"]:::service
        DB["Database Interaction Layer (packages/bot/src/database)"]:::database
    end

    %% Shared Libraries Package
    subgraph "Shared Libraries"
        Libs["Shared Libraries (packages/libs)"]:::lib
    end

    %% Web Interfaces
    subgraph "Web Interfaces"
        Legacy["Web Dashboard / Legacy Interface (packages/website-legacy)"]:::web
        NewWeb["New Website Interface (packages/website)"]:::web
    end

    %% Relationships and Data Flow
    Discord -->|"commands/events"| Bot
    Bot -->|"API calls"| Discord
    Bot -->|"Utilizes"| Builders
    Bot -->|"Handles"| API
    Bot -->|"CRUD"| DB
    Bot -->|"Uses"| Libs
    Bot -->|"ImageHosting"| Imgur

    Legacy -->|"configures"| API
    NewWeb -->|"configures"| API

    Docker -->|"deploys"| Bot
    Docker -->|"deploys"| API
    Docker -->|"deploys"| Builders
    Docker -->|"deploys"| DB
    Docker -->|"deploys"| Libs
    Docker -->|"deploys"| Legacy
    Docker -->|"deploys"| NewWeb

    %% Click Events for Component Mapping
    click Bot "https://github.com/frovahappy/beatriz-dono/tree/main/packages/bot"
    click API "https://github.com/frovahappy/beatriz-dono/tree/main/packages/bot/src/api/controllers"
    click Builders "https://github.com/frovahappy/beatriz-dono/tree/main/packages/bot/src/core/build"
    click DB "https://github.com/frovahappy/beatriz-dono/tree/main/packages/bot/src/database"
    click Libs "https://github.com/frovahappy/beatriz-dono/tree/main/packages/libs"
    click Legacy "https://github.com/frovahappy/beatriz-dono/tree/main/packages/website-legacy"
    click NewWeb "https://github.com/frovahappy/beatriz-dono/tree/main/packages/website"
    click Docker "https://github.com/frovahappy/beatriz-dono/tree/main/Dockerfile"

    %% Styles
    classDef external fill:#cfc,stroke:#0a0,stroke-width:2px;
    classDef docker fill:#fc9,stroke:#f60,stroke-width:2px;
    classDef service fill:#bbf,stroke:#00f,stroke-width:2px;
    classDef database fill:#ffe,stroke:#aa0,stroke-width:2px;
    classDef lib fill:#9cf,stroke:#06c,stroke-width:2px;
    classDef web fill:#fdb,stroke:#d66,stroke-width:2px;
```
