# felipebonfim2006/basebot architecture

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

- Interactive diagram: https://gitdiagram.com/felipebonfim2006/basebot
- Repository: https://github.com/felipebonfim2006/basebot

## Overview

BaseBot is a Discord bot supporting prefix and slash commands, per-server prefix and slash-command settings, utility and moderation features, and MongoDB-backed state. The main flow starts at the Discord client: message events resolve prefix commands, while interaction events handle slash commands; command handlers respond through Discord and may read or update MongoDB. Startup connects to MongoDB and loads command and event handlers. The event-handler and command-loading internals are not shown, so those links are marked unverified where appropriate.

Main entry points: [`src/commands/moderacao`](https://github.com/felipebonfim2006/basebot/tree/main/src/commands/moderacao) (Moderation Commands), [`index.js`](https://github.com/felipebonfim2006/basebot/blob/main/index.js) (Client Startup), [`src/events/client/messageCreate.js`](https://github.com/felipebonfim2006/basebot/blob/main/src/events/client/messageCreate.js) (Message Event), [`src/handlers/Events.js`](https://github.com/felipebonfim2006/basebot/blob/main/src/handlers/Events.js) (Event Loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot Runtime"]
  node_entry["Client Startup<br/>[index.js]"]
  node_event_loader["Event Loader<br/>[Events.js]"]
  node_command_loader["Command Loader<br/>[Commands.js]"]
  node_ready["Ready Event<br/>[ClientReady.js]"]
  node_message_event["Message Event<br/>[messageCreate.js]"]
  node_interaction_event["Interaction Event"]
  node_config["Bot Configuration<br/>[ex.config.json]"]
end

subgraph group_commands["Commands"]
  node_moderation["Moderation Commands"]
  node_utilities["Utility Commands"]
end

subgraph group_state["Persistent State"]
  node_guild_model[("Guild Settings<br/>[Guild.js]")]
  node_user_model[("User Statistics<br/>[User.js]")]
  node_db_connection["MongoDB Connection<br/>[mongoose.js]"]
end

subgraph group_discord["Discord Integration"]
  node_discord_api{{"Discord API"}}
end

node_operator(("Bot Operator"))
node_discord_users(("Discord Users"))

node_operator -->|"starts bot"| node_entry
node_entry -->|"connects database"| node_db_connection
node_entry -->|"loads handler"| node_event_loader
node_entry -->|"loads handler"| node_command_loader
node_entry -->|"logs in"| node_discord_api
node_entry -->|"reads credentials"| node_config
node_event_loader -.->|"registers events"| node_ready
node_event_loader -.->|"registers events"| node_message_event
node_event_loader -.->|"registers events"| node_interaction_event
node_command_loader -.->|"loads commands"| node_moderation
node_command_loader -.->|"loads commands"| node_utilities
node_discord_users -->|"sends messages"| node_message_event
node_message_event -->|"reads prefix"| node_guild_model
node_message_event -->|"dispatches prefix"| node_moderation
node_message_event -->|"dispatches prefix"| node_utilities
node_discord_users -->|"sends interactions"| node_interaction_event
node_interaction_event -.->|"dispatches slash"| node_moderation
node_interaction_event -.->|"dispatches slash"| node_utilities
node_moderation -->|"updates settings"| node_guild_model
node_moderation -->|"toggles commands"| node_guild_model
node_moderation -->|"registers commands"| node_discord_api
node_moderation -->|"removes commands"| node_discord_api
node_moderation -->|"updates usage"| node_user_model
node_utilities -->|"updates usage"| node_user_model
node_ready -->|"reads enabled servers"| node_guild_model
node_ready -->|"syncs commands"| node_discord_api
node_db_connection -->|"reads URI"| node_config

click node_entry "https://github.com/felipebonfim2006/basebot/blob/main/index.js"
click node_event_loader "https://github.com/felipebonfim2006/basebot/blob/main/src/handlers/Events.js"
click node_command_loader "https://github.com/felipebonfim2006/basebot/blob/main/src/handlers/Commands.js"
click node_ready "https://github.com/felipebonfim2006/basebot/blob/main/src/events/client/ClientReady.js"
click node_message_event "https://github.com/felipebonfim2006/basebot/blob/main/src/events/client/messageCreate.js"
click node_interaction_event "https://github.com/felipebonfim2006/basebot/blob/main/src/events/client/interactionCreate.js"
click node_moderation "https://github.com/felipebonfim2006/basebot/tree/main/src/commands/moderacao"
click node_utilities "https://github.com/felipebonfim2006/basebot/tree/main/src/commands/utilidades"
click node_guild_model "https://github.com/felipebonfim2006/basebot/blob/main/src/database/models/Guild.js"
click node_user_model "https://github.com/felipebonfim2006/basebot/blob/main/src/database/models/User.js"
click node_db_connection "https://github.com/felipebonfim2006/basebot/blob/main/src/database/mongoose.js"
click node_config "https://github.com/felipebonfim2006/basebot/blob/main/src/configs/ex.config.json"

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_entry,node_event_loader,node_command_loader,node_ready,node_message_event,node_interaction_event,node_config,node_discord_users toneBlue
class node_moderation,node_utilities toneAmber
class node_guild_model,node_user_model,node_db_connection toneMint
class node_discord_api toneRose
class node_operator toneIndigo
```

## Components

### Bot Runtime

- [Client Startup](https://github.com/felipebonfim2006/basebot/blob/main/index.js): `index.js`
- [Event Loader](https://github.com/felipebonfim2006/basebot/blob/main/src/handlers/Events.js): `src/handlers/Events.js`
- [Command Loader](https://github.com/felipebonfim2006/basebot/blob/main/src/handlers/Commands.js): `src/handlers/Commands.js`
- [Ready Event](https://github.com/felipebonfim2006/basebot/blob/main/src/events/client/ClientReady.js): `src/events/client/ClientReady.js`
- [Message Event](https://github.com/felipebonfim2006/basebot/blob/main/src/events/client/messageCreate.js): `src/events/client/messageCreate.js`
- [Interaction Event](https://github.com/felipebonfim2006/basebot/blob/main/src/events/client/interactionCreate.js): `src/events/client/interactionCreate.js`
- [Bot Configuration](https://github.com/felipebonfim2006/basebot/blob/main/src/configs/ex.config.json): `src/configs/ex.config.json`

### Commands

- [Moderation Commands](https://github.com/felipebonfim2006/basebot/tree/main/src/commands/moderacao): `src/commands/moderacao`
- [Utility Commands](https://github.com/felipebonfim2006/basebot/tree/main/src/commands/utilidades): `src/commands/utilidades`

### Persistent State

- [Guild Settings](https://github.com/felipebonfim2006/basebot/blob/main/src/database/models/Guild.js): `src/database/models/Guild.js`
- [User Statistics](https://github.com/felipebonfim2006/basebot/blob/main/src/database/models/User.js): `src/database/models/User.js`
- [MongoDB Connection](https://github.com/felipebonfim2006/basebot/blob/main/src/database/mongoose.js): `src/database/mongoose.js`

### Discord Integration

- **Discord API**

### Other components

- **Bot Operator**
- **Discord Users**

## Connections

- Bot Operator → Client Startup: starts bot (evidence: `README.md`)
- Client Startup → MongoDB Connection: connects database (evidence: `index.js`)
- Client Startup → Event Loader: loads handler (evidence: `index.js`)
- Client Startup → Command Loader: loads handler (evidence: `index.js`)
- Client Startup → Discord API: logs in (evidence: `index.js`)
- Client Startup → Bot Configuration: reads credentials (evidence: `index.js`)
- Event Loader → Ready Event: registers events
- Event Loader → Message Event: registers events
- Event Loader → Interaction Event: registers events
- Command Loader → Moderation Commands: loads commands
- Command Loader → Utility Commands: loads commands
- Discord Users → Message Event: sends messages (evidence: `src/events/client/messageCreate.js`)
- Message Event → Guild Settings: reads prefix (evidence: `src/events/client/messageCreate.js`)
- Message Event → Moderation Commands: dispatches prefix (evidence: `src/events/client/messageCreate.js`)
- Message Event → Utility Commands: dispatches prefix (evidence: `src/events/client/messageCreate.js`)
- Discord Users → Interaction Event: sends interactions (evidence: `README.md`)
- Interaction Event → Moderation Commands: dispatches slash
- Interaction Event → Utility Commands: dispatches slash
- Moderation Commands → Guild Settings: updates settings (evidence: `src/commands/moderacao/setprefix.js`)
- Moderation Commands → Guild Settings: toggles commands (evidence: `src/commands/moderacao/addslash.js`)
- Moderation Commands → Discord API: registers commands (evidence: `src/commands/moderacao/addslash.js`)
- Moderation Commands → Discord API: removes commands (evidence: `src/commands/moderacao/removeslash.js`)
- Moderation Commands → User Statistics: updates usage (evidence: `src/commands/moderacao/clear.js`)
- Utility Commands → User Statistics: updates usage (evidence: `src/commands/utilidades/ping.js`)
- Ready Event → Guild Settings: reads enabled servers (evidence: `src/events/client/ClientReady.js`)
- Ready Event → Discord API: syncs commands (evidence: `src/events/client/ClientReady.js`)
- MongoDB Connection → Bot Configuration: reads URI (evidence: `src/database/mongoose.js`)
