# iamdestroy/yukibot-md architecture

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

- Interactive diagram: https://gitdiagram.com/iamdestroy/yukibot-md
- Repository: https://github.com/iamdestroy/yukibot-md

## Overview

Yuki Bot is a Baileys-based, multifuncional WhatsApp bot. Its main workflow receives a WhatsApp event, normalizes the message, processes it in the command handler, and replies through the socket. Commands span group administration, gacha and economy games, media downloads, stickers, profiles, and utility features; the README also describes automatic responses and external API integrations. The excerpts show startup, message handling, selected database access, and sticker conversion. Most command-family links are therefore shown as unverified rather than inferred from directory names.

Main entry points: [`main.js`](https://github.com/iamdestroy/yukibot-md/blob/main/main.js) (Message handler), [`core/system/database.js`](https://github.com/iamdestroy/yukibot-md/blob/main/core/system/database.js) (SQLite database), [`index.js`](https://github.com/iamdestroy/yukibot-md/blob/main/index.js) (Socket startup), [`core/serialize.js`](https://github.com/iamdestroy/yukibot-md/blob/main/core/serialize.js) (Message normalization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_startup["Socket startup<br/>[index.js]"]
  node_normalize["Message normalization<br/>[serialize.js]"]
  node_handler["Message handler<br/>[main.js]"]
  node_loader["Command loader<br/>[cmdsLoader.js]"]
  node_commandmap["Command registry<br/>[commands.js]"]
end

subgraph group_commands["Command features"]
  node_gacha["Gacha games"]
  node_economy["Economy games"]
  node_groups["Group management"]
  node_media["Media commands"]
  node_stickers["Sticker commands<br/>[sticker.js]"]
  node_profiles["Profiles and levels"]
  node_automatic["Automatic responses<br/>[events.js]"]
  node_utilities["Other commands"]
end

subgraph group_state["State and media"]
  node_database[("SQLite database<br/>[database.js]")]
  node_exif["Sticker metadata<br/>[exif.js]"]
end

subgraph group_integrations["External services"]
  node_apis["Configured APIs<br/>[settings.js]"]
end

node_user(("WhatsApp user"))
node_whatsapp["WhatsApp"]
node_api_service["External API services"]
node_baileys["Baileys"]

node_user -->|"sends messages"| node_whatsapp
node_whatsapp -.->|"delivers events"| node_startup
node_startup -->|"normalizes messages"| node_normalize
node_normalize -->|"passes message"| node_handler
node_startup -->|"loads commands"| node_loader
node_handler -.->|"looks up command"| node_commandmap
node_handler -.->|"dispatches commands"| node_gacha
node_handler -.->|"dispatches commands"| node_economy
node_handler -.->|"dispatches commands"| node_groups
node_handler -.->|"dispatches commands"| node_media
node_handler -.->|"dispatches commands"| node_stickers
node_handler -.->|"dispatches commands"| node_profiles
node_handler -.->|"handles events"| node_automatic
node_handler -.->|"dispatches commands"| node_utilities
node_handler -->|"updates chat stats"| node_database
node_economy -->|"reads and writes"| node_database
node_stickers -->|"writes metadata"| node_exif
node_gacha -.->|"uses stored state"| node_database
node_profiles -.->|"uses stored state"| node_database
node_automatic -.->|"uses stored state"| node_database
node_apis -.->|"configures integrations"| node_api_service
node_media -.->|"fetches media"| node_api_service
node_whatsapp -->|"connects through"| node_baileys

click node_startup "https://github.com/iamdestroy/yukibot-md/blob/main/index.js"
click node_normalize "https://github.com/iamdestroy/yukibot-md/blob/main/core/serialize.js"
click node_handler "https://github.com/iamdestroy/yukibot-md/blob/main/main.js"
click node_loader "https://github.com/iamdestroy/yukibot-md/blob/main/core/system/cmdsLoader.js"
click node_commandmap "https://github.com/iamdestroy/yukibot-md/blob/main/core/system/commands.js"
click node_gacha "https://github.com/iamdestroy/yukibot-md/tree/main/cmds/gacha"
click node_economy "https://github.com/iamdestroy/yukibot-md/tree/main/cmds/economy"
click node_groups "https://github.com/iamdestroy/yukibot-md/tree/main/cmds/group"
click node_media "https://github.com/iamdestroy/yukibot-md/tree/main/cmds/downloads"
click node_stickers "https://github.com/iamdestroy/yukibot-md/blob/main/cmds/stickers/sticker.js"
click node_profiles "https://github.com/iamdestroy/yukibot-md/tree/main/cmds/profile"
click node_automatic "https://github.com/iamdestroy/yukibot-md/blob/main/cmds/events.js"
click node_utilities "https://github.com/iamdestroy/yukibot-md/tree/main/cmds/utils"
click node_database "https://github.com/iamdestroy/yukibot-md/blob/main/core/system/database.js"
click node_exif "https://github.com/iamdestroy/yukibot-md/blob/main/core/exif.js"
click node_apis "https://github.com/iamdestroy/yukibot-md/blob/main/settings.js"

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_startup,node_normalize,node_handler,node_loader,node_commandmap,node_user toneBlue
class node_gacha,node_economy,node_groups,node_media,node_stickers,node_profiles,node_automatic,node_utilities toneAmber
class node_database,node_exif,node_api_service toneMint
class node_apis toneRose
class node_whatsapp,node_baileys toneIndigo
```

## Components

### Bot runtime

- [Socket startup](https://github.com/iamdestroy/yukibot-md/blob/main/index.js): `index.js`
- [Message normalization](https://github.com/iamdestroy/yukibot-md/blob/main/core/serialize.js): `core/serialize.js`
- [Message handler](https://github.com/iamdestroy/yukibot-md/blob/main/main.js): `main.js`
- [Command loader](https://github.com/iamdestroy/yukibot-md/blob/main/core/system/cmdsLoader.js): `core/system/cmdsLoader.js`
- [Command registry](https://github.com/iamdestroy/yukibot-md/blob/main/core/system/commands.js): `core/system/commands.js`

### Command features

- [Gacha games](https://github.com/iamdestroy/yukibot-md/tree/main/cmds/gacha): `cmds/gacha`
- [Economy games](https://github.com/iamdestroy/yukibot-md/tree/main/cmds/economy): `cmds/economy`
- [Group management](https://github.com/iamdestroy/yukibot-md/tree/main/cmds/group): `cmds/group`
- [Media commands](https://github.com/iamdestroy/yukibot-md/tree/main/cmds/downloads): `cmds/downloads`
- [Sticker commands](https://github.com/iamdestroy/yukibot-md/blob/main/cmds/stickers/sticker.js): `cmds/stickers/sticker.js`
- [Profiles and levels](https://github.com/iamdestroy/yukibot-md/tree/main/cmds/profile): `cmds/profile`
- [Automatic responses](https://github.com/iamdestroy/yukibot-md/blob/main/cmds/events.js): `cmds/events.js`
- [Other commands](https://github.com/iamdestroy/yukibot-md/tree/main/cmds/utils): `cmds/utils`

### State and media

- [SQLite database](https://github.com/iamdestroy/yukibot-md/blob/main/core/system/database.js): `core/system/database.js`
- [Sticker metadata](https://github.com/iamdestroy/yukibot-md/blob/main/core/exif.js): `core/exif.js`

### External services

- [Configured APIs](https://github.com/iamdestroy/yukibot-md/blob/main/settings.js): `settings.js`

### Other components

- **WhatsApp user**
- **WhatsApp**
- **External API services**
- **Baileys**

## Connections

- WhatsApp user → WhatsApp: sends messages (evidence: `README.md`)
- WhatsApp → Socket startup: delivers events
- Socket startup → Message normalization: normalizes messages (evidence: `index.js`)
- Message normalization → Message handler: passes message
- Socket startup → Command loader: loads commands (evidence: `index.js`)
- Message handler → Command registry: looks up command
- Message handler → Gacha games: dispatches commands
- Message handler → Economy games: dispatches commands
- Message handler → Group management: dispatches commands
- Message handler → Media commands: dispatches commands
- Message handler → Sticker commands: dispatches commands
- Message handler → Profiles and levels: dispatches commands
- Message handler → Automatic responses: handles events
- Message handler → Other commands: dispatches commands
- Message handler → SQLite database: updates chat stats (evidence: `main.js`)
- Economy games → SQLite database: reads and writes (evidence: `cmds/economy/shop.js`)
- Sticker commands → Sticker metadata: writes metadata (evidence: `cmds/stickers/sticker.js`)
- Gacha games → SQLite database: uses stored state
- Profiles and levels → SQLite database: uses stored state
- Automatic responses → SQLite database: uses stored state
- Configured APIs → External API services: configures integrations
- Media commands → External API services: fetches media
- WhatsApp → Baileys: connects through
