# ryanjohnkennedy/pancakebot architecture

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

- Interactive diagram: https://gitdiagram.com/ryanjohnkennedy/pancakebot
- Repository: https://github.com/ryanjohnkennedy/pancakebot

## Overview

PancakeBot is a Discord slash-command bot. A user invokes a command in Discord; the bot routes the interaction, applies a per-server rolling rate limit, and executes the matching command. Ping replies directly, while the two Track of the Day commands fetch authenticated leaderboard data from the PancakeBot API and format it for Discord. On startup and when joining a server, the bot registers its commands with Discord. The excerpts show these runtime links; the API’s internal processing is outside this repository.

Main entry points: [`src/index.ts`](https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/index.ts) (Event router), [`src/commands/totd.ts`](https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/commands/totd.ts) (Daily leaderboard), [`src/commands/totd-month.ts`](https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/commands/totd-month.ts) (Monthly leaderboard), [`src/deploy-commands.ts`](https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/deploy-commands.ts) (Command registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_entry["Event router<br/>[index.ts]"]
  node_limiter["Guild rate limiter"]
end

subgraph group_commands["Slash commands"]
  node_registry["Command registry<br/>[index.ts]"]
  node_ping["Ping reply<br/>[ping.ts]"]
  node_totd["Daily leaderboard<br/>[totd.ts]"]
  node_monthly["Monthly leaderboard<br/>[totd-month.ts]"]
end

subgraph group_setup["Configuration and registration"]
  node_config["Runtime configuration<br/>[config.ts]"]
  node_deploy["Command registration<br/>[deploy-commands.ts]"]
end

node_user(("Discord user"))
node_discord["Discord platform"]
node_api["PancakeBot API"]

node_user -->|"invokes command"| node_discord
node_discord -->|"delivers interaction"| node_entry
node_entry -->|"checks guild quota"| node_limiter
node_entry -->|"looks up command"| node_registry
node_entry -->|"executes selected"| node_ping
node_entry -->|"executes selected"| node_totd
node_entry -->|"executes selected"| node_monthly
node_ping -->|"replies"| node_discord
node_totd -->|"fetches daily results"| node_api
node_totd -->|"edits reply"| node_discord
node_monthly -->|"fetches monthly results"| node_api
node_monthly -->|"edits reply"| node_discord
node_entry -->|"registers commands"| node_deploy
node_deploy -->|"serializes commands"| node_registry
node_deploy -->|"updates guild commands"| node_discord
node_entry -->|"reads settings"| node_config
node_deploy -->|"reads credentials"| node_config
node_totd -->|"reads API settings"| node_config
node_monthly -->|"reads API settings"| node_config

click node_entry "https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/index.ts"
click node_limiter "https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/guild-rate-limiter.ts"
click node_registry "https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/commands/index.ts"
click node_ping "https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/commands/ping.ts"
click node_totd "https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/commands/totd.ts"
click node_monthly "https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/commands/totd-month.ts"
click node_config "https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/config.ts"
click node_deploy "https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/deploy-commands.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_limiter,node_user toneBlue
class node_registry,node_ping,node_totd,node_monthly toneAmber
class node_config,node_deploy,node_api toneMint
class node_discord toneIndigo
```

## Components

### Bot runtime

- [Event router](https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/index.ts): `src/index.ts`
- [Guild rate limiter](https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/guild-rate-limiter.ts): `src/guild-rate-limiter.ts`

### Slash commands

- [Command registry](https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/commands/index.ts): `src/commands/index.ts`
- [Ping reply](https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/commands/ping.ts): `src/commands/ping.ts`
- [Daily leaderboard](https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/commands/totd.ts): `src/commands/totd.ts`
- [Monthly leaderboard](https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/commands/totd-month.ts): `src/commands/totd-month.ts`

### Configuration and registration

- [Runtime configuration](https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/config.ts): `src/config.ts`
- [Command registration](https://github.com/ryanjohnkennedy/pancakebot/blob/develop/src/deploy-commands.ts): `src/deploy-commands.ts`

### Other components

- **Discord user**
- **Discord platform**
- **PancakeBot API**

## Connections

- Discord user → Discord platform: invokes command (evidence: `README.md`)
- Discord platform → Event router: delivers interaction (evidence: `src/index.ts`)
- Event router → Guild rate limiter: checks guild quota (evidence: `src/index.ts`)
- Event router → Command registry: looks up command (evidence: `src/index.ts`)
- Event router → Ping reply: executes selected
- Event router → Daily leaderboard: executes selected
- Event router → Monthly leaderboard: executes selected
- Ping reply → Discord platform: replies (evidence: `src/commands/ping.ts`)
- Daily leaderboard → PancakeBot API: fetches daily results (evidence: `src/commands/totd.ts`)
- Daily leaderboard → Discord platform: edits reply (evidence: `src/commands/totd.ts`)
- Monthly leaderboard → PancakeBot API: fetches monthly results (evidence: `src/commands/totd-month.ts`)
- Monthly leaderboard → Discord platform: edits reply (evidence: `src/commands/totd-month.ts`)
- Event router → Command registration: registers commands (evidence: `src/index.ts`)
- Command registration → Command registry: serializes commands (evidence: `src/deploy-commands.ts`)
- Command registration → Discord platform: updates guild commands (evidence: `src/deploy-commands.ts`)
- Event router → Runtime configuration: reads settings (evidence: `src/index.ts`)
- Command registration → Runtime configuration: reads credentials (evidence: `src/deploy-commands.ts`)
- Daily leaderboard → Runtime configuration: reads API settings (evidence: `src/commands/totd.ts`)
- Monthly leaderboard → Runtime configuration: reads API settings (evidence: `src/commands/totd-month.ts`)
