# kevinurreta/discord-bot architecture

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

- Interactive diagram: https://gitdiagram.com/kevinurreta/discord-bot
- Repository: https://github.com/kevinurreta/discord-bot

## Overview

MultifuncionalBot is a self-hosted Discord bot whose user-facing workflow is Discord commands and events handled by the bot client, with responses and server settings supported by translation and persistence. Its main product branches are information, moderation, music, and server configuration; music uses a separate Lavalink integration. The graph also shows database repositories and ORM models as an internal persistence layer. Some command and event modules were not sampled, so those subsystems are represented by their existing directories; links are limited to relationships supported by the README or source index.

Main entry points: [`src/app/client.py`](https://github.com/kevinurreta/discord-bot/blob/main/src/app/client.py) (Discord client), [`src/infrastructure/database/repositories/guild_settings.py`](https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/repositories/guild_settings.py) (Settings repository), [`src/app/commands/info`](https://github.com/kevinurreta/discord-bot/tree/main/src/app/commands/info) (Information commands), [`src/app/commands/settings`](https://github.com/kevinurreta/discord-bot/tree/main/src/app/commands/settings) (Server settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bot["Bot runtime"]
  node_entry["Application entry<br/>[main.py]"]
  node_client["Discord client<br/>[client.py]"]
  node_loader["Module loader<br/>[loader.py]"]
  node_config["Settings<br/>[config.py]"]
  node_logging["Logging<br/>[logging.py]"]
end

subgraph group_features["Bot features"]
  node_events["Discord events"]
  node_tasks["Data sync task<br/>[sync_data.py]"]
  node_info["Information commands"]
  node_moderation["Moderation commands"]
  node_music["Music commands"]
  node_settings_cmd["Server settings"]
  node_i18n["Translation service<br/>[translate.py]"]
  node_embeds["Localized embeds<br/>[embed.py]"]
  node_permissions["Permission checks<br/>[permissions.py]"]
end

subgraph group_storage["Persistence"]
  node_db_connection["Database connection<br/>[connection.py]"]
  node_repo_base["CRUD repository<br/>[base.py]"]
  node_repo_guild["Guild repository<br/>[guild.py]"]
  node_repo_settings["Settings repository<br/>[guild_settings.py]"]
  node_repo_member["Member repository<br/>[member.py]"]
  node_repo_user["User repository<br/>[user.py]"]
  node_guild_model["Guild model<br/>[guild.py]"]
  node_guild_settings_model["Guild settings model<br/>[guild_settings.py]"]
  node_member_model["Member model<br/>[member.py]"]
  node_user_model["User model<br/>[user.py]"]
end

subgraph group_integrations["External services"]
  node_postgres[("PostgreSQL")]
  node_lavalink["Lavalink audio"]
  node_lavalink_connector["Lavalink connector<br/>[connection.py]"]
end

node_discord_user(("Discord users"))

node_discord_user -->|"uses bot"| node_client
node_entry -->|"starts"| node_client
node_entry -->|"loads settings"| node_config
node_client -->|"uses settings"| node_config
node_client -->|"loads modules"| node_loader
node_client -->|"creates tables"| node_db_connection
node_client -->|"connects"| node_lavalink_connector
node_client -.->|"dispatches events"| node_events
node_discord_user -.->|"requests information"| node_info
node_discord_user -.->|"requests moderation"| node_moderation
node_discord_user -.->|"requests music"| node_music
node_discord_user -.->|"changes settings"| node_settings_cmd
node_info -->|"reads guild data"| node_repo_guild
node_info -->|"reads preferences"| node_repo_settings
node_info -->|"reads members"| node_repo_member
node_info -->|"reads users"| node_repo_user
node_moderation -->|"checks access"| node_permissions
node_moderation -->|"formats response"| node_embeds
node_music -->|"formats response"| node_embeds
node_music -.->|"controls playback"| node_lavalink
node_settings_cmd -->|"checks access"| node_permissions
node_settings_cmd -->|"formats response"| node_embeds
node_settings_cmd -->|"translates responses"| node_i18n
node_settings_cmd -->|"updates language"| node_repo_settings
node_embeds -->|"requests translations"| node_i18n
node_i18n -->|"reads language"| node_repo_settings
node_tasks -->|"syncs guilds"| node_repo_guild
node_tasks -->|"syncs settings"| node_repo_settings
node_tasks -->|"syncs members"| node_repo_member
node_tasks -->|"syncs users"| node_repo_user
node_repo_guild -->|"extends CRUD"| node_repo_base
node_repo_settings -->|"extends CRUD"| node_repo_base
node_repo_member -->|"extends CRUD"| node_repo_base
node_repo_user -->|"extends CRUD"| node_repo_base
node_repo_guild -->|"persists"| node_guild_model
node_repo_settings -->|"persists"| node_guild_settings_model
node_repo_member -->|"persists"| node_member_model
node_repo_user -->|"persists"| node_user_model
node_db_connection -->|"connects to"| node_postgres
node_lavalink_connector -->|"connects to"| node_lavalink

click node_entry "https://github.com/kevinurreta/discord-bot/blob/main/main.py"
click node_client "https://github.com/kevinurreta/discord-bot/blob/main/src/app/client.py"
click node_loader "https://github.com/kevinurreta/discord-bot/blob/main/src/core/loader.py"
click node_config "https://github.com/kevinurreta/discord-bot/blob/main/src/core/config.py"
click node_logging "https://github.com/kevinurreta/discord-bot/blob/main/src/core/logging.py"
click node_events "https://github.com/kevinurreta/discord-bot/tree/main/src/app/events"
click node_tasks "https://github.com/kevinurreta/discord-bot/blob/main/src/app/tasks/sync_data.py"
click node_info "https://github.com/kevinurreta/discord-bot/tree/main/src/app/commands/info"
click node_moderation "https://github.com/kevinurreta/discord-bot/tree/main/src/app/commands/moderation"
click node_music "https://github.com/kevinurreta/discord-bot/tree/main/src/app/commands/music"
click node_settings_cmd "https://github.com/kevinurreta/discord-bot/tree/main/src/app/commands/settings"
click node_i18n "https://github.com/kevinurreta/discord-bot/blob/main/src/i18n/translate.py"
click node_embeds "https://github.com/kevinurreta/discord-bot/blob/main/src/helpers/embed.py"
click node_permissions "https://github.com/kevinurreta/discord-bot/blob/main/src/helpers/permissions.py"
click node_db_connection "https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/connection.py"
click node_repo_base "https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/repositories/base.py"
click node_repo_guild "https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/repositories/guild.py"
click node_repo_settings "https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/repositories/guild_settings.py"
click node_repo_member "https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/repositories/member.py"
click node_repo_user "https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/repositories/user.py"
click node_guild_model "https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/models/guild.py"
click node_guild_settings_model "https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/models/guild_settings.py"
click node_member_model "https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/models/member.py"
click node_user_model "https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/models/user.py"
click node_lavalink_connector "https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/lavalink/connection.py"

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_client,node_loader,node_config,node_logging,node_discord_user toneBlue
class node_events,node_tasks,node_info,node_moderation,node_music,node_settings_cmd,node_i18n,node_embeds,node_permissions toneAmber
class node_db_connection,node_repo_base,node_repo_guild,node_repo_settings,node_repo_member,node_repo_user,node_guild_model,node_guild_settings_model,node_member_model,node_user_model toneMint
class node_postgres,node_lavalink,node_lavalink_connector toneRose
```

## Components

### Bot runtime

- [Application entry](https://github.com/kevinurreta/discord-bot/blob/main/main.py): `main.py`
- [Discord client](https://github.com/kevinurreta/discord-bot/blob/main/src/app/client.py): `src/app/client.py`
- [Module loader](https://github.com/kevinurreta/discord-bot/blob/main/src/core/loader.py): `src/core/loader.py`
- [Settings](https://github.com/kevinurreta/discord-bot/blob/main/src/core/config.py): `src/core/config.py`
- [Logging](https://github.com/kevinurreta/discord-bot/blob/main/src/core/logging.py): `src/core/logging.py`

### Bot features

- [Discord events](https://github.com/kevinurreta/discord-bot/tree/main/src/app/events): `src/app/events`
- [Data sync task](https://github.com/kevinurreta/discord-bot/blob/main/src/app/tasks/sync_data.py): `src/app/tasks/sync_data.py`
- [Information commands](https://github.com/kevinurreta/discord-bot/tree/main/src/app/commands/info): `src/app/commands/info`
- [Moderation commands](https://github.com/kevinurreta/discord-bot/tree/main/src/app/commands/moderation): `src/app/commands/moderation`
- [Music commands](https://github.com/kevinurreta/discord-bot/tree/main/src/app/commands/music): `src/app/commands/music`
- [Server settings](https://github.com/kevinurreta/discord-bot/tree/main/src/app/commands/settings): `src/app/commands/settings`
- [Translation service](https://github.com/kevinurreta/discord-bot/blob/main/src/i18n/translate.py): `src/i18n/translate.py`
- [Localized embeds](https://github.com/kevinurreta/discord-bot/blob/main/src/helpers/embed.py): `src/helpers/embed.py`
- [Permission checks](https://github.com/kevinurreta/discord-bot/blob/main/src/helpers/permissions.py): `src/helpers/permissions.py`

### Persistence

- [Database connection](https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/connection.py): `src/infrastructure/database/connection.py`
- [CRUD repository](https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/repositories/base.py): `src/infrastructure/database/repositories/base.py`
- [Guild repository](https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/repositories/guild.py): `src/infrastructure/database/repositories/guild.py`
- [Settings repository](https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/repositories/guild_settings.py): `src/infrastructure/database/repositories/guild_settings.py`
- [Member repository](https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/repositories/member.py): `src/infrastructure/database/repositories/member.py`
- [User repository](https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/repositories/user.py): `src/infrastructure/database/repositories/user.py`
- [Guild model](https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/models/guild.py): `src/infrastructure/database/models/guild.py`
- [Guild settings model](https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/models/guild_settings.py): `src/infrastructure/database/models/guild_settings.py`
- [Member model](https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/models/member.py): `src/infrastructure/database/models/member.py`
- [User model](https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/database/models/user.py): `src/infrastructure/database/models/user.py`

### External services

- **PostgreSQL**
- **Lavalink audio**
- [Lavalink connector](https://github.com/kevinurreta/discord-bot/blob/main/src/infrastructure/lavalink/connection.py): `src/infrastructure/lavalink/connection.py`

### Other components

- **Discord users**

## Connections

- Discord users → Discord client: uses bot
- Application entry → Discord client: starts (evidence: `main.py`)
- Application entry → Settings: loads settings (evidence: `main.py`)
- Discord client → Settings: uses settings (evidence: `src/app/client.py`)
- Discord client → Module loader: loads modules (evidence: `src/app/client.py`)
- Discord client → Database connection: creates tables (evidence: `src/app/client.py`)
- Discord client → Lavalink connector: connects (evidence: `src/app/client.py`)
- Discord client → Discord events: dispatches events
- Discord users → Information commands: requests information
- Discord users → Moderation commands: requests moderation
- Discord users → Music commands: requests music
- Discord users → Server settings: changes settings
- Information commands → Guild repository: reads guild data (evidence: `src/app/commands/info/guild_stats.py`)
- Information commands → Settings repository: reads preferences (evidence: `src/app/commands/info/guild_stats.py`)
- Information commands → Member repository: reads members (evidence: `src/app/commands/info/guild_stats.py`)
- Information commands → User repository: reads users (evidence: `src/app/commands/info/guild_stats.py`)
- Moderation commands → Permission checks: checks access (evidence: `src/app/commands/moderation/purge.py`)
- Moderation commands → Localized embeds: formats response (evidence: `src/app/commands/moderation/purge.py`)
- Music commands → Localized embeds: formats response (evidence: `src/app/commands/music/play.py`)
- Music commands → Lavalink audio: controls playback
- Server settings → Permission checks: checks access (evidence: `src/app/commands/settings/language.py`)
- Server settings → Localized embeds: formats response (evidence: `src/app/commands/settings/language.py`)
- Server settings → Translation service: translates responses (evidence: `src/app/commands/settings/language.py`)
- Server settings → Settings repository: updates language (evidence: `src/app/commands/settings/language.py`)
- Localized embeds → Translation service: requests translations (evidence: `src/helpers/embed.py`)
- Translation service → Settings repository: reads language (evidence: `src/i18n/translate.py`)
- Data sync task → Guild repository: syncs guilds (evidence: `src/app/tasks/sync_data.py`)
- Data sync task → Settings repository: syncs settings (evidence: `src/app/tasks/sync_data.py`)
- Data sync task → Member repository: syncs members (evidence: `src/app/tasks/sync_data.py`)
- Data sync task → User repository: syncs users (evidence: `src/app/tasks/sync_data.py`)
- Guild repository → CRUD repository: extends CRUD (evidence: `src/infrastructure/database/repositories/guild.py`)
- Settings repository → CRUD repository: extends CRUD (evidence: `src/infrastructure/database/repositories/guild_settings.py`)
- Member repository → CRUD repository: extends CRUD (evidence: `src/infrastructure/database/repositories/base.py`)
- User repository → CRUD repository: extends CRUD (evidence: `src/infrastructure/database/repositories/base.py`)
- Guild repository → Guild model: persists (evidence: `src/infrastructure/database/repositories/guild.py`)
- Settings repository → Guild settings model: persists (evidence: `src/infrastructure/database/repositories/guild_settings.py`)
- Member repository → Member model: persists (evidence: `src/infrastructure/database/repositories/member.py`)
- User repository → User model: persists (evidence: `src/infrastructure/database/repositories/user.py`)
- Database connection → PostgreSQL: connects to (evidence: `src/infrastructure/database/connection.py`)
- Lavalink connector → Lavalink audio: connects to
