# commonly-ts/discord-bot-template architecture

> Architecture diagram of the GitHub repository commonly-ts/discord-bot-template, 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/commonly-ts/discord-bot-template
- Repository: https://github.com/commonly-ts/discord-bot-template

## Overview

This is a Discord bot starter template built around Trivious. Its runtime entry initializes PostgreSQL through TypeORM, then starts a Discord client configured to use `src/features` as its core path; the included debug slash command is the active feature shown in the tree. The template also provides examples for slash and context-menu commands, components, event modules, and component builders, plus shared interaction utilities. The README documents running and operating the bot but does not describe more application workflows. Framework internals were not sampled, so command discovery and interaction dispatch are not expanded into inferred edges.

Main entry points: [`src/index.ts`](https://github.com/commonly-ts/discord-bot-template/blob/main/src/index.ts) (Trivious client), [`templates/command`](https://github.com/commonly-ts/discord-bot-template/tree/main/templates/command) (Command examples), [`templates/builder/builder.example.ts`](https://github.com/commonly-ts/discord-bot-template/blob/main/templates/builder/builder.example.ts) (Component builder), [`src/features/debug/index.ts`](https://github.com/commonly-ts/discord-bot-template/blob/main/src/features/debug/index.ts) (Debug command)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_entry["Application entry<br/>[index.ts]"]
  node_client["Trivious client<br/>[index.ts]"]
  node_debug["Debug command<br/>[index.ts]"]
  node_database[("PostgreSQL datasource<br/>[index.ts]")]
end

subgraph group_authoring["Discord authoring"]
  node_commands["Command examples"]
  node_slash["Slash command<br/>[index.ts]"]
  node_context["Context commands"]
  node_components["Component example"]
  node_builder["Component builder<br/>[builder.example.ts]"]
  node_module["Event module<br/>[module.example.ts]"]
  node_events["Event example<br/>[event.example.ts]"]
end

subgraph group_shared["Shared support"]
  node_utilities["Interaction utilities<br/>[functions.ts]"]
  node_config["Configuration helpers<br/>[config.ts]"]
  node_builders["Shared builders<br/>[index.ts]"]
  node_typings["Shared typings<br/>[index.ts]"]
end

node_user(("Discord user"))
node_discord(("Discord"))

node_user -->|"uses bot"| node_discord
node_entry -->|"initializes"| node_database
node_entry -->|"starts"| node_client
node_client -.->|"connects"| node_discord
node_client -->|"core path"| node_debug
node_commands -->|"includes"| node_slash
node_commands -->|"includes"| node_context
node_builder -->|"builds IDs for"| node_components

click node_entry "https://github.com/commonly-ts/discord-bot-template/blob/main/src/index.ts"
click node_client "https://github.com/commonly-ts/discord-bot-template/blob/main/src/index.ts"
click node_debug "https://github.com/commonly-ts/discord-bot-template/blob/main/src/features/debug/index.ts"
click node_database "https://github.com/commonly-ts/discord-bot-template/blob/main/src/db/index.ts"
click node_commands "https://github.com/commonly-ts/discord-bot-template/tree/main/templates/command"
click node_slash "https://github.com/commonly-ts/discord-bot-template/blob/main/templates/command/slash-command/index.ts"
click node_context "https://github.com/commonly-ts/discord-bot-template/tree/main/templates/command/context-command"
click node_components "https://github.com/commonly-ts/discord-bot-template/blob/main/templates/component/component.example.ts"
click node_builder "https://github.com/commonly-ts/discord-bot-template/blob/main/templates/builder/builder.example.ts"
click node_module "https://github.com/commonly-ts/discord-bot-template/blob/main/templates/module/module.example.ts"
click node_events "https://github.com/commonly-ts/discord-bot-template/blob/main/templates/event/event.example.ts"
click node_utilities "https://github.com/commonly-ts/discord-bot-template/blob/main/src/shared/utility/functions.ts"
click node_config "https://github.com/commonly-ts/discord-bot-template/blob/main/src/shared/utility/config.ts"
click node_builders "https://github.com/commonly-ts/discord-bot-template/blob/main/src/shared/builders/index.ts"
click node_typings "https://github.com/commonly-ts/discord-bot-template/blob/main/src/shared/typings/index.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_client,node_debug,node_database,node_user toneBlue
class node_commands,node_slash,node_context,node_components,node_builder,node_module,node_events toneAmber
class node_utilities,node_config,node_builders,node_typings toneMint
class node_discord toneIndigo
```

## Components

### Bot runtime

- [Application entry](https://github.com/commonly-ts/discord-bot-template/blob/main/src/index.ts): `src/index.ts`
- [Trivious client](https://github.com/commonly-ts/discord-bot-template/blob/main/src/index.ts): `src/index.ts`
- [Debug command](https://github.com/commonly-ts/discord-bot-template/blob/main/src/features/debug/index.ts): `src/features/debug/index.ts`
- [PostgreSQL datasource](https://github.com/commonly-ts/discord-bot-template/blob/main/src/db/index.ts): `src/db/index.ts`

### Discord authoring

- [Command examples](https://github.com/commonly-ts/discord-bot-template/tree/main/templates/command): `templates/command`
- [Slash command](https://github.com/commonly-ts/discord-bot-template/blob/main/templates/command/slash-command/index.ts): `templates/command/slash-command/index.ts`
- [Context commands](https://github.com/commonly-ts/discord-bot-template/tree/main/templates/command/context-command): `templates/command/context-command`
- [Component example](https://github.com/commonly-ts/discord-bot-template/blob/main/templates/component/component.example.ts): `templates/component/component.example.ts`
- [Component builder](https://github.com/commonly-ts/discord-bot-template/blob/main/templates/builder/builder.example.ts): `templates/builder/builder.example.ts`
- [Event module](https://github.com/commonly-ts/discord-bot-template/blob/main/templates/module/module.example.ts): `templates/module/module.example.ts`
- [Event example](https://github.com/commonly-ts/discord-bot-template/blob/main/templates/event/event.example.ts): `templates/event/event.example.ts`

### Shared support

- [Interaction utilities](https://github.com/commonly-ts/discord-bot-template/blob/main/src/shared/utility/functions.ts): `src/shared/utility/functions.ts`
- [Configuration helpers](https://github.com/commonly-ts/discord-bot-template/blob/main/src/shared/utility/config.ts): `src/shared/utility/config.ts`
- [Shared builders](https://github.com/commonly-ts/discord-bot-template/blob/main/src/shared/builders/index.ts): `src/shared/builders/index.ts`
- [Shared typings](https://github.com/commonly-ts/discord-bot-template/blob/main/src/shared/typings/index.ts): `src/shared/typings/index.ts`

### Other components

- **Discord user**
- **Discord**

## Connections

- Discord user → Discord: uses bot
- Application entry → PostgreSQL datasource: initializes
- Application entry → Trivious client: starts
- Trivious client → Discord: connects
- Trivious client → Debug command: core path
- Command examples → Slash command: includes
- Command examples → Context commands: includes
- Component builder → Component example: builds IDs for
