# fazzrqy/xynzbot architecture

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

- Interactive diagram: https://gitdiagram.com/fazzrqy/xynzbot
- Repository: https://github.com/fazzrqy/xynzbot

## Overview

XYNZBOT is a WhatsApp bot whose plugins provide chat commands across administration, media, AI, entertainment, and utility features. Its main workflow is inbound WhatsApp events → message serialization → handler-based plugin dispatch → command execution and replies. The handler also loads per-message user and chat state from the JSON-backed database. The README only notes supported run environments; feature links for unsampled command modules are represented at their existing directories, and their individual integrations are not inferred.

Main entry points: [`system/handler.js`](https://github.com/fazzrqy/xynzbot/blob/main/system/handler.js) (Command handler), [`system/main.js`](https://github.com/fazzrqy/xynzbot/blob/main/system/main.js) (Bot session), [`command/ai`](https://github.com/fazzrqy/xynzbot/tree/main/command/ai) (AI features), [`command/anime`](https://github.com/fazzrqy/xynzbot/tree/main/command/anime) (Anime features)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_supervisor["Process supervisor<br/>[index.js]"]
  node_bot["Bot session<br/>[main.js]"]
  node_serializer["Message serializer<br/>[serialize.js]"]
  node_handler["Command handler<br/>[handler.js]"]
end

subgraph group_features["Chat features"]
  node_admin["Group administration"]
  node_owner["Owner controls"]
  node_maincommands["Bot commands"]
  node_ai["AI features"]
  node_anime["Anime features"]
  node_wattpad["Wattpad features"]
  node_utility["User utilities"]
  node_fun["Entertainment"]
end

subgraph group_media["Media tools"]
  node_downloads["Media downloads"]
  node_conversion["Media conversion"]
  node_tools["Chat utilities"]
end

subgraph group_state["State and plugins"]
  node_pluginloader["Plugin loader<br/>[plugins.js]"]
  node_database["Database layer<br/>[database.js]"]
  node_jsonstore[("JSON state")]
end

subgraph group_integrations["External services"]
  node_externalapis{{"External APIs"}}
end

node_user(("WhatsApp user"))
node_whatsapp(("WhatsApp"))

node_user -->|"sends messages"| node_whatsapp
node_whatsapp -->|"delivers events"| node_bot
node_supervisor -->|"starts process"| node_bot
node_bot -->|"connects session"| node_whatsapp
node_bot -->|"serializes messages"| node_serializer
node_bot -->|"dispatches events"| node_handler
node_bot -->|"loads plugins"| node_pluginloader
node_handler -->|"loads message state"| node_database
node_database -->|"reads and writes"| node_jsonstore
node_handler -->|"dispatches commands"| node_admin
node_handler -->|"dispatches commands"| node_owner
node_handler -->|"dispatches commands"| node_maincommands
node_handler -->|"dispatches commands"| node_ai
node_handler -->|"dispatches commands"| node_anime
node_handler -->|"dispatches commands"| node_wattpad
node_handler -->|"dispatches commands"| node_downloads
node_handler -->|"dispatches commands"| node_conversion
node_handler -->|"dispatches commands"| node_tools
node_handler -->|"dispatches commands"| node_utility
node_handler -->|"dispatches commands"| node_fun
node_admin -->|"sends replies"| node_whatsapp
node_owner -->|"sends replies"| node_whatsapp
node_maincommands -->|"sends replies"| node_whatsapp
node_ai -.->|"requests AI services"| node_externalapis
node_anime -.->|"requests content"| node_externalapis
node_wattpad -.->|"searches stories"| node_externalapis
node_downloads -.->|"requests media"| node_externalapis
node_tools -.->|"fetches resources"| node_externalapis
node_downloads -->|"sends media"| node_whatsapp
node_conversion -->|"sends converted media"| node_whatsapp
node_tools -->|"sends results"| node_whatsapp
node_utility -->|"sends replies"| node_whatsapp
node_fun -->|"sends replies"| node_whatsapp
node_ai -->|"sends replies"| node_whatsapp
node_anime -->|"sends replies"| node_whatsapp
node_wattpad -->|"sends replies"| node_whatsapp

click node_supervisor "https://github.com/fazzrqy/xynzbot/blob/main/system/index.js"
click node_bot "https://github.com/fazzrqy/xynzbot/blob/main/system/main.js"
click node_serializer "https://github.com/fazzrqy/xynzbot/blob/main/system/lib/serialize.js"
click node_handler "https://github.com/fazzrqy/xynzbot/blob/main/system/handler.js"
click node_pluginloader "https://github.com/fazzrqy/xynzbot/blob/main/system/lib/plugins.js"
click node_database "https://github.com/fazzrqy/xynzbot/blob/main/system/lib/database.js"
click node_admin "https://github.com/fazzrqy/xynzbot/tree/main/command/admin"
click node_owner "https://github.com/fazzrqy/xynzbot/tree/main/command/owner"
click node_maincommands "https://github.com/fazzrqy/xynzbot/tree/main/command/main"
click node_ai "https://github.com/fazzrqy/xynzbot/tree/main/command/ai"
click node_anime "https://github.com/fazzrqy/xynzbot/tree/main/command/anime"
click node_wattpad "https://github.com/fazzrqy/xynzbot/tree/main/command/wattpad"
click node_downloads "https://github.com/fazzrqy/xynzbot/tree/main/command/download"
click node_conversion "https://github.com/fazzrqy/xynzbot/tree/main/command/convert"
click node_tools "https://github.com/fazzrqy/xynzbot/tree/main/command/tools"
click node_utility "https://github.com/fazzrqy/xynzbot/tree/main/command/utility"
click node_fun "https://github.com/fazzrqy/xynzbot/tree/main/command/fun"

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_supervisor,node_bot,node_serializer,node_handler,node_user toneBlue
class node_admin,node_owner,node_maincommands,node_ai,node_anime,node_wattpad,node_utility,node_fun toneAmber
class node_downloads,node_conversion,node_tools toneMint
class node_pluginloader,node_database,node_jsonstore toneRose
class node_externalapis,node_whatsapp toneIndigo
```

## Components

### Bot runtime

- [Process supervisor](https://github.com/fazzrqy/xynzbot/blob/main/system/index.js): `system/index.js`
- [Bot session](https://github.com/fazzrqy/xynzbot/blob/main/system/main.js): `system/main.js`
- [Message serializer](https://github.com/fazzrqy/xynzbot/blob/main/system/lib/serialize.js): `system/lib/serialize.js`
- [Command handler](https://github.com/fazzrqy/xynzbot/blob/main/system/handler.js): `system/handler.js`

### Chat features

- [Group administration](https://github.com/fazzrqy/xynzbot/tree/main/command/admin): `command/admin`
- [Owner controls](https://github.com/fazzrqy/xynzbot/tree/main/command/owner): `command/owner`
- [Bot commands](https://github.com/fazzrqy/xynzbot/tree/main/command/main): `command/main`
- [AI features](https://github.com/fazzrqy/xynzbot/tree/main/command/ai): `command/ai`
- [Anime features](https://github.com/fazzrqy/xynzbot/tree/main/command/anime): `command/anime`
- [Wattpad features](https://github.com/fazzrqy/xynzbot/tree/main/command/wattpad): `command/wattpad`
- [User utilities](https://github.com/fazzrqy/xynzbot/tree/main/command/utility): `command/utility`
- [Entertainment](https://github.com/fazzrqy/xynzbot/tree/main/command/fun): `command/fun`

### Media tools

- [Media downloads](https://github.com/fazzrqy/xynzbot/tree/main/command/download): `command/download`
- [Media conversion](https://github.com/fazzrqy/xynzbot/tree/main/command/convert): `command/convert`
- [Chat utilities](https://github.com/fazzrqy/xynzbot/tree/main/command/tools): `command/tools`

### State and plugins

- [Plugin loader](https://github.com/fazzrqy/xynzbot/blob/main/system/lib/plugins.js): `system/lib/plugins.js`
- [Database layer](https://github.com/fazzrqy/xynzbot/blob/main/system/lib/database.js): `system/lib/database.js`
- **JSON state**

### External services

- **External APIs**

### Other components

- **WhatsApp user**
- **WhatsApp**

## Connections

- WhatsApp user → WhatsApp: sends messages
- WhatsApp → Bot session: delivers events
- Process supervisor → Bot session: starts process
- Bot session → WhatsApp: connects session
- Bot session → Message serializer: serializes messages
- Bot session → Command handler: dispatches events
- Bot session → Plugin loader: loads plugins
- Command handler → Database layer: loads message state
- Database layer → JSON state: reads and writes
- Command handler → Group administration: dispatches commands
- Command handler → Owner controls: dispatches commands
- Command handler → Bot commands: dispatches commands
- Command handler → AI features: dispatches commands
- Command handler → Anime features: dispatches commands
- Command handler → Wattpad features: dispatches commands
- Command handler → Media downloads: dispatches commands
- Command handler → Media conversion: dispatches commands
- Command handler → Chat utilities: dispatches commands
- Command handler → User utilities: dispatches commands
- Command handler → Entertainment: dispatches commands
- Group administration → WhatsApp: sends replies
- Owner controls → WhatsApp: sends replies
- Bot commands → WhatsApp: sends replies
- AI features → External APIs: requests AI services
- Anime features → External APIs: requests content
- Wattpad features → External APIs: searches stories
- Media downloads → External APIs: requests media
- Chat utilities → External APIs: fetches resources
- Media downloads → WhatsApp: sends media
- Media conversion → WhatsApp: sends converted media
- Chat utilities → WhatsApp: sends results
- User utilities → WhatsApp: sends replies
- Entertainment → WhatsApp: sends replies
- AI features → WhatsApp: sends replies
- Anime features → WhatsApp: sends replies
- Wattpad features → WhatsApp: sends replies
