# driplase/ft architecture

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

- Interactive diagram: https://gitdiagram.com/driplase/ft
- Repository: https://github.com/driplase/ft

## Overview

##### Main Components

a. Bot Core Engine
- Central “Discord Bot Engine” which is driven by files like main.js and gl.js. This component handles startup, event listeners, and overall orchestration.

b. Command System
- You might also note that many of these commands trigger specific bot functionalities (like sending DM notifications, badges, XP management, etc.).

c. Data and Configuration Stores
- A “Data Store” component that points to directories like “data”, “stats”, and files such as texts.json and config.json. This covers all persistent data like achievement records, language settings, ranking, subscription info, and audio files for TTS.
- Also incorporate “locales” and “ftlocales” directories to emphasize multi-language support.

d. Web Interface Components
- “Web Features” component. This includes the htdocs directory (with subdirectories for rate, timeline, trend, etc.) and data/web which stores shared post templates and default HTML pages. This part depicts the dashboards and website segments used via different localhost ports detailed in the README.

e. External Integrations
- Integrations to external systems and APIs:
- The Discord API for bot operation and event management.
- Google AI Studio for AI-based chat features.
- VOICEVOX and UTAU voicebanks for text-to-speech functionality in voice channels.
- Possibly integration with Second Treron (as a dependency point mentioned in the readme).
- Other external services like DISBOARD and dissoku for bump reminders.

##### Relationships and Interactions

- That the Command System accesses the “Data Store” for persistent user stats, badges, achievements, etc.

##### Architectural Patterns or Design Principles

- The project’s modular command structure suggests a plug-in style or command–handler pattern, where each command script (in the commands/utility folder) acts as a separate module.
- Additionally, note the integration with external platforms (web and other bot frameworks), which resembles a microservices-like interaction (even if they run on the same Node.js process) and asynchronous processing.

##### Relevant Technologies and Frameworks

- That the application is built in Node.js. This should be annotated along with the use of JSON for configuration, YAML for stats, and various templating (HTML, CSS, and JavaScript in the htdocs directory).
- Mention that package management is handled via npm (as seen by package.json and package-lock.json).
- Potential use of pm2 for process management, as suggested in the README.

##### Details to Capture

- Every directory or major file grouping is accounted for.
- Detail the responsibilities of each component. For example:
- “commands”: where each file is an independent command that the bot can execute.
- “data”: which houses not just static files but user data and runtime-generated data.
- “htdocs”: air interface interfaces that support website features like timeline, trend, and post sharing.
- Clearly denote configuration files (.env, config.json) as supporting the overall orchestration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Bot Core Engine Subgraph
    subgraph "Bot Core Engine"
        BotEngine["Discord Bot Engine"]:::internal
        MainFile["main.js"]:::file
        GLFile["gl.js"]:::file
        MainFile --> BotEngine
        GLFile --> BotEngine
    end

    %% Command System Subgraph
    subgraph "Command System"
        CommandMgr["Command Manager (commands/)"]:::internal
        subgraph "Utility Commands"
            Utility1["!share.js"]:::command
            Utility2["addcoin.js"]:::command
            Utility3["achievements.js"]:::command
        end
        Utility1 --> CommandMgr
        Utility2 --> CommandMgr
        Utility3 --> CommandMgr
    end

    %% Data and Configuration Stores Subgraph
    subgraph "Data & Config Stores"
        DataStore["Data & Config Store"]:::internal
        configFile["config.json"]:::file
        textsFile["texts.json"]:::file
        dataFolder["data/"]:::file
        localesFolder["locales/"]:::file
        ftlocalesFolder["ftlocales/"]:::file
        DataStore --> configFile
        DataStore --> textsFile
        DataStore --> dataFolder
        DataStore --> localesFolder
        DataStore --> ftlocalesFolder
    end

    %% Web Interface Components Subgraph
    subgraph "Web Interface Components"
        WebInterface["Web Interface"]:::web
        htdocs["htdocs/"]:::web
        webData["data/web/"]:::web
        WebInterface --> htdocs
        WebInterface --> webData
    end

    %% External Integrations Subgraph
    subgraph "External Integrations"
        DiscordAPIext["Discord API"]:::external
        GoogleAI["Google AI Studio"]:::external
        VOICEVOX["VOICEVOX"]:::external
        UTAU["UTAU Voicebanks"]:::external
        SecondTreron["Second Treron"]:::external
        DISBOARD["DISBOARD"]:::external
        dissoku["dissoku"]:::external
    end

    %% Relationships
    DiscordAPIext -->|"events"| BotEngine
    BotEngine -->|"routesCommands"| CommandMgr
    CommandMgr -->|"readWrite"| DataStore
    BotEngine -->|"updatesWeb"| WebInterface

    %% Bidirectional External Integrations with Bot Engine
    BotEngine <-->|"reqResp"| GoogleAI
    BotEngine <-->|"reqResp"| VOICEVOX
    BotEngine <-->|"reqResp"| UTAU
    BotEngine <-->|"reqResp"| SecondTreron
    BotEngine <-->|"reqResp"| DISBOARD
    BotEngine <-->|"reqResp"| dissoku

    %% Styles
    classDef internal fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef command fill:#B0E0E6,stroke:#000,stroke-width:1px;
    classDef web fill:#FFFF99,stroke:#000,stroke-width:1px;
    classDef external fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef file fill:#D3D3D3,stroke:#000,stroke-width:1px;

    %% Click Events
    click MainFile "https://github.com/driplase/ft/blob/main/main.js"
    click GLFile "https://github.com/driplase/ft/blob/main/gl.js"
    click CommandMgr "https://github.com/driplase/ft/tree/main/commands/"
    click Utility1 "https://github.com/driplase/ft/blob/main/commands/utility/!share.js"
    click Utility2 "https://github.com/driplase/ft/blob/main/commands/utility/addcoin.js"
    click Utility3 "https://github.com/driplase/ft/blob/main/commands/utility/achievements.js"
    click configFile "https://github.com/driplase/ft/blob/main/config.json"
    click textsFile "https://github.com/driplase/ft/blob/main/texts.json"
    click dataFolder "https://github.com/driplase/ft/tree/main/data/"
    click localesFolder "https://github.com/driplase/ft/tree/main/locales/"
    click ftlocalesFolder "https://github.com/driplase/ft/tree/main/ftlocales/"
    click htdocs "https://github.com/driplase/ft/tree/main/htdocs/"
    click webData "https://github.com/driplase/ft/tree/main/data/web/"
```
