# stegripe/rawon architecture

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

- Interactive diagram: https://gitdiagram.com/stegripe/rawon
- Repository: https://github.com/stegripe/rawon

## Overview

Rawon is a Discord music bot, optionally running multiple bot instances. Its main user journey is a Discord command or request-channel action that selects music, adds it to a server queue, and controls playback in voice. The README also documents multi-source support, audio pre-caching, Google cookie login, and persistent settings. Some subsystem links reflect documented capabilities and directory names; unsampled wiring is left out.

Main entry points: [`src/commands/music/PlayCommand.ts`](https://github.com/stegripe/rawon/blob/main/src/commands/music/PlayCommand.ts) (Play command), [`src/structures/CommandContext.ts`](https://github.com/stegripe/rawon/blob/main/src/structures/CommandContext.ts) (Command context), [`src/utils/structures/CommandManager.ts`](https://github.com/stegripe/rawon/blob/main/src/utils/structures/CommandManager.ts) (Command manager), [`src/structures/ServerQueue.ts`](https://github.com/stegripe/rawon/blob/main/src/structures/ServerQueue.ts) (Server queue)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_bot["Bot client<br/>[bot.ts]"]
  node_message_listener["Message listener"]
  node_interaction_listener["Interaction listener"]
  node_command_manager["Command manager<br/>[CommandManager.ts]"]
  node_multi_bot["Multi-bot routing<br/>[MultiBotManager.ts]"]
  node_launcher["Multi-bot launcher"]
end

subgraph group_commands["Discord commands"]
  node_command_context["Command context<br/>[CommandContext.ts]"]
  node_play_command["Play command<br/>[PlayCommand.ts]"]
  node_music_commands["Music controls"]
end

subgraph group_music["Music playback"]
  node_query_classifier["Query classifier<br/>[checkQuery.ts]"]
  node_music_handlers["Search and resolve"]
  node_general_util["General music utility<br/>[GeneralUtil.ts]"]
  node_queue["Server queue<br/>[ServerQueue.ts]"]
  node_song_manager["Song manager<br/>[SongManager.ts]"]
  node_audio_cache["Audio pre-cache"]
  node_voice["Voice playback<br/>[YTDLUtil.ts]"]
end

subgraph group_state["State and routing"]
  node_request_channel["Request channel"]
  node_sqlite[("SQLite data")]
end

subgraph group_integrations["Media integrations"]
  node_google_login["Google login"]
  node_media_services(("Music sources"))
end

node_user(("Discord user"))
node_discord(("Discord"))
node_google(("Google login site"))

node_user -->|"sends command"| node_discord
node_discord -->|"delivers message"| node_message_listener
node_discord -->|"delivers interaction"| node_interaction_listener
node_message_listener -->|"dispatches command"| node_command_manager
node_interaction_listener -->|"dispatches command"| node_command_manager
node_command_manager -->|"builds context"| node_command_context
node_command_context -->|"invokes"| node_play_command
node_command_context -->|"invokes"| node_music_commands
node_request_channel -->|"offers controls"| node_music_commands
node_play_command -->|"classifies query"| node_query_classifier
node_play_command -->|"resolves request"| node_music_handlers
node_music_handlers -.->|"searches sources"| node_media_services
node_play_command -->|"queues tracks"| node_queue
node_general_util -->|"handles playback"| node_queue
node_queue -->|"manages songs"| node_song_manager
node_general_util -->|"streams audio"| node_voice
node_audio_cache -.->|"fetches audio"| node_media_services
node_launcher -->|"coordinates bots"| node_multi_bot
node_bot -->|"uses persistent data"| node_sqlite
node_google_login -.->|"authenticates"| node_google
node_google_login -->|"stores session state"| node_sqlite

click node_bot "https://github.com/stegripe/rawon/blob/main/src/bot.ts"
click node_message_listener "https://github.com/stegripe/rawon/blob/main/src/listeners/MessageCreateListener.ts"
click node_interaction_listener "https://github.com/stegripe/rawon/blob/main/src/listeners/InteractionCreateListener.ts"
click node_command_manager "https://github.com/stegripe/rawon/blob/main/src/utils/structures/CommandManager.ts"
click node_command_context "https://github.com/stegripe/rawon/blob/main/src/structures/CommandContext.ts"
click node_play_command "https://github.com/stegripe/rawon/blob/main/src/commands/music/PlayCommand.ts"
click node_music_commands "https://github.com/stegripe/rawon/tree/main/src/commands/music"
click node_request_channel "https://github.com/stegripe/rawon/blob/main/src/utils/structures/RequestChannelManager.ts"
click node_query_classifier "https://github.com/stegripe/rawon/blob/main/src/utils/handlers/general/checkQuery.ts"
click node_music_handlers "https://github.com/stegripe/rawon/tree/main/src/utils/handlers/general"
click node_general_util "https://github.com/stegripe/rawon/blob/main/src/utils/handlers/GeneralUtil.ts"
click node_queue "https://github.com/stegripe/rawon/blob/main/src/structures/ServerQueue.ts"
click node_song_manager "https://github.com/stegripe/rawon/blob/main/src/utils/structures/SongManager.ts"
click node_audio_cache "https://github.com/stegripe/rawon/blob/main/src/utils/structures/AudioCacheManager.ts"
click node_voice "https://github.com/stegripe/rawon/blob/main/src/utils/handlers/YTDLUtil.ts"
click node_multi_bot "https://github.com/stegripe/rawon/blob/main/src/utils/structures/MultiBotManager.ts"
click node_launcher "https://github.com/stegripe/rawon/blob/main/src/utils/structures/MultiBotLauncher.ts"
click node_sqlite "https://github.com/stegripe/rawon/blob/main/src/utils/structures/SQLiteDataManager.ts"
click node_google_login "https://github.com/stegripe/rawon/blob/main/src/utils/structures/GoogleLoginManager.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_bot,node_message_listener,node_interaction_listener,node_command_manager,node_multi_bot,node_launcher,node_user toneBlue
class node_command_context,node_play_command,node_music_commands toneAmber
class node_query_classifier,node_music_handlers,node_general_util,node_queue,node_song_manager,node_audio_cache,node_voice toneMint
class node_request_channel,node_sqlite toneRose
class node_google_login,node_media_services,node_discord,node_google toneIndigo
```

## Components

### Bot runtime

- [Bot client](https://github.com/stegripe/rawon/blob/main/src/bot.ts): `src/bot.ts`
- [Message listener](https://github.com/stegripe/rawon/blob/main/src/listeners/MessageCreateListener.ts): `src/listeners/MessageCreateListener.ts`
- [Interaction listener](https://github.com/stegripe/rawon/blob/main/src/listeners/InteractionCreateListener.ts): `src/listeners/InteractionCreateListener.ts`
- [Command manager](https://github.com/stegripe/rawon/blob/main/src/utils/structures/CommandManager.ts): `src/utils/structures/CommandManager.ts`
- [Multi-bot routing](https://github.com/stegripe/rawon/blob/main/src/utils/structures/MultiBotManager.ts): `src/utils/structures/MultiBotManager.ts`
- [Multi-bot launcher](https://github.com/stegripe/rawon/blob/main/src/utils/structures/MultiBotLauncher.ts): `src/utils/structures/MultiBotLauncher.ts`

### Discord commands

- [Command context](https://github.com/stegripe/rawon/blob/main/src/structures/CommandContext.ts): `src/structures/CommandContext.ts`
- [Play command](https://github.com/stegripe/rawon/blob/main/src/commands/music/PlayCommand.ts): `src/commands/music/PlayCommand.ts`
- [Music controls](https://github.com/stegripe/rawon/tree/main/src/commands/music): `src/commands/music`

### Music playback

- [Query classifier](https://github.com/stegripe/rawon/blob/main/src/utils/handlers/general/checkQuery.ts): `src/utils/handlers/general/checkQuery.ts`
- [Search and resolve](https://github.com/stegripe/rawon/tree/main/src/utils/handlers/general): `src/utils/handlers/general`
- [General music utility](https://github.com/stegripe/rawon/blob/main/src/utils/handlers/GeneralUtil.ts): `src/utils/handlers/GeneralUtil.ts`
- [Server queue](https://github.com/stegripe/rawon/blob/main/src/structures/ServerQueue.ts): `src/structures/ServerQueue.ts`
- [Song manager](https://github.com/stegripe/rawon/blob/main/src/utils/structures/SongManager.ts): `src/utils/structures/SongManager.ts`
- [Audio pre-cache](https://github.com/stegripe/rawon/blob/main/src/utils/structures/AudioCacheManager.ts): `src/utils/structures/AudioCacheManager.ts`
- [Voice playback](https://github.com/stegripe/rawon/blob/main/src/utils/handlers/YTDLUtil.ts): `src/utils/handlers/YTDLUtil.ts`

### State and routing

- [Request channel](https://github.com/stegripe/rawon/blob/main/src/utils/structures/RequestChannelManager.ts): `src/utils/structures/RequestChannelManager.ts`
- [SQLite data](https://github.com/stegripe/rawon/blob/main/src/utils/structures/SQLiteDataManager.ts): `src/utils/structures/SQLiteDataManager.ts`

### Media integrations

- [Google login](https://github.com/stegripe/rawon/blob/main/src/utils/structures/GoogleLoginManager.ts): `src/utils/structures/GoogleLoginManager.ts`
- **Music sources**

### Other components

- **Discord user**
- **Discord**
- **Google login site**

## Connections

- Discord user → Discord: sends command
- Discord → Message listener: delivers message
- Discord → Interaction listener: delivers interaction
- Message listener → Command manager: dispatches command
- Interaction listener → Command manager: dispatches command
- Command manager → Command context: builds context
- Command context → Play command: invokes
- Command context → Music controls: invokes
- Request channel → Music controls: offers controls
- Play command → Query classifier: classifies query
- Play command → Search and resolve: resolves request
- Search and resolve → Music sources: searches sources
- Play command → Server queue: queues tracks
- General music utility → Server queue: handles playback
- Server queue → Song manager: manages songs
- General music utility → Voice playback: streams audio
- Audio pre-cache → Music sources: fetches audio
- Multi-bot launcher → Multi-bot routing: coordinates bots
- Bot client → SQLite data: uses persistent data
- Google login → Google login site: authenticates
- Google login → SQLite data: stores session state
