# the-a-p-o-l-l-o-organization/apollo-discord-bot architecture

> Architecture diagram of the GitHub repository the-a-p-o-l-l-o-organization/apollo-discord-bot, 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/the-a-p-o-l-l-o-organization/apollo-discord-bot
- Repository: https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot
- Video tour (about a minute): https://gitdiagram.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/video

## Overview

A.P.O.L.L.O is a modular Discord bot for server administration, moderation, tickets, automation, and utility commands. The main workflow is a Discord interaction entering the gateway, being dispatched to a plugin command (or queued for worker processing), and producing a Discord response; plugins also react to guild events. Redis-backed queues and locks support multi-instance operation, while SQLite/PostgreSQL provide persistence. The repository additionally contains optional Interlink cross-bot messaging and a Rust NSFW-classification service. The README documents product capabilities not represented in sampled source; their wiring is shown only where tree paths and explicit architecture documentation support it.

Main entry points: [`src/index.ts`](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/index.ts) (Gateway Runtime), [`src/core/PluginManager.ts`](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/core/PluginManager.ts) (Plugin Manager), [`src/queue/jobHandler.ts`](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/queue/jobHandler.ts) (Job Handler), [`src/queue/nsfwClient.ts`](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/queue/nsfwClient.ts) (NSFW gRPC Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot Runtime"]
  node_gateway["Gateway Runtime<br/>[index.ts]"]
  node_plugin_manager["Plugin Manager<br/>[PluginManager.ts]"]
  node_event_bus["Plugin Event Bus<br/>[EventBus.ts]"]
end

subgraph group_plugins["Guild Features"]
  node_moderation["Moderation<br/>[plugin.ts]"]
  node_automod["Auto Moderation<br/>[plugin.ts]"]
  node_tickets["Ticket System<br/>[plugin.ts]"]
  node_admin["Admin and Logging<br/>[plugin.ts]"]
  node_utility["Utility Commands<br/>[plugin.ts]"]
  node_integrations_plugin["Service Integrations<br/>[plugin.ts]"]
end

subgraph group_scaling["Distributed Runtime"]
  node_gateway_router["Gateway Router<br/>[gatewayRouter.ts]"]
  node_queue["Job Queue<br/>[queue.ts]"]
  node_worker["Worker Runtime<br/>[worker.ts]"]
  node_job_handler["Job Handler<br/>[jobHandler.ts]"]
  node_process_command["Command Jobs<br/>[processCommand.ts]"]
  node_leader["Leader Election<br/>[leader.ts]"]
end

subgraph group_persistence["State and Services"]
  node_database[("Bot Database<br/>[db.ts]")]
  node_redis[("Redis<br/>[redis.ts]")]
end

subgraph group_integrations["External Integrations"]
  node_interlink_client["Interlink Client<br/>[connectClient.ts]"]
  node_interlink_server["Interlink Service<br/>[server.go]"]
  node_nsfw_job["NSFW Analysis Job<br/>[nsfwAnalyze.ts]"]
  node_nsfw_client["NSFW gRPC Client<br/>[nsfwClient.ts]"]
  node_nsfw_server["NSFW Model Service<br/>[main.rs]"]
end

node_user(("Discord User"))
node_discord(("Discord Platform"))
node_service_apis(("Twitch, YouTube, RSS"))

node_user -->|"sends interaction"| node_discord
node_discord -->|"delivers interaction"| node_gateway
node_gateway -->|"loads plugins"| node_plugin_manager
node_gateway -->|"routes work"| node_gateway_router
node_gateway_router -->|"enqueues jobs"| node_queue
node_queue -->|"dispatches jobs"| node_worker
node_worker -->|"handles jobs"| node_job_handler
node_job_handler -->|"processes command"| node_process_command
node_gateway -->|"responds via API"| node_discord
node_plugin_manager -->|"loads plugin"| node_moderation
node_plugin_manager -->|"loads plugin"| node_automod
node_plugin_manager -->|"loads plugin"| node_tickets
node_plugin_manager -->|"loads plugin"| node_admin
node_plugin_manager -->|"loads plugin"| node_utility
node_plugin_manager -->|"loads plugin"| node_integrations_plugin
node_moderation -->|"persists cases"| node_database
node_tickets -->|"persists tickets"| node_database
node_admin -->|"publishes events"| node_event_bus
node_event_bus -.->|"bridges cross-pod events"| node_redis
node_gateway -->|"elects leader"| node_leader
node_leader -->|"acquires lock"| node_redis
node_gateway -->|"reads and writes state"| node_database
node_gateway -->|"uses shared services"| node_redis
node_integrations_plugin -.->|"queries services"| node_service_apis
node_gateway -.->|"uses messaging"| node_interlink_client
node_interlink_client -.->|"sends envelopes"| node_interlink_server
node_job_handler -.->|"handles analysis"| node_nsfw_job
node_nsfw_job -.->|"requests detection"| node_nsfw_client
node_nsfw_client -.->|"calls gRPC"| node_nsfw_server
node_nsfw_server -.->|"returns classification"| node_nsfw_client
node_gateway -->|"receives guild events"| node_discord

click node_gateway "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/index.ts"
click node_plugin_manager "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/core/PluginManager.ts"
click node_event_bus "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/core/EventBus.ts"
click node_moderation "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/plugins/moderation/plugin.ts"
click node_automod "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/plugins/automod/plugin.ts"
click node_tickets "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/plugins/tickets/plugin.ts"
click node_admin "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/plugins/admin/plugin.ts"
click node_utility "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/plugins/utility/plugin.ts"
click node_integrations_plugin "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/plugins/integrations/plugin.ts"
click node_gateway_router "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/queue/gatewayRouter.ts"
click node_queue "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/queue/queue.ts"
click node_worker "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/worker.ts"
click node_job_handler "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/queue/jobHandler.ts"
click node_process_command "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/queue/jobs/processCommand.ts"
click node_leader "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/gateway/leader.ts"
click node_database "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/utils/db.ts"
click node_redis "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/utils/redis.ts"
click node_interlink_client "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/plugins/interlink/connectClient.ts"
click node_interlink_server "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/services/interlink/internal/server/server.go"
click node_nsfw_job "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/queue/jobs/nsfwAnalyze.ts"
click node_nsfw_client "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/queue/nsfwClient.ts"
click node_nsfw_server "https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/crates/nsfw-server/src/main.rs"

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_gateway,node_plugin_manager,node_event_bus,node_user toneBlue
class node_moderation,node_automod,node_tickets,node_admin,node_utility,node_integrations_plugin toneAmber
class node_gateway_router,node_queue,node_worker,node_job_handler,node_process_command,node_leader toneMint
class node_database,node_redis toneRose
class node_interlink_client,node_interlink_server,node_nsfw_job,node_nsfw_client,node_nsfw_server,node_discord,node_service_apis toneIndigo
```

## Components

### Bot Runtime

- [Gateway Runtime](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/index.ts): `src/index.ts`
- [Plugin Manager](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/core/PluginManager.ts): `src/core/PluginManager.ts`
- [Plugin Event Bus](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/core/EventBus.ts): `src/core/EventBus.ts`

### Guild Features

- [Moderation](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/plugins/moderation/plugin.ts): `src/plugins/moderation/plugin.ts`
- [Auto Moderation](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/plugins/automod/plugin.ts): `src/plugins/automod/plugin.ts`
- [Ticket System](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/plugins/tickets/plugin.ts): `src/plugins/tickets/plugin.ts`
- [Admin and Logging](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/plugins/admin/plugin.ts): `src/plugins/admin/plugin.ts`
- [Utility Commands](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/plugins/utility/plugin.ts): `src/plugins/utility/plugin.ts`
- [Service Integrations](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/plugins/integrations/plugin.ts): `src/plugins/integrations/plugin.ts`

### Distributed Runtime

- [Gateway Router](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/queue/gatewayRouter.ts): `src/queue/gatewayRouter.ts`
- [Job Queue](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/queue/queue.ts): `src/queue/queue.ts`
- [Worker Runtime](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/worker.ts): `src/worker.ts`
- [Job Handler](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/queue/jobHandler.ts): `src/queue/jobHandler.ts`
- [Command Jobs](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/queue/jobs/processCommand.ts): `src/queue/jobs/processCommand.ts`
- [Leader Election](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/gateway/leader.ts): `src/gateway/leader.ts`

### State and Services

- [Bot Database](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/utils/db.ts): `src/utils/db.ts`
- [Redis](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/utils/redis.ts): `src/utils/redis.ts`

### External Integrations

- [Interlink Client](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/plugins/interlink/connectClient.ts): `src/plugins/interlink/connectClient.ts`
- [Interlink Service](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/services/interlink/internal/server/server.go): `services/interlink/internal/server/server.go`
- [NSFW Analysis Job](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/queue/jobs/nsfwAnalyze.ts): `src/queue/jobs/nsfwAnalyze.ts`
- [NSFW gRPC Client](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/src/queue/nsfwClient.ts): `src/queue/nsfwClient.ts`
- [NSFW Model Service](https://github.com/the-a-p-o-l-l-o-organization/apollo-discord-bot/blob/main/crates/nsfw-server/src/main.rs): `crates/nsfw-server/src/main.rs`

### Other components

- **Discord User**
- **Discord Platform**
- **Twitch, YouTube, RSS**

## Connections

- Discord User → Discord Platform: sends interaction
- Discord Platform → Gateway Runtime: delivers interaction
- Gateway Runtime → Plugin Manager: loads plugins
- Gateway Runtime → Gateway Router: routes work
- Gateway Router → Job Queue: enqueues jobs
- Job Queue → Worker Runtime: dispatches jobs
- Worker Runtime → Job Handler: handles jobs
- Job Handler → Command Jobs: processes command
- Gateway Runtime → Discord Platform: responds via API
- Plugin Manager → Moderation: loads plugin
- Plugin Manager → Auto Moderation: loads plugin
- Plugin Manager → Ticket System: loads plugin
- Plugin Manager → Admin and Logging: loads plugin
- Plugin Manager → Utility Commands: loads plugin
- Plugin Manager → Service Integrations: loads plugin
- Moderation → Bot Database: persists cases
- Ticket System → Bot Database: persists tickets
- Admin and Logging → Plugin Event Bus: publishes events
- Plugin Event Bus → Redis: bridges cross-pod events
- Gateway Runtime → Leader Election: elects leader
- Leader Election → Redis: acquires lock
- Gateway Runtime → Bot Database: reads and writes state
- Gateway Runtime → Redis: uses shared services
- Service Integrations → Twitch, YouTube, RSS: queries services
- Gateway Runtime → Interlink Client: uses messaging
- Interlink Client → Interlink Service: sends envelopes
- Job Handler → NSFW Analysis Job: handles analysis
- NSFW Analysis Job → NSFW gRPC Client: requests detection
- NSFW gRPC Client → NSFW Model Service: calls gRPC
- NSFW Model Service → NSFW gRPC Client: returns classification
- Gateway Runtime → Discord Platform: receives guild events
