# pupariaa/cordium architecture

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

- Interactive diagram: https://gitdiagram.com/pupariaa/cordium
- Repository: https://github.com/pupariaa/cordium

## Overview

Cordium is a Discord.js bot framework combining bot commands and event handling with a REST API, a configuration dashboard, and selectable persistence/cache backends. The main runtime path starts in index.js, initializes the bot and framework managers, then dispatches Discord interactions to loaded commands while event handlers process Discord activity. The README documents additional dashboard and deployment capabilities not fully visible in the excerpts; those are represented at subsystem level. Arrows are limited to relationships visible in excerpts or explicitly documented in the README.

Main entry points: [`index.js`](https://github.com/pupariaa/cordium/blob/main/index.js) (Bot bootstrap), [`internals/EventsManager.js`](https://github.com/pupariaa/cordium/blob/main/internals/EventsManager.js) (Event lifecycle), [`internals/CommandsManager.js`](https://github.com/pupariaa/cordium/blob/main/internals/CommandsManager.js) (Command lifecycle), [`internals/EndpointsManager.js`](https://github.com/pupariaa/cordium/blob/main/internals/EndpointsManager.js) (Endpoint routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_bootstrap["Bot bootstrap<br/>[index.js]"]
  node_commands["Slash commands"]
  node_events["Discord event handlers"]
end

subgraph group_management["Framework management"]
  node_command_manager["Command lifecycle<br/>[CommandsManager.js]"]
  node_event_manager["Event lifecycle<br/>[EventsManager.js]"]
  node_endpoint_manager["Endpoint routing"]
  node_files_manager["Hot reload and file watching<br/>[FilesManager.js]"]
  node_configuration["Configuration management<br/>[configManager.js]"]
end

subgraph group_data["Data services"]
  node_events_database[("Event recording<br/>[EventsDatabase.js]")]
  node_messages_database[("Message database")]
  node_messages_cache["Message cache<br/>[MessagesCache.js]"]
  node_cache_manager["Cache backend selection<br/>[CacheManager.js]"]
  node_redis[("Redis backend<br/>[RedisManager.js]")]
  node_attachments["Attachment indexing"]
end

subgraph group_http["HTTP and dashboard"]
  node_api_endpoints["Public and private API"]
  node_dashboard_ui["Configuration dashboard<br/>[app.js]"]
  node_dashboard_server["Dashboard API server<br/>[server.js]"]
end

subgraph group_extensions["Developer extensions"]
  node_prototypes["Discord.js extensions"]
end

node_discord(("Discord users and platform"))
node_developer(("Bot developer"))

node_discord -->|"connects bot"| node_bootstrap
node_bootstrap -->|"initializes"| node_command_manager
node_bootstrap -->|"initializes"| node_event_manager
node_bootstrap -->|"registers interactions"| node_discord
node_bootstrap -->|"dispatches interactions"| node_commands
node_command_manager -->|"loads commands"| node_commands
node_event_manager -->|"registers handlers"| node_events
node_event_manager -->|"deletes message records"| node_messages_database
node_developer -->|"creates commands"| node_commands
node_developer -->|"creates handlers"| node_events
node_developer -->|"creates endpoints"| node_api_endpoints
node_bootstrap -.->|"starts API manager"| node_endpoint_manager
node_endpoint_manager -->|"routes requests"| node_api_endpoints
node_discord -->|"requests operations"| node_api_endpoints
node_developer -->|"configures bot"| node_dashboard_ui
node_dashboard_ui -->|"calls dashboard API"| node_dashboard_server
node_dashboard_server -->|"updates settings"| node_configuration
node_dashboard_server -->|"reads messages"| node_messages_cache
node_bootstrap -.->|"loads settings"| node_configuration
node_event_manager -.->|"records activity"| node_events_database
node_messages_cache -.->|"uses cache backend"| node_cache_manager
node_cache_manager -.->|"selects Redis"| node_redis
node_event_manager -.->|"indexes attachments"| node_attachments
node_bootstrap -->|"extends Discord.js"| node_prototypes
node_command_manager -.->|"inherits file lifecycle"| node_files_manager
node_event_manager -->|"inherits file lifecycle"| node_files_manager
node_endpoint_manager -->|"inherits file lifecycle"| node_files_manager

click node_bootstrap "https://github.com/pupariaa/cordium/blob/main/index.js"
click node_commands "https://github.com/pupariaa/cordium/tree/main/src/commands"
click node_events "https://github.com/pupariaa/cordium/tree/main/src/events"
click node_command_manager "https://github.com/pupariaa/cordium/blob/main/internals/CommandsManager.js"
click node_event_manager "https://github.com/pupariaa/cordium/blob/main/internals/EventsManager.js"
click node_endpoint_manager "https://github.com/pupariaa/cordium/blob/main/internals/EndpointsManager.js"
click node_files_manager "https://github.com/pupariaa/cordium/blob/main/internals/FilesManager.js"
click node_api_endpoints "https://github.com/pupariaa/cordium/tree/main/src/endpoints"
click node_dashboard_ui "https://github.com/pupariaa/cordium/blob/main/configurator/public/app.js"
click node_dashboard_server "https://github.com/pupariaa/cordium/blob/main/configurator/server.js"
click node_configuration "https://github.com/pupariaa/cordium/blob/main/internals/configManager.js"
click node_events_database "https://github.com/pupariaa/cordium/blob/main/internals/EventsDatabase.js"
click node_messages_database "https://github.com/pupariaa/cordium/blob/main/internals/MessagesDatabase.js"
click node_messages_cache "https://github.com/pupariaa/cordium/blob/main/internals/MessagesCache.js"
click node_cache_manager "https://github.com/pupariaa/cordium/blob/main/internals/CacheManager.js"
click node_redis "https://github.com/pupariaa/cordium/blob/main/internals/RedisManager.js"
click node_attachments "https://github.com/pupariaa/cordium/blob/main/internals/AttachmentsManager.js"
click node_prototypes "https://github.com/pupariaa/cordium/tree/main/internals/prototypes"

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_bootstrap,node_commands,node_events,node_discord toneBlue
class node_command_manager,node_event_manager,node_endpoint_manager,node_files_manager,node_configuration toneAmber
class node_events_database,node_messages_database,node_messages_cache,node_cache_manager,node_redis,node_attachments toneMint
class node_api_endpoints,node_dashboard_ui,node_dashboard_server toneRose
class node_prototypes,node_developer toneIndigo
```

## Components

### Bot runtime

- [Bot bootstrap](https://github.com/pupariaa/cordium/blob/main/index.js): `index.js`
- [Slash commands](https://github.com/pupariaa/cordium/tree/main/src/commands): `src/commands`
- [Discord event handlers](https://github.com/pupariaa/cordium/tree/main/src/events): `src/events`

### Framework management

- [Command lifecycle](https://github.com/pupariaa/cordium/blob/main/internals/CommandsManager.js): `internals/CommandsManager.js`
- [Event lifecycle](https://github.com/pupariaa/cordium/blob/main/internals/EventsManager.js): `internals/EventsManager.js`
- [Endpoint routing](https://github.com/pupariaa/cordium/blob/main/internals/EndpointsManager.js): `internals/EndpointsManager.js`
- [Hot reload and file watching](https://github.com/pupariaa/cordium/blob/main/internals/FilesManager.js): `internals/FilesManager.js`
- [Configuration management](https://github.com/pupariaa/cordium/blob/main/internals/configManager.js): `internals/configManager.js`

### Data services

- [Event recording](https://github.com/pupariaa/cordium/blob/main/internals/EventsDatabase.js): `internals/EventsDatabase.js`
- [Message database](https://github.com/pupariaa/cordium/blob/main/internals/MessagesDatabase.js): `internals/MessagesDatabase.js`
- [Message cache](https://github.com/pupariaa/cordium/blob/main/internals/MessagesCache.js): `internals/MessagesCache.js`
- [Cache backend selection](https://github.com/pupariaa/cordium/blob/main/internals/CacheManager.js): `internals/CacheManager.js`
- [Redis backend](https://github.com/pupariaa/cordium/blob/main/internals/RedisManager.js): `internals/RedisManager.js`
- [Attachment indexing](https://github.com/pupariaa/cordium/blob/main/internals/AttachmentsManager.js): `internals/AttachmentsManager.js`

### HTTP and dashboard

- [Public and private API](https://github.com/pupariaa/cordium/tree/main/src/endpoints): `src/endpoints`
- [Configuration dashboard](https://github.com/pupariaa/cordium/blob/main/configurator/public/app.js): `configurator/public/app.js`
- [Dashboard API server](https://github.com/pupariaa/cordium/blob/main/configurator/server.js): `configurator/server.js`

### Developer extensions

- [Discord.js extensions](https://github.com/pupariaa/cordium/tree/main/internals/prototypes): `internals/prototypes`

### Other components

- **Discord users and platform**
- **Bot developer**

## Connections

- Discord users and platform → Bot bootstrap: connects bot
- Bot bootstrap → Command lifecycle: initializes (evidence: `index.js`)
- Bot bootstrap → Event lifecycle: initializes (evidence: `index.js`)
- Bot bootstrap → Discord users and platform: registers interactions (evidence: `index.js`)
- Bot bootstrap → Slash commands: dispatches interactions (evidence: `index.js`)
- Command lifecycle → Slash commands: loads commands
- Event lifecycle → Discord event handlers: registers handlers (evidence: `internals/EventsManager.js`)
- Event lifecycle → Message database: deletes message records (evidence: `internals/EventsManager.js`)
- Bot developer → Slash commands: creates commands
- Bot developer → Discord event handlers: creates handlers
- Bot developer → Public and private API: creates endpoints
- Bot bootstrap → Endpoint routing: starts API manager
- Endpoint routing → Public and private API: routes requests (evidence: `internals/EndpointsManager.js`)
- Discord users and platform → Public and private API: requests operations
- Bot developer → Configuration dashboard: configures bot
- Configuration dashboard → Dashboard API server: calls dashboard API (evidence: `configurator/public/app.js`)
- Dashboard API server → Configuration management: updates settings (evidence: `configurator/server.js`)
- Dashboard API server → Message cache: reads messages (evidence: `configurator/server.js`)
- Bot bootstrap → Configuration management: loads settings
- Event lifecycle → Event recording: records activity
- Message cache → Cache backend selection: uses cache backend
- Cache backend selection → Redis backend: selects Redis
- Event lifecycle → Attachment indexing: indexes attachments
- Bot bootstrap → Discord.js extensions: extends Discord.js
- Command lifecycle → Hot reload and file watching: inherits file lifecycle
- Event lifecycle → Hot reload and file watching: inherits file lifecycle (evidence: `internals/EventsManager.js`)
- Endpoint routing → Hot reload and file watching: inherits file lifecycle (evidence: `internals/EndpointsManager.js`)
