# eniiju/movetool architecture

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

- Interactive diagram: https://gitdiagram.com/eniiju/movetool
- Repository: https://github.com/eniiju/movetool

## Overview

##### Project type and purpose
- This is a backend service: a Discord bot built in Node.js (TypeScript) using discord.js.
- Purpose: provide slash‑commands and context‑menu commands to move voice‑channel members on Discord and optionally log those actions into a MongoDB database.

##### File structure
- Top‑level config and orchestration files:
- Dockerfile, docker-compose.yaml, mongo-init.sh – define containerized deployment with a MongoDB service
- .github/workflows/deploy.yml – CI/CD pipeline for building and deploying the containers
- src/commands – individual command handlers organized under chatInput and contextMenu
- src/events – event listeners for Discord gateway events (ready, interactionCreate, guildDelete, shardError)
- src/lib – shared utilities (message formatting, moving logic, general helpers)
- src/modules – core modules: Database.ts (Mongo connection), Logger.ts (logging service)
- src/registerCommands.ts – registers slash and context‑menu commands with the Discord API
- src/index.ts – application entry point that initializes config, modules, registers commands, and starts the Discord client

##### README for additional insights
- Lists all slash commands (assemble, move, split, enable logging, logs, follow) and context‑menu commands
- Describes permissions required and basic usage

##### Elements
- Clear labels: e.g., “Discord Gateway”, “Bot Service (Node.js)”, “MongoDB”
- From Discord to Bot (incoming events)
- From Bot to MongoDB (read/write logs)
- From Bot to Discord (responses)
- From GitHub Actions to Docker/Server (deployment)
- Another for the database

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "External Services"
        Discord["Discord Gateway"]:::external
        Mongo["MongoDB"]:::database
    end

    subgraph "Infrastructure Definitions"
        DL["Dockerfile"]:::config
        DC["docker-compose.yaml"]:::config
        MI["mongo-init.sh"]:::config
        DeployYml[".github/workflows/deploy.yml"]:::config
    end

    subgraph "CI/CD & Deployment"
        GH["GitHub Actions"]:::ci
        Registry["Docker Registry"]:::external
        Compose["Docker Compose"]:::ci
    end

    subgraph "Bot Service Container"
        Entry["Entry Point (src/index.ts)"]:::module
        Config["Config Loader (src/config.ts)"]:::module
        Registrar["Command Registrar (src/registerCommands.ts)"]:::module
        subgraph "Event Handlers"
            Ready["Ready Event (src/events/ready.ts)"]:::module
            InteractionEvt["Interaction Create (src/events/interactionCreate.ts)"]:::module
            GuildDel["Guild Delete (src/events/guildDelete.ts)"]:::module
            ShardErr["Shard Error (src/events/shardError.ts)"]:::module
        end
        subgraph "Command Modules"
            Assemble["Assemble Command (src/commands/chatInput/assemble.ts)"]:::module
            Move["Move Command (src/commands/chatInput/move.ts)"]:::module
            Split["Split Command (src/commands/chatInput/split.ts)"]:::module
            EnableLog["Enable Logging (src/commands/chatInput/enable/logging.ts)"]:::module
            Logs["Logs Command (src/commands/chatInput/logs.ts)"]:::module
            Follow["Follow Command (src/commands/chatInput/follow.ts)"]:::module
            subgraph "Move Sub-Commands"
                MoveMembers["Move Members (src/commands/chatInput/move/members.ts)"]:::module
                MoveOnly["Move Only (src/commands/chatInput/move/only.ts)"]:::module
                MoveRole["Move Only by Role (src/commands/chatInput/move/only/role.ts)"]:::module
            end
        end
        subgraph "Context-Menu Commands"
            Goto["Go To Their Channel (src/commands/contextMenu/goToTheirChannel.ts)"]:::module
            MoveToMy["Move To My Channel (src/commands/contextMenu/moveToMyChannel.ts)"]:::module
        end
        subgraph "Modules & Utilities"
            DatabaseM["Database Module (src/modules/Database.ts)"]:::module
            LoggerM["Logger Module (src/modules/Logger.ts)"]:::module
            Helpers["Command Helpers (src/lib/commands.ts)"]:::module
            MsgFmt["Message Formatting (src/lib/message.ts)"]:::module
            MoveLogic["Move Logic (src/lib/move.ts)"]:::module
            Util["General Helpers (src/lib/util.ts)"]:::module
        end
    end

    %% Interactions
    Discord -->|"gateway events"| Entry
    Entry --> Config
    Entry --> Registrar
    Registrar --> InteractionEvt
    InteractionEvt -->|"routes to"| Assemble
    InteractionEvt --> Move
    InteractionEvt --> Split
    InteractionEvt --> EnableLog
    InteractionEvt --> Logs
    InteractionEvt --> Follow
    InteractionEvt --> Goto
    InteractionEvt --> MoveToMy
    InteractionEvt --> Ready
    Discord --> Ready
    Discord --> GuildDel
    Discord --> ShardErr
    Assemble --> LoggerM
    Move --> LoggerM
    Split --> LoggerM
    EnableLog --> LoggerM
    Logs --> LoggerM
    Follow --> LoggerM
    LoggerM --> DatabaseM
    DatabaseM -->|"connects to"| Mongo

    %% Deployment Flow
    DeployYml --> GH
    GH -->|"build image"| Registry
    Registry -->|"deploy"| Compose
    DL -->|"used by"| Compose
    DC -->|"used by"| Compose
    MI -->|"init script"| Mongo
    Compose -->|"launch|run containers"| BotService[Bot Service Container]
    Compose -->|"launch containers"| Mongo

    %% Click Events
    click DL "https://github.com/eniiju/movetool/tree/main/Dockerfile"
    click DC "https://github.com/eniiju/movetool/blob/main/docker-compose.yaml"
    click MI "https://github.com/eniiju/movetool/blob/main/mongo-init.sh"
    click DeployYml "https://github.com/eniiju/movetool/blob/main/.github/workflows/deploy.yml"
    click Entry "https://github.com/eniiju/movetool/blob/main/src/index.ts"
    click Config "https://github.com/eniiju/movetool/blob/main/src/config.ts"
    click Registrar "https://github.com/eniiju/movetool/blob/main/src/registerCommands.ts"
    click Assemble "https://github.com/eniiju/movetool/blob/main/src/commands/chatInput/assemble.ts"
    click Move "https://github.com/eniiju/movetool/blob/main/src/commands/chatInput/move.ts"
    click MoveMembers "https://github.com/eniiju/movetool/blob/main/src/commands/chatInput/move/members.ts"
    click MoveOnly "https://github.com/eniiju/movetool/blob/main/src/commands/chatInput/move/only.ts"
    click MoveRole "https://github.com/eniiju/movetool/blob/main/src/commands/chatInput/move/only/role.ts"
    click Split "https://github.com/eniiju/movetool/blob/main/src/commands/chatInput/split.ts"
    click EnableLog "https://github.com/eniiju/movetool/blob/main/src/commands/chatInput/enable/logging.ts"
    click Logs "https://github.com/eniiju/movetool/blob/main/src/commands/chatInput/logs.ts"
    click Follow "https://github.com/eniiju/movetool/blob/main/src/commands/chatInput/follow.ts"
    click Goto "https://github.com/eniiju/movetool/blob/main/src/commands/contextMenu/goToTheirChannel.ts"
    click MoveToMy "https://github.com/eniiju/movetool/blob/main/src/commands/contextMenu/moveToMyChannel.ts"
    click Ready "https://github.com/eniiju/movetool/blob/main/src/events/ready.ts"
    click InteractionEvt "https://github.com/eniiju/movetool/blob/main/src/events/interactionCreate.ts"
    click GuildDel "https://github.com/eniiju/movetool/blob/main/src/events/guildDelete.ts"
    click ShardErr "https://github.com/eniiju/movetool/blob/main/src/events/shardError.ts"
    click DatabaseM "https://github.com/eniiju/movetool/blob/main/src/modules/Database.ts"
    click LoggerM "https://github.com/eniiju/movetool/blob/main/src/modules/Logger.ts"
    click Helpers "https://github.com/eniiju/movetool/blob/main/src/lib/commands.ts"
    click MsgFmt "https://github.com/eniiju/movetool/blob/main/src/lib/message.ts"
    click MoveLogic "https://github.com/eniiju/movetool/blob/main/src/lib/move.ts"
    click Util "https://github.com/eniiju/movetool/blob/main/src/lib/util.ts"

    %% Styles
    classDef external fill:#BBDEFB,stroke:#0D47A1
    classDef database fill:#FFE0B2,stroke:#E65100
    classDef module fill:#C8E6C9,stroke:#1B5E20
    classDef ci fill:#E1BEE7,stroke:#6A1B9A
    classDef container fill:#F5F5F5,stroke:#616161
    classDef config fill:#FFF9C4,stroke:#F9A825
```
