# taranvohra/bbot architecture

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

- Interactive diagram: https://gitdiagram.com/taranvohra/bbot
- Repository: https://github.com/taranvohra/bbot

## Overview

bBot is a Discord bot for organizing UT99 pickup games and querying UT99 servers. The main workflow starts with Discord events, routes commands to handlers, then updates guild data and responds in Discord; pug operations also model team selection and match state, while query operations contact game servers. The README documents additional administration, moderation, statistics, and audit-log capabilities. Source excerpts establish several handler and persistence relationships; some command-routing details and unsampled capabilities are represented only at the documented subsystem level.

Main entry points: [`src/handlers/pugHandlers.ts`](https://github.com/taranvohra/bbot/blob/master/src/handlers/pugHandlers.ts) (Pug commands), [`src/handlers/queryHandlers.ts`](https://github.com/taranvohra/bbot/blob/master/src/handlers/queryHandlers.ts) (Query commands), [`src/handlers/generalHandlers.ts`](https://github.com/taranvohra/bbot/blob/master/src/handlers/generalHandlers.ts) (Guild administration), [`src/actions/index.ts`](https://github.com/taranvohra/bbot/blob/master/src/actions/index.ts) (Database actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_entry["Bot startup<br/>[index.ts]"]
  node_events["Event routing<br/>[eventHandlers.ts]"]
  node_general["Guild administration<br/>[generalHandlers.ts]"]
  node_audit["Warnings and logs<br/>[generalHandlers.ts]"]
  node_commands["Command catalog"]
  node_formatting["Response formatting<br/>[formatting.ts]"]
  node_logging["Logging<br/>[log.ts]"]
end

subgraph group_pugs["Pickup games"]
  node_pug_handlers["Pug commands<br/>[pugHandlers.ts]"]
  node_pug_model["Pug match state<br/>[Pug.ts]"]
  node_pug_capabilities["Pug features<br/>[pugHandlers.ts]"]
  node_utils["Game utilities<br/>[index.ts]"]
end

subgraph group_queries["Server queries"]
  node_query_handlers["Query commands<br/>[queryHandlers.ts]"]
  node_query_capabilities["Server management<br/>[queryHandlers.ts]"]
end

subgraph group_data["State and persistence"]
  node_setup["Database setup<br/>[setup.ts]"]
  node_actions["Database actions<br/>[index.ts]"]
  node_models["Domain models"]
  node_store["Runtime store<br/>[index.ts]"]
  node_slices["State slices"]
end

node_discord_users(("Discord users"))
node_discord["Discord platform"]
node_ut_servers["UT99 servers"]
node_mongo[("MongoDB")]

node_discord_users -->|"send commands"| node_discord
node_discord -->|"delivers events"| node_entry
node_entry -->|"registers handlers"| node_events
node_events -->|"checks commands"| node_commands
node_events -->|"dispatches events"| node_general
node_events -->|"dispatches events"| node_pug_handlers
node_events -->|"dispatches events"| node_query_handlers
node_general -->|"sends replies"| node_discord
node_general -->|"persists settings"| node_actions
node_general -->|"updates state"| node_store
node_general -->|"records warnings"| node_audit
node_audit -->|"creates log entries"| node_actions
node_audit -->|"sends log results"| node_discord
node_pug_handlers -.->|"manages matches"| node_pug_model
node_pug_handlers -->|"persists game data"| node_actions
node_pug_handlers -->|"updates state"| node_store
node_pug_handlers -->|"formats responses"| node_formatting
node_pug_handlers -->|"sends game updates"| node_discord
node_pug_model -->|"uses game helpers"| node_utils
node_pug_handlers -->|"provides match features"| node_pug_capabilities
node_query_handlers -->|"queries via UDP"| node_ut_servers
node_query_handlers -->|"persists server settings"| node_actions
node_query_handlers -->|"updates state"| node_store
node_query_handlers -->|"formats results"| node_formatting
node_query_handlers -->|"sends results"| node_discord
node_query_handlers -->|"manages servers"| node_query_capabilities
node_entry -->|"connects and hydrates"| node_setup
node_setup -->|"connects to"| node_mongo
node_setup -->|"loads guild records"| node_models
node_setup -->|"hydrates state"| node_store
node_actions -->|"uses domain records"| node_models
node_actions -->|"reads and writes"| node_mongo
node_store -->|"combines reducers"| node_slices
node_entry -->|"logs lifecycle"| node_logging
node_general -->|"formats logs"| node_formatting

click node_entry "https://github.com/taranvohra/bbot/blob/master/src/index.ts"
click node_events "https://github.com/taranvohra/bbot/blob/master/src/handlers/eventHandlers.ts"
click node_general "https://github.com/taranvohra/bbot/blob/master/src/handlers/generalHandlers.ts"
click node_audit "https://github.com/taranvohra/bbot/blob/master/src/handlers/generalHandlers.ts"
click node_commands "https://github.com/taranvohra/bbot/tree/master/src/commands"
click node_formatting "https://github.com/taranvohra/bbot/blob/master/src/formatting.ts"
click node_pug_handlers "https://github.com/taranvohra/bbot/blob/master/src/handlers/pugHandlers.ts"
click node_pug_model "https://github.com/taranvohra/bbot/blob/master/src/models/Pug.ts"
click node_pug_capabilities "https://github.com/taranvohra/bbot/blob/master/src/handlers/pugHandlers.ts"
click node_query_handlers "https://github.com/taranvohra/bbot/blob/master/src/handlers/queryHandlers.ts"
click node_query_capabilities "https://github.com/taranvohra/bbot/blob/master/src/handlers/queryHandlers.ts"
click node_setup "https://github.com/taranvohra/bbot/blob/master/src/setup.ts"
click node_actions "https://github.com/taranvohra/bbot/blob/master/src/actions/index.ts"
click node_models "https://github.com/taranvohra/bbot/tree/master/src/models"
click node_store "https://github.com/taranvohra/bbot/blob/master/src/store/index.ts"
click node_slices "https://github.com/taranvohra/bbot/tree/master/src/store/slices"
click node_utils "https://github.com/taranvohra/bbot/blob/master/src/utils/index.ts"
click node_logging "https://github.com/taranvohra/bbot/blob/master/src/log.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_events,node_general,node_audit,node_commands,node_formatting,node_logging,node_discord_users toneBlue
class node_pug_handlers,node_pug_model,node_pug_capabilities,node_utils,node_mongo toneAmber
class node_query_handlers,node_query_capabilities,node_ut_servers toneMint
class node_setup,node_actions,node_models,node_store,node_slices toneRose
class node_discord toneIndigo
```

## Components

### Bot runtime

- [Bot startup](https://github.com/taranvohra/bbot/blob/master/src/index.ts): `src/index.ts`
- [Event routing](https://github.com/taranvohra/bbot/blob/master/src/handlers/eventHandlers.ts): `src/handlers/eventHandlers.ts`
- [Guild administration](https://github.com/taranvohra/bbot/blob/master/src/handlers/generalHandlers.ts): `src/handlers/generalHandlers.ts`
- [Warnings and logs](https://github.com/taranvohra/bbot/blob/master/src/handlers/generalHandlers.ts): `src/handlers/generalHandlers.ts`
- [Command catalog](https://github.com/taranvohra/bbot/tree/master/src/commands): `src/commands`
- [Response formatting](https://github.com/taranvohra/bbot/blob/master/src/formatting.ts): `src/formatting.ts`
- [Logging](https://github.com/taranvohra/bbot/blob/master/src/log.ts): `src/log.ts`

### Pickup games

- [Pug commands](https://github.com/taranvohra/bbot/blob/master/src/handlers/pugHandlers.ts): `src/handlers/pugHandlers.ts`
- [Pug match state](https://github.com/taranvohra/bbot/blob/master/src/models/Pug.ts): `src/models/Pug.ts`
- [Pug features](https://github.com/taranvohra/bbot/blob/master/src/handlers/pugHandlers.ts): `src/handlers/pugHandlers.ts`
- [Game utilities](https://github.com/taranvohra/bbot/blob/master/src/utils/index.ts): `src/utils/index.ts`

### Server queries

- [Query commands](https://github.com/taranvohra/bbot/blob/master/src/handlers/queryHandlers.ts): `src/handlers/queryHandlers.ts`
- [Server management](https://github.com/taranvohra/bbot/blob/master/src/handlers/queryHandlers.ts): `src/handlers/queryHandlers.ts`

### State and persistence

- [Database setup](https://github.com/taranvohra/bbot/blob/master/src/setup.ts): `src/setup.ts`
- [Database actions](https://github.com/taranvohra/bbot/blob/master/src/actions/index.ts): `src/actions/index.ts`
- [Domain models](https://github.com/taranvohra/bbot/tree/master/src/models): `src/models`
- [Runtime store](https://github.com/taranvohra/bbot/blob/master/src/store/index.ts): `src/store/index.ts`
- [State slices](https://github.com/taranvohra/bbot/tree/master/src/store/slices): `src/store/slices`

### Other components

- **Discord users**
- **Discord platform**
- **UT99 servers**
- **MongoDB**

## Connections

- Discord users → Discord platform: send commands (evidence: `README.md`)
- Discord platform → Bot startup: delivers events (evidence: `src/index.ts`)
- Bot startup → Event routing: registers handlers (evidence: `src/index.ts`)
- Event routing → Command catalog: checks commands (evidence: `src/handlers/eventHandlers.ts`)
- Event routing → Guild administration: dispatches events (evidence: `src/handlers/eventHandlers.ts`)
- Event routing → Pug commands: dispatches events (evidence: `src/handlers/eventHandlers.ts`)
- Event routing → Query commands: dispatches events (evidence: `src/handlers/eventHandlers.ts`)
- Guild administration → Discord platform: sends replies (evidence: `src/handlers/generalHandlers.ts`)
- Guild administration → Database actions: persists settings (evidence: `src/handlers/generalHandlers.ts`)
- Guild administration → Runtime store: updates state (evidence: `src/handlers/generalHandlers.ts`)
- Guild administration → Warnings and logs: records warnings (evidence: `README.md`)
- Warnings and logs → Database actions: creates log entries (evidence: `src/handlers/generalHandlers.ts`)
- Warnings and logs → Discord platform: sends log results (evidence: `src/handlers/generalHandlers.ts`)
- Pug commands → Pug match state: manages matches
- Pug commands → Database actions: persists game data (evidence: `src/handlers/pugHandlers.ts`)
- Pug commands → Runtime store: updates state (evidence: `src/handlers/pugHandlers.ts`)
- Pug commands → Response formatting: formats responses (evidence: `src/handlers/pugHandlers.ts`)
- Pug commands → Discord platform: sends game updates (evidence: `README.md`)
- Pug match state → Game utilities: uses game helpers (evidence: `src/models/Pug.ts`)
- Pug commands → Pug features: provides match features (evidence: `README.md`)
- Query commands → UT99 servers: queries via UDP (evidence: `src/handlers/queryHandlers.ts`)
- Query commands → Database actions: persists server settings (evidence: `src/handlers/queryHandlers.ts`)
- Query commands → Runtime store: updates state (evidence: `src/handlers/queryHandlers.ts`)
- Query commands → Response formatting: formats results (evidence: `src/handlers/queryHandlers.ts`)
- Query commands → Discord platform: sends results (evidence: `src/handlers/queryHandlers.ts`)
- Query commands → Server management: manages servers (evidence: `README.md`)
- Bot startup → Database setup: connects and hydrates (evidence: `src/index.ts`)
- Database setup → MongoDB: connects to (evidence: `src/setup.ts`)
- Database setup → Domain models: loads guild records (evidence: `src/setup.ts`)
- Database setup → Runtime store: hydrates state (evidence: `src/setup.ts`)
- Database actions → Domain models: uses domain records (evidence: `src/actions/index.ts`)
- Database actions → MongoDB: reads and writes (evidence: `src/actions/index.ts`)
- Runtime store → State slices: combines reducers (evidence: `src/store/index.ts`)
- Bot startup → Logging: logs lifecycle (evidence: `src/index.ts`)
- Guild administration → Response formatting: formats logs (evidence: `src/handlers/generalHandlers.ts`)
