# dankerow/blop architecture

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

- Interactive diagram: https://gitdiagram.com/dankerow/blop
- Repository: https://github.com/dankerow/blop

## Overview

##### Project type and purpose
- This is a Discord bot (“Blop”) built with Node.js and discord.js.
- It provides slash‐commands, image transformations (via an external RawGO API), internationalization (i18next), and persists data (Prisma + PostgreSQL).

##### File structure
- src/main.ts: entry point that initializes the bot client.
- src/structures: custom Client, Command, and Event classes implement the Discord.js command/event framework.
- src/commands: directory of grouped slash‑command modules (administration, general, images, miscellaneous).
- src/events: handlers for Discord events (ready, interactionCreate).
- src/services: shared services (I18n, central index).
- src/utils: utilities (configLoader, fetch error handler, uptime, image generation helper).
- prisma/schema.prisma: database schema.
- locales/*.json: translation files.
- config files: .env, config.example.ts, i18next configuration in services.

##### README for additional insights
- Uses Discord’s slash commands.
- Stores guild/user preferences (language, modules enabled) in PostgreSQL via Prisma.
- Offloads image manipulation to a self‑hosted RawGO API.
- Internationalization of command names, descriptions, and responses.

##### Essential details to capture
- Initialization flow (config → services → register commands → connect).
- Command processing pipeline (Event → Dispatcher → Business Logic → Response).
- Data flow to/from the database and RawGO API.
- Localization engine intercepting output.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Users and Services
    User["User"]:::external
    Discord["Discord Gateway & REST API"]:::external
    RawGO["RawGO API"]:::external
    DB["PostgreSQL Database"]:::db

    User -->|issues slash command| Discord
    Discord -->|emits interactionCreate| inter
    CommandBase -->|responds via REST| Discord
    CommandBase -->|reads/writes| DB
    genImg -->|HTTP| RawGO
    DB <-->|via Prisma Client| prisma

    subgraph "Bot (Node.js + discord.js)" 
        direction TB
        main["Entry Point: src/main.ts"]:::internal
        config["Config Loader Utility"]:::internal
        prisma["Prisma Client"]:::internal
        i18n["I18n Service"]:::internal
        structuresIndex["Structures Index"]:::internal
        Client["Custom Discord Client"]:::internal
        CommandBase["Command Base Class"]:::internal
        EventBase["Event Base Class"]:::internal

        subgraph "Commands"
            admin["Administration Commands"]:::internal
            general["General Commands"]:::internal
            images["Image Commands"]:::internal
            misc["Miscellaneous Commands"]:::internal
        end

        subgraph "Events"
            inter["interactionCreate Handler"]:::internal
            ready["ready Handler"]:::internal
        end

        subgraph "Services"
            servicesIndex["Services Index"]:::internal
        end

        subgraph "Utilities"
            genImg["generateImage.ts"]:::internal
            fetchErr["handleFetchError.ts"]:::internal
            uptime["getSystemUptime.ts"]:::internal
        end

        %% Initialization Flow
        main -->|loads| config
        config -->|initializes| prisma
        config -->|initializes| i18n
        main -->|registers structures| structuresIndex
        main -->|login| Client

        %% Structure Relations
        structuresIndex --> Client
        structuresIndex --> CommandBase
        structuresIndex --> EventBase

        %% Command/Event Flow
        inter -->|dispatches| EventBase
        EventBase -->|invokes| CommandBase
        CommandBase --> admin
        CommandBase --> general
        CommandBase --> images
        CommandBase --> misc

        %% Services and Utils
        CommandBase -->|uses| i18n
        images -->|uses| genImg
        genImg -->|uses| fetchErr
        CommandBase -->|monitors| uptime
        servicesIndex --> i18n
        servicesIndex --> config

    end

    %% Click Events
    click main "https://github.com/dankerow/blop/blob/main/src/main.ts"
    click Client "https://github.com/dankerow/blop/blob/main/src/structures/Client.ts"
    click CommandBase "https://github.com/dankerow/blop/blob/main/src/structures/Command.ts"
    click EventBase "https://github.com/dankerow/blop/blob/main/src/structures/Event.ts"
    click structuresIndex "https://github.com/dankerow/blop/blob/main/src/structures/index.ts"
    click admin "https://github.com/dankerow/blop/tree/main/src/commands/administration"
    click general "https://github.com/dankerow/blop/tree/main/src/commands/general"
    click images "https://github.com/dankerow/blop/tree/main/src/commands/images"
    click misc "https://github.com/dankerow/blop/tree/main/src/commands/miscellaneous"
    click inter "https://github.com/dankerow/blop/blob/main/src/events/interactionCreate.ts"
    click ready "https://github.com/dankerow/blop/blob/main/src/events/ready.ts"
    click i18n "https://github.com/dankerow/blop/blob/main/src/services/I18n.ts"
    click servicesIndex "https://github.com/dankerow/blop/blob/main/src/services/index.ts"
    click genImg "https://github.com/dankerow/blop/blob/main/src/utils/generateImage.ts"
    click config "https://github.com/dankerow/blop/blob/main/src/utils/configLoader.ts"
    click fetchErr "https://github.com/dankerow/blop/blob/main/src/utils/handleFetchError.ts"
    click uptime "https://github.com/dankerow/blop/blob/main/src/utils/getSystemUptime.ts"
    click DB "https://github.com/dankerow/blop/blob/main/prisma/schema.prisma"

    classDef internal fill:#D8B4FE,stroke:#7C3AED,color:#000
    classDef external fill:#DBEAFE,stroke:#3B82F6,color:#000
    classDef db fill:#BBF7D0,stroke:#15803D,color:#000
```
