# rayanfer32/atlas-md architecture

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

- Interactive diagram: https://gitdiagram.com/rayanfer32/atlas-md
- Repository: https://github.com/rayanfer32/atlas-md

## Overview

Atlas MD is a feature-rich WhatsApp bot: users send commands or messages through WhatsApp, the bot dispatches them to command plugins, and replies are sent back through its Baileys connection. The product also exposes pairing/status and webhook APIs, persists bot settings and authentication state in MongoDB, and supports hot-installed plugins. The README documents AI chat, downloads, moderation, group management, stickers/conversion, search and character features; these are mapped to plugin and system paths from the tree. Several runtime details are unsampled, so uncertain internal wiring is omitted.

Main entry points: [`System/ReadCommands.ts`](https://github.com/rayanfer32/atlas-md/blob/main/System/ReadCommands.ts) (Command loader), [`core/connection.ts`](https://github.com/rayanfer32/atlas-md/blob/main/core/connection.ts) (Bot connection), [`System/MongoDB/MongoDb_Core.ts`](https://github.com/rayanfer32/atlas-md/blob/main/System/MongoDB/MongoDb_Core.ts) (Bot settings), [`Plugins/core.ts`](https://github.com/rayanfer32/atlas-md/blob/main/Plugins/core.ts) (AI and chat)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_entry["Application entry<br/>[index.ts]"]
  node_connection["Bot connection<br/>[connection.ts]"]
  node_events["Message events<br/>[events.ts]"]
  node_commands_loader["Command loader<br/>[ReadCommands.ts]"]
  node_plugin_manager["Plugin manager<br/>[pluginManager.ts]"]
end

subgraph group_commands["Command features"]
  node_moderation["Moderation<br/>[moderator.ts]"]
  node_groups["Group management<br/>[group.ts]"]
  node_ai_chat["AI and chat<br/>[core.ts]"]
  node_downloads["Media downloads<br/>[downloader.ts]"]
  node_search["Search and media<br/>[search.ts]"]
  node_stickers_convert["Stickers and conversion<br/>[tools.ts]"]
  node_characters["Bot characters<br/>[BotCharacters.js]"]
end

subgraph group_state["Persistence"]
  node_settings["Bot settings<br/>[MongoDb_Core.ts]"]
  node_mongodb[("MongoDB models<br/>[MongoDB_Schema.ts]")]
  node_auth["Session auth<br/>[MongoAuth.ts]"]
  node_session_schema[("Session records<br/>[SessionSchema.ts]")]
end

subgraph group_interfaces["External interfaces"]
  node_http["HTTP and pairing API<br/>[server.ts]"]
end

subgraph group_integrations["External services"]
  node_ai_services["AI providers"]
  node_media_services["Media and search providers"]
end

node_operator(("WhatsApp user"))
node_wa(("WhatsApp"))

node_operator -->|"sends messages"| node_wa
node_wa -->|"delivers events"| node_connection
node_entry -->|"starts"| node_connection
node_connection -->|"loads credentials"| node_auth
node_auth -->|"reads and writes"| node_session_schema
node_connection -->|"dispatches events"| node_events
node_events -->|"dispatches commands"| node_commands_loader
node_commands_loader -->|"routes commands"| node_moderation
node_commands_loader -->|"routes commands"| node_groups
node_commands_loader -->|"routes commands"| node_ai_chat
node_commands_loader -->|"routes commands"| node_downloads
node_commands_loader -->|"routes commands"| node_search
node_commands_loader -->|"routes commands"| node_stickers_convert
node_commands_loader -->|"routes commands"| node_characters
node_moderation -->|"reads and updates"| node_settings
node_groups -->|"reads and updates"| node_settings
node_ai_chat -->|"reads settings"| node_settings
node_settings -->|"queries"| node_mongodb
node_entry -->|"starts server"| node_http
node_http -->|"uses socket"| node_connection
node_connection -->|"sends replies"| node_wa
node_plugin_manager -->|"loads plugin URLs"| node_settings
node_plugin_manager -->|"reloads commands"| node_commands_loader
node_ai_chat -.->|"requests responses"| node_ai_services
node_downloads -.->|"fetches media"| node_media_services
node_search -.->|"searches providers"| node_media_services

click node_entry "https://github.com/rayanfer32/atlas-md/blob/main/index.ts"
click node_connection "https://github.com/rayanfer32/atlas-md/blob/main/core/connection.ts"
click node_events "https://github.com/rayanfer32/atlas-md/blob/main/core/events.ts"
click node_commands_loader "https://github.com/rayanfer32/atlas-md/blob/main/System/ReadCommands.ts"
click node_plugin_manager "https://github.com/rayanfer32/atlas-md/blob/main/core/pluginManager.ts"
click node_moderation "https://github.com/rayanfer32/atlas-md/blob/main/Plugins/moderator.ts"
click node_groups "https://github.com/rayanfer32/atlas-md/blob/main/Plugins/group.ts"
click node_ai_chat "https://github.com/rayanfer32/atlas-md/blob/main/Plugins/core.ts"
click node_downloads "https://github.com/rayanfer32/atlas-md/blob/main/Plugins/downloader.ts"
click node_search "https://github.com/rayanfer32/atlas-md/blob/main/Plugins/search.ts"
click node_stickers_convert "https://github.com/rayanfer32/atlas-md/blob/main/Plugins/tools.ts"
click node_characters "https://github.com/rayanfer32/atlas-md/blob/main/System/BotCharacters.js"
click node_settings "https://github.com/rayanfer32/atlas-md/blob/main/System/MongoDB/MongoDb_Core.ts"
click node_mongodb "https://github.com/rayanfer32/atlas-md/blob/main/System/MongoDB/MongoDB_Schema.ts"
click node_auth "https://github.com/rayanfer32/atlas-md/blob/main/System/MongoAuth/MongoAuth.ts"
click node_session_schema "https://github.com/rayanfer32/atlas-md/blob/main/System/MongoAuth/Schema/SessionSchema.ts"
click node_http "https://github.com/rayanfer32/atlas-md/blob/main/core/server.ts"

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_connection,node_events,node_commands_loader,node_plugin_manager,node_operator toneBlue
class node_moderation,node_groups,node_ai_chat,node_downloads,node_search,node_stickers_convert,node_characters toneAmber
class node_settings,node_mongodb,node_auth,node_session_schema toneMint
class node_http toneRose
class node_ai_services,node_media_services,node_wa toneIndigo
```

## Components

### Bot runtime

- [Application entry](https://github.com/rayanfer32/atlas-md/blob/main/index.ts): `index.ts`
- [Bot connection](https://github.com/rayanfer32/atlas-md/blob/main/core/connection.ts): `core/connection.ts`
- [Message events](https://github.com/rayanfer32/atlas-md/blob/main/core/events.ts): `core/events.ts`
- [Command loader](https://github.com/rayanfer32/atlas-md/blob/main/System/ReadCommands.ts): `System/ReadCommands.ts`
- [Plugin manager](https://github.com/rayanfer32/atlas-md/blob/main/core/pluginManager.ts): `core/pluginManager.ts`

### Command features

- [Moderation](https://github.com/rayanfer32/atlas-md/blob/main/Plugins/moderator.ts): `Plugins/moderator.ts`
- [Group management](https://github.com/rayanfer32/atlas-md/blob/main/Plugins/group.ts): `Plugins/group.ts`
- [AI and chat](https://github.com/rayanfer32/atlas-md/blob/main/Plugins/core.ts): `Plugins/core.ts`
- [Media downloads](https://github.com/rayanfer32/atlas-md/blob/main/Plugins/downloader.ts): `Plugins/downloader.ts`
- [Search and media](https://github.com/rayanfer32/atlas-md/blob/main/Plugins/search.ts): `Plugins/search.ts`
- [Stickers and conversion](https://github.com/rayanfer32/atlas-md/blob/main/Plugins/tools.ts): `Plugins/tools.ts`
- [Bot characters](https://github.com/rayanfer32/atlas-md/blob/main/System/BotCharacters.js): `System/BotCharacters.js`

### Persistence

- [Bot settings](https://github.com/rayanfer32/atlas-md/blob/main/System/MongoDB/MongoDb_Core.ts): `System/MongoDB/MongoDb_Core.ts`
- [MongoDB models](https://github.com/rayanfer32/atlas-md/blob/main/System/MongoDB/MongoDB_Schema.ts): `System/MongoDB/MongoDB_Schema.ts`
- [Session auth](https://github.com/rayanfer32/atlas-md/blob/main/System/MongoAuth/MongoAuth.ts): `System/MongoAuth/MongoAuth.ts`
- [Session records](https://github.com/rayanfer32/atlas-md/blob/main/System/MongoAuth/Schema/SessionSchema.ts): `System/MongoAuth/Schema/SessionSchema.ts`

### External interfaces

- [HTTP and pairing API](https://github.com/rayanfer32/atlas-md/blob/main/core/server.ts): `core/server.ts`

### External services

- **AI providers**
- **Media and search providers**

### Other components

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

## Connections

- WhatsApp user → WhatsApp: sends messages
- WhatsApp → Bot connection: delivers events
- Application entry → Bot connection: starts
- Bot connection → Session auth: loads credentials
- Session auth → Session records: reads and writes
- Bot connection → Message events: dispatches events
- Message events → Command loader: dispatches commands
- Command loader → Moderation: routes commands
- Command loader → Group management: routes commands
- Command loader → AI and chat: routes commands
- Command loader → Media downloads: routes commands
- Command loader → Search and media: routes commands
- Command loader → Stickers and conversion: routes commands
- Command loader → Bot characters: routes commands
- Moderation → Bot settings: reads and updates
- Group management → Bot settings: reads and updates
- AI and chat → Bot settings: reads settings
- Bot settings → MongoDB models: queries
- Application entry → HTTP and pairing API: starts server
- HTTP and pairing API → Bot connection: uses socket
- Bot connection → WhatsApp: sends replies
- Plugin manager → Bot settings: loads plugin URLs
- Plugin manager → Command loader: reloads commands
- AI and chat → AI providers: requests responses
- Media downloads → Media and search providers: fetches media
- Search and media → Media and search providers: searches providers
