# konik-yt/admin-bot architecture

> Architecture diagram of the GitHub repository konik-yt/admin-bot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/konik-yt/admin-bot
- Repository: https://github.com/konik-yt/admin-bot

## Overview

#### Purpose and runtime
This is a Node.js Discord bot organized around Discord event handlers and category-based message commands. The process entry point is likely `index.js`; `Procfile` supports deployment on a process host. Core runtime dependencies are declared in `package.json`.

#### Startup and event boundary
`index.js` likely initializes the Discord client, persistence connections, and event registration. Incoming platform events are separated from business commands:
- `events/message.js` receives messages and is the primary command-ingress boundary.
- `events/guildCreate.js` and `events/guildDelete.js` handle bot installation/removal from Discord guilds.
- `handlers/command.js` resolves and executes commands after message handling.

#### Command dispatch and extension model
Commands are filesystem-organized by domain, making each command module an independently extensible capability. `handlers/command.js` is the central routing layer between parsed message input and command implementations. Representative command domains:
- Currency: `commands/currency/balance.js`, `commands/currency/transfer.js`, `commands/currency/gamble.js`
- Moderation: `commands/moderation/ban.js`, `commands/moderation/warn.js`, `commands/moderation/report.js`
- Mute management: `commands/mute/mute.js`, `commands/mute/unmute.js`
- Server/user utilities: `commands/misc/prefix.js`, `commands/info/help.js`, `commands/fun/giveaway.js`

#### Primary control flow
The expected request path is: Discord message → `events/message.js` → command parsing/validation → `handlers/command.js` → a module under `commands/` → Discord API actions and/or persistence → response message. Administrative commands such as `commands/moderation/restart.js` may affect process lifecycle, while `commands/misc/prefix.js` changes guild-specific dispatch behavior.

#### Persistence boundary
The repository contains both SQLite-oriented and MongoDB/Mongoose-oriented persistence artifacts:
- `db.js`
- `json.sqlite`
- `utils/mongoose.js`
- `models/guild.js`

`models/guild.js` is the likely schema boundary for guild configuration, including data needed by lifecycle events and per-guild behavior such as command prefixes. The coexistence of `db.js`/`json.sqlite` and Mongoose should be treated as an architectural integration point: command features may depend on one or both stores.

#### Shared behavior and configuration
`functions.js` is the likely shared utility/service layer used across events and commands. `config.json` is the repository-level configuration boundary, likely supplying bot credentials, defaults, or operational settings; it should remain distinct from mutable guild state in `models/guild.js`.

#### External systems and operational boundaries
The primary external service is Discord, accessed by the client initialized from `index.js` and invoked by event/command modules. MongoDB is implied by `utils/mongoose.js` and `models/guild.js`; SQLite is materially present through `db.js` and `json.sqlite`. Deployment process configuration is represented by `Procfile`.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot Runtime"]
  node_procfile["Process Host<br/>deployment"]
  node_package["Node Dependencies<br/>package manifest<br/>[package.json]"]
  node_config["Bot Configuration<br/>[config.json]"]
  node_index["Bot Bootstrap<br/>Node entry point<br/>[index.js]"]
end

subgraph group_events["Discord Events"]
  node_message_event["Message Ingress<br/>Discord event handler<br/>[message.js]"]
  node_guild_create["Guild Installed<br/>Discord event handler<br/>[guildCreate.js]"]
  node_guild_delete["Guild Removed<br/>Discord event handler<br/>[guildDelete.js]"]
end

subgraph group_commands["Command Extensions"]
  node_dispatcher["Command Dispatcher<br/>command router<br/>[command.js]"]
  node_currency["Currency Commands<br/>command modules<br/>[balance.js]"]
  node_moderation["Moderation Commands<br/>command modules<br/>[ban.js]"]
  node_mute["Mute Commands<br/>command modules<br/>[mute.js]"]
  node_guild_utilities["Guild Utilities<br/>command modules<br/>[prefix.js]"]
end

subgraph group_data["Persistence"]
  node_mongoose["Mongo Connection<br/>database adapter<br/>[mongoose.js]"]
  node_guild_model[("Guild State Model<br/>Mongoose model<br/>[guild.js]")]
  node_mongodb[("MongoDB<br/>external database")]
  node_sqlite_adapter["SQLite Adapter<br/>database adapter<br/>[db.js]"]
  node_sqlite[("SQLite Data<br/>[json.sqlite]")]
end

node_discord{{"Discord Platform<br/>external API"}}
node_shared["Shared Functions<br/>utility service<br/>[functions.js]"]

node_procfile -->|"starts"| node_index
node_package -.->|"provides runtime dependencies"| node_index
node_config -.->|"supplies settings"| node_index
node_index -->|"connects client"| node_discord
node_discord -->|"message events"| node_message_event
node_discord -->|"guild create"| node_guild_create
node_discord -->|"guild delete"| node_guild_delete
node_message_event -->|"parsed command"| node_dispatcher
node_dispatcher -->|"routes currency commands"| node_currency
node_dispatcher -->|"routes moderation commands"| node_moderation
node_dispatcher -->|"routes mute commands"| node_mute
node_dispatcher -->|"routes utility commands"| node_guild_utilities
node_message_event -.->|"reads guild settings"| node_guild_model
node_guild_create -->|"creates guild state"| node_guild_model
node_guild_delete -->|"removes guild state"| node_guild_model
node_guild_utilities -->|"updates prefix"| node_guild_model
node_currency -.->|"persists feature data"| node_sqlite_adapter
node_moderation -.->|"uses shared behavior"| node_shared
node_currency -->|"sends responses"| node_discord
node_moderation -->|"performs actions"| node_discord
node_mongoose -->|"connects"| node_mongodb
node_guild_model -->|"uses connection"| node_mongoose
node_sqlite_adapter -->|"reads and writes"| node_sqlite

click node_procfile "https://github.com/konik-yt/admin-bot/blob/master/Procfile"
click node_package "https://github.com/konik-yt/admin-bot/blob/master/package.json"
click node_config "https://github.com/konik-yt/admin-bot/blob/master/config.json"
click node_index "https://github.com/konik-yt/admin-bot/blob/master/index.js"
click node_message_event "https://github.com/konik-yt/admin-bot/blob/master/events/message.js"
click node_guild_create "https://github.com/konik-yt/admin-bot/blob/master/events/guildCreate.js"
click node_guild_delete "https://github.com/konik-yt/admin-bot/blob/master/events/guildDelete.js"
click node_dispatcher "https://github.com/konik-yt/admin-bot/blob/master/handlers/command.js"
click node_currency "https://github.com/konik-yt/admin-bot/blob/master/commands/currency/balance.js"
click node_moderation "https://github.com/konik-yt/admin-bot/blob/master/commands/moderation/ban.js"
click node_mute "https://github.com/konik-yt/admin-bot/blob/master/commands/mute/mute.js"
click node_guild_utilities "https://github.com/konik-yt/admin-bot/blob/master/commands/misc/prefix.js"
click node_shared "https://github.com/konik-yt/admin-bot/blob/master/functions.js"
click node_mongoose "https://github.com/konik-yt/admin-bot/blob/master/utils/mongoose.js"
click node_guild_model "https://github.com/konik-yt/admin-bot/blob/master/models/guild.js"
click node_sqlite_adapter "https://github.com/konik-yt/admin-bot/blob/master/db.js"
click node_sqlite "https://github.com/konik-yt/admin-bot/blob/master/json.sqlite"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_procfile,node_package,node_config,node_index toneBlue
class node_message_event,node_guild_create,node_guild_delete toneAmber
class node_dispatcher,node_currency,node_moderation,node_mute,node_guild_utilities toneMint
class node_mongoose,node_guild_model,node_mongodb,node_sqlite_adapter,node_sqlite toneRose
class node_discord,node_shared toneNeutral
```

## Components

### Bot Runtime

- [Process Host](https://github.com/konik-yt/admin-bot/blob/master/Procfile): deployment · Defines the deployed process command. · `Procfile`
- [Node Dependencies](https://github.com/konik-yt/admin-bot/blob/master/package.json): package manifest · `package.json`
- [Bot Configuration](https://github.com/konik-yt/admin-bot/blob/master/config.json): configuration · Static credentials and operational defaults. · `config.json`
- [Bot Bootstrap](https://github.com/konik-yt/admin-bot/blob/master/index.js): Node entry point · Initializes the Discord client, data connections, and handlers. · `index.js`

### Discord Events

- [Message Ingress](https://github.com/konik-yt/admin-bot/blob/master/events/message.js): Discord event handler · Validates incoming messages before command dispatch. · `events/message.js`
- [Guild Installed](https://github.com/konik-yt/admin-bot/blob/master/events/guildCreate.js): Discord event handler · `events/guildCreate.js`
- [Guild Removed](https://github.com/konik-yt/admin-bot/blob/master/events/guildDelete.js): Discord event handler · `events/guildDelete.js`

### Command Extensions

- [Command Dispatcher](https://github.com/konik-yt/admin-bot/blob/master/handlers/command.js): command router · Resolves parsed command input to command modules. · `handlers/command.js`
- [Currency Commands](https://github.com/konik-yt/admin-bot/blob/master/commands/currency/balance.js): command modules · Balance, transfer, and gambling capabilities. · `commands/currency/balance.js`
- [Moderation Commands](https://github.com/konik-yt/admin-bot/blob/master/commands/moderation/ban.js): command modules · Ban, warn, report, and restart capabilities. · `commands/moderation/ban.js`
- [Mute Commands](https://github.com/konik-yt/admin-bot/blob/master/commands/mute/mute.js): command modules · Mute and unmute management. · `commands/mute/mute.js`
- [Guild Utilities](https://github.com/konik-yt/admin-bot/blob/master/commands/misc/prefix.js): command modules · Prefix, help, and giveaway capabilities. · `commands/misc/prefix.js`

### Persistence

- [Mongo Connection](https://github.com/konik-yt/admin-bot/blob/master/utils/mongoose.js): database adapter · `utils/mongoose.js`
- [Guild State Model](https://github.com/konik-yt/admin-bot/blob/master/models/guild.js): Mongoose model · Stores mutable guild configuration such as prefixes. · `models/guild.js`
- **MongoDB**: external database
- [SQLite Adapter](https://github.com/konik-yt/admin-bot/blob/master/db.js): database adapter · `db.js`
- [SQLite Data](https://github.com/konik-yt/admin-bot/blob/master/json.sqlite): SQLite database · `json.sqlite`

### Other components

- **Discord Platform**: external API
- [Shared Functions](https://github.com/konik-yt/admin-bot/blob/master/functions.js): utility service · `functions.js`

## Connections

- Process Host → Bot Bootstrap: starts
- Node Dependencies → Bot Bootstrap: provides runtime dependencies
- Bot Configuration → Bot Bootstrap: supplies settings
- Bot Bootstrap → Discord Platform: connects client
- Discord Platform → Message Ingress: message events
- Discord Platform → Guild Installed: guild create
- Discord Platform → Guild Removed: guild delete
- Message Ingress → Command Dispatcher: parsed command
- Command Dispatcher → Currency Commands: routes currency commands
- Command Dispatcher → Moderation Commands: routes moderation commands
- Command Dispatcher → Mute Commands: routes mute commands
- Command Dispatcher → Guild Utilities: routes utility commands
- Message Ingress → Guild State Model: reads guild settings
- Guild Installed → Guild State Model: creates guild state
- Guild Removed → Guild State Model: removes guild state
- Guild Utilities → Guild State Model: updates prefix
- Currency Commands → SQLite Adapter: persists feature data
- Moderation Commands → Shared Functions: uses shared behavior
- Currency Commands → Discord Platform: sends responses
- Moderation Commands → Discord Platform: performs actions
- Mongo Connection → MongoDB: connects
- Guild State Model → Mongo Connection: uses connection
- SQLite Adapter → SQLite Data: reads and writes
