# denis-rubtsov/discordchatbot architecture

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

- Interactive diagram: https://gitdiagram.com/denis-rubtsov/discordchatbot
- Repository: https://github.com/denis-rubtsov/discordchatbot

## Overview

DiscordChatBot is a Discord companion bot whose main workflow routes eligible messages to a conversational AI, then sends the response back to Discord while retaining channel history and per-member relationship notes. Separate branches handle images, moderation, reactions, newcomer greetings, opinions, and periodic interjections. Voice commands start a Realtime API session that bridges Discord audio. The excerpts show the main wiring and stores; several feature details are documented in the README but their full implementations were not sampled.

Main entry points: [`DiscordChatBot/DiscordBotService.cs`](https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/DiscordBotService.cs) (Bot service), [`DiscordChatBot/CatGirlAiService.cs`](https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/CatGirlAiService.cs) (Message replies), [`DiscordChatBot/VoiceChatService.cs`](https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/VoiceChatService.cs) (Voice audio bridge), [`DiscordChatBot/RelationshipStore.cs`](https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/RelationshipStore.cs) (Member relationships)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discord["Discord interaction"]
  node_discord_gateway{{"Discord gateway"}}
  node_bot["Bot service"]
end

subgraph group_text_ai["Text and AI features"]
  node_conversation["Message replies"]
  node_image["Image generation"]
  node_moderation["Rule checks"]
  node_social["Social features"]
end

subgraph group_memory["Persistent memory"]
  node_history[("Channel history<br/>[BotStateStore.cs]")]
  node_relationships[("Member relationships")]
end

subgraph group_voice["Voice conversation"]
  node_voice_commands["Voice commands"]
  node_voice_bridge["Voice audio bridge"]
end

node_members(("Discord members"))
node_openai{{"OpenAI chat and image APIs"}}
node_realtime{{"OpenAI Realtime API"}}

node_members -->|"send messages"| node_discord_gateway
node_discord_gateway -->|"dispatch events"| node_bot
node_bot -->|"request replies"| node_conversation
node_conversation -->|"request completions"| node_openai
node_bot -->|"send responses"| node_discord_gateway
node_conversation -->|"read history"| node_history
node_conversation -->|"read and update notes"| node_relationships
node_bot -->|"persist exchanges"| node_history
node_bot -->|"record members"| node_relationships
node_bot -->|"request image"| node_image
node_image -->|"generate image"| node_openai
node_bot -->|"check rules"| node_moderation
node_bot -->|"request social features"| node_social
node_members -->|"issue voice commands"| node_voice_commands
node_voice_commands -->|"join or leave"| node_voice_bridge
node_voice_bridge -->|"exchange audio"| node_realtime
node_voice_bridge -->|"read participant notes"| node_relationships

click node_bot "https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/DiscordBotService.cs"
click node_conversation "https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/CatGirlAiService.cs"
click node_image "https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/CatGirlAiService.cs"
click node_moderation "https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/CatGirlAiService.cs"
click node_social "https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/CatGirlAiService.cs"
click node_history "https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/BotStateStore.cs"
click node_relationships "https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/RelationshipStore.cs"
click node_voice_commands "https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/DiscordBotService.cs"
click node_voice_bridge "https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/VoiceChatService.cs"

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_discord_gateway,node_bot toneBlue
class node_conversation,node_image,node_moderation,node_social toneAmber
class node_history,node_relationships,node_openai,node_realtime toneMint
class node_voice_commands,node_voice_bridge toneRose
class node_members toneIndigo
```

## Components

### Discord interaction

- **Discord gateway**
- [Bot service](https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/DiscordBotService.cs): `DiscordChatBot/DiscordBotService.cs`

### Text and AI features

- [Message replies](https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/CatGirlAiService.cs): `DiscordChatBot/CatGirlAiService.cs`
- [Image generation](https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/CatGirlAiService.cs): `DiscordChatBot/CatGirlAiService.cs`
- [Rule checks](https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/CatGirlAiService.cs): `DiscordChatBot/CatGirlAiService.cs`
- [Social features](https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/CatGirlAiService.cs): `DiscordChatBot/CatGirlAiService.cs`

### Persistent memory

- [Channel history](https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/BotStateStore.cs): `DiscordChatBot/BotStateStore.cs`
- [Member relationships](https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/RelationshipStore.cs): `DiscordChatBot/RelationshipStore.cs`

### Voice conversation

- [Voice commands](https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/DiscordBotService.cs): `DiscordChatBot/DiscordBotService.cs`
- [Voice audio bridge](https://github.com/denis-rubtsov/discordchatbot/blob/main/DiscordChatBot/VoiceChatService.cs): `DiscordChatBot/VoiceChatService.cs`

### Other components

- **Discord members**
- **OpenAI chat and image APIs**
- **OpenAI Realtime API**

## Connections

- Discord members → Discord gateway: send messages (evidence: `README.md`)
- Discord gateway → Bot service: dispatch events
- Bot service → Message replies: request replies (evidence: `DiscordChatBot/DiscordBotService.cs`)
- Message replies → OpenAI chat and image APIs: request completions (evidence: `DiscordChatBot/CatGirlAiService.cs`)
- Bot service → Discord gateway: send responses (evidence: `README.md`)
- Message replies → Channel history: read history (evidence: `DiscordChatBot/CatGirlAiService.cs`)
- Message replies → Member relationships: read and update notes (evidence: `DiscordChatBot/CatGirlAiService.cs`)
- Bot service → Channel history: persist exchanges (evidence: `DiscordChatBot/DiscordBotService.cs`)
- Bot service → Member relationships: record members (evidence: `DiscordChatBot/DiscordBotService.cs`)
- Bot service → Image generation: request image (evidence: `DiscordChatBot/DiscordBotService.cs`)
- Image generation → OpenAI chat and image APIs: generate image (evidence: `DiscordChatBot/CatGirlAiService.cs`)
- Bot service → Rule checks: check rules (evidence: `README.md`)
- Bot service → Social features: request social features (evidence: `README.md`)
- Discord members → Voice commands: issue voice commands (evidence: `README.md`)
- Voice commands → Voice audio bridge: join or leave (evidence: `DiscordChatBot/DiscordBotService.cs`)
- Voice audio bridge → OpenAI Realtime API: exchange audio (evidence: `DiscordChatBot/VoiceChatService.cs`)
- Voice audio bridge → Member relationships: read participant notes (evidence: `DiscordChatBot/VoiceChatService.cs`)
