# antnygamer/twitchcraft architecture

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

- Interactive diagram: https://gitdiagram.com/antnygamer/twitchcraft
- Repository: https://github.com/antnygamer/twitchcraft

## Overview

TwitchCraft is a Windows desktop application that connects Twitch chat and viewer activity to a Minecraft server. The main flow is setup and Twitch authorization, start or attach to a server, receive chat/reward activity, execute configured gameplay commands, and maintain viewer tokens and statistics. The graph includes the documented remote-control option and major customization capabilities. Several runtime modules are unsampled, so uncertain links are omitted; README-backed relationships are identified as such.

Main entry points: [`TwitchCraft_SOURCE/Runtime/MainHandlerLifecycle.cs`](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/MainHandlerLifecycle.cs) (Session Lifecycle), [`TwitchCraft_SOURCE/Commands/CommandService.cs`](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Commands/CommandService.cs) (Command Dispatch), [`TwitchCraft_SOURCE/Runtime/MainHandlerState.cs`](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/MainHandlerState.cs) (Runtime Coordination), [`TwitchCraft_SOURCE/Tokens/TokenService.cs`](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Tokens/TokenService.cs) (Viewer Tokens)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Setup and UI"]
  node_setup_ui["Setup Screens<br/>[Setup.xaml.cs]"]
  node_settings_ui["Settings Editor<br/>[Settings.xaml.cs]"]
  node_oauth["Twitch Authorization"]
  node_server_prep["Server Preparation"]
  node_main_ui["Live Dashboard<br/>[Main.xaml.cs]"]
end

subgraph group_runtime["Session Runtime"]
  node_lifecycle["Session Lifecycle"]
  node_runtime_state["Runtime Coordination"]
  node_minecraft_runtime["Minecraft Runtime"]
  node_server_process["Server Process<br/>[ServerSession.cs]"]
  node_rcon["RCON Control"]
  node_query["Server Query"]
  node_player_monitor["Player Monitoring<br/>[PlayerMonitor.cs]"]
end

subgraph group_twitch["Twitch Integration"]
  node_twitch_runtime["Twitch Connection<br/>[TwitchRuntime.cs]"]
  node_irc_messages["IRC Messaging<br/>[TwitchMessages.cs]"]
  node_follow_rewards["Follow Rewards"]
end

subgraph group_gameplay["Commands and Gameplay"]
  node_command_service["Command Dispatch<br/>[CommandService.cs]"]
  node_gameplay_commands["Gameplay Commands<br/>[GameplayCore.cs]"]
  node_minigames["Minigames<br/>[MinigameSession.cs]"]
end

subgraph group_state["Persistent State"]
  node_config["Configuration"]
  node_token_service["Viewer Tokens<br/>[TokenService.cs]"]
  node_token_store[("Token Persistence<br/>[TokenStore.cs]")]
  node_statistics_service["Statistics"]
  node_statistics_store[("Statistics Persistence<br/>[StatisticsStore.cs]")]
end

node_streamer(("Streamer"))
node_chat(("Twitch Chat"))
node_minecraft["Minecraft Server"]

node_streamer -.->|"configures"| node_setup_ui
node_setup_ui -.->|"requests auth"| node_oauth
node_oauth -.->|"authorizes account"| node_streamer
node_setup_ui -.->|"saves settings"| node_config
node_settings_ui -.->|"updates settings"| node_config
node_lifecycle -->|"loads configuration"| node_config
node_lifecycle -->|"installs datapack"| node_server_prep
node_lifecycle -.->|"starts process"| node_server_process
node_lifecycle -->|"connects remotely"| node_rcon
node_lifecycle -.->|"coordinates runtime"| node_runtime_state
node_runtime_state -->|"creates service"| node_command_service
node_runtime_state -->|"creates service"| node_token_service
node_runtime_state -->|"creates service"| node_statistics_service
node_server_process -.->|"hosts world"| node_minecraft
node_rcon -.->|"sends commands"| node_minecraft
node_minecraft_runtime -.->|"queries server"| node_query
node_query -.->|"reads player status"| node_minecraft
node_player_monitor -.->|"probes players"| node_query
node_twitch_runtime -.->|"connects to"| node_chat
node_twitch_runtime -.->|"handles messages"| node_irc_messages
node_irc_messages -.->|"dispatches commands"| node_command_service
node_command_service -.->|"routes command"| node_gameplay_commands
node_command_service -.->|"routes minigame"| node_minigames
node_gameplay_commands -.->|"controls gameplay"| node_minecraft_runtime
node_command_service -.->|"checks balances"| node_token_service
node_follow_rewards -.->|"awards tokens"| node_token_service
node_token_service -->|"persists balances"| node_token_store
node_statistics_service -->|"persists statistics"| node_statistics_store
node_lifecycle -->|"starts session stats"| node_statistics_service
node_main_ui -.->|"sends commands"| node_lifecycle

click node_setup_ui "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Frames/Setup.xaml.cs"
click node_settings_ui "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Frames/Settings.xaml.cs"
click node_oauth "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Setup/TwitchOAuthAuthorizer.cs"
click node_config "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Setup/ConfigurationStore.cs"
click node_server_prep "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Setup/DatapackInstaller.cs"
click node_lifecycle "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/MainHandlerLifecycle.cs"
click node_runtime_state "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/MainHandlerState.cs"
click node_minecraft_runtime "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/Minecraft/MinecraftRuntime.cs"
click node_server_process "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/Minecraft/ServerSession.cs"
click node_rcon "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/Minecraft/MinecraftRCONClient.cs"
click node_query "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/Minecraft/MinecraftQueryClient.cs"
click node_player_monitor "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/Players/PlayerMonitor.cs"
click node_twitch_runtime "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/Twitch/TwitchRuntime.cs"
click node_irc_messages "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/Twitch/TwitchMessages.cs"
click node_follow_rewards "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/Twitch/TwitchFollowRewards.cs"
click node_command_service "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Commands/CommandService.cs"
click node_gameplay_commands "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Commands/GameplayCore.cs"
click node_minigames "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Commands/Minigames/MinigameSession.cs"
click node_token_service "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Tokens/TokenService.cs"
click node_token_store "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Tokens/TokenStore.cs"
click node_statistics_service "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Statistics/StatisticsService.cs"
click node_statistics_store "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Statistics/StatisticsStore.cs"
click node_main_ui "https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Frames/Main.xaml.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_setup_ui,node_settings_ui,node_oauth,node_server_prep,node_main_ui toneBlue
class node_lifecycle,node_runtime_state,node_minecraft_runtime,node_server_process,node_rcon,node_query,node_player_monitor toneAmber
class node_twitch_runtime,node_irc_messages,node_follow_rewards,node_minecraft toneMint
class node_command_service,node_gameplay_commands,node_minigames toneRose
class node_config,node_token_service,node_token_store,node_statistics_service,node_statistics_store,node_streamer,node_chat toneIndigo
```

## Components

### Setup and UI

- [Setup Screens](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Frames/Setup.xaml.cs): `TwitchCraft_SOURCE/Frames/Setup.xaml.cs`
- [Settings Editor](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Frames/Settings.xaml.cs): `TwitchCraft_SOURCE/Frames/Settings.xaml.cs`
- [Twitch Authorization](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Setup/TwitchOAuthAuthorizer.cs): `TwitchCraft_SOURCE/Setup/TwitchOAuthAuthorizer.cs`
- [Server Preparation](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Setup/DatapackInstaller.cs): `TwitchCraft_SOURCE/Setup/DatapackInstaller.cs`
- [Live Dashboard](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Frames/Main.xaml.cs): `TwitchCraft_SOURCE/Frames/Main.xaml.cs`

### Session Runtime

- [Session Lifecycle](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/MainHandlerLifecycle.cs): `TwitchCraft_SOURCE/Runtime/MainHandlerLifecycle.cs`
- [Runtime Coordination](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/MainHandlerState.cs): `TwitchCraft_SOURCE/Runtime/MainHandlerState.cs`
- [Minecraft Runtime](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/Minecraft/MinecraftRuntime.cs): `TwitchCraft_SOURCE/Runtime/Minecraft/MinecraftRuntime.cs`
- [Server Process](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/Minecraft/ServerSession.cs): `TwitchCraft_SOURCE/Runtime/Minecraft/ServerSession.cs`
- [RCON Control](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/Minecraft/MinecraftRCONClient.cs): `TwitchCraft_SOURCE/Runtime/Minecraft/MinecraftRCONClient.cs`
- [Server Query](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/Minecraft/MinecraftQueryClient.cs): `TwitchCraft_SOURCE/Runtime/Minecraft/MinecraftQueryClient.cs`
- [Player Monitoring](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/Players/PlayerMonitor.cs): `TwitchCraft_SOURCE/Runtime/Players/PlayerMonitor.cs`

### Twitch Integration

- [Twitch Connection](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/Twitch/TwitchRuntime.cs): `TwitchCraft_SOURCE/Runtime/Twitch/TwitchRuntime.cs`
- [IRC Messaging](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/Twitch/TwitchMessages.cs): `TwitchCraft_SOURCE/Runtime/Twitch/TwitchMessages.cs`
- [Follow Rewards](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Runtime/Twitch/TwitchFollowRewards.cs): `TwitchCraft_SOURCE/Runtime/Twitch/TwitchFollowRewards.cs`

### Commands and Gameplay

- [Command Dispatch](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Commands/CommandService.cs): `TwitchCraft_SOURCE/Commands/CommandService.cs`
- [Gameplay Commands](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Commands/GameplayCore.cs): `TwitchCraft_SOURCE/Commands/GameplayCore.cs`
- [Minigames](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Commands/Minigames/MinigameSession.cs): `TwitchCraft_SOURCE/Commands/Minigames/MinigameSession.cs`

### Persistent State

- [Configuration](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Setup/ConfigurationStore.cs): `TwitchCraft_SOURCE/Setup/ConfigurationStore.cs`
- [Viewer Tokens](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Tokens/TokenService.cs): `TwitchCraft_SOURCE/Tokens/TokenService.cs`
- [Token Persistence](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Tokens/TokenStore.cs): `TwitchCraft_SOURCE/Tokens/TokenStore.cs`
- [Statistics](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Statistics/StatisticsService.cs): `TwitchCraft_SOURCE/Statistics/StatisticsService.cs`
- [Statistics Persistence](https://github.com/antnygamer/twitchcraft/blob/main/TwitchCraft_SOURCE/Statistics/StatisticsStore.cs): `TwitchCraft_SOURCE/Statistics/StatisticsStore.cs`

### Other components

- **Streamer**
- **Twitch Chat**
- **Minecraft Server**

## Connections

- Streamer → Setup Screens: configures
- Setup Screens → Twitch Authorization: requests auth
- Twitch Authorization → Streamer: authorizes account
- Setup Screens → Configuration: saves settings
- Settings Editor → Configuration: updates settings
- Session Lifecycle → Configuration: loads configuration (evidence: `TwitchCraft_SOURCE/Runtime/MainHandlerLifecycle.cs`)
- Session Lifecycle → Server Preparation: installs datapack (evidence: `TwitchCraft_SOURCE/Runtime/MainHandlerLifecycle.cs`)
- Session Lifecycle → Server Process: starts process
- Session Lifecycle → RCON Control: connects remotely (evidence: `TwitchCraft_SOURCE/Runtime/MainHandlerLifecycle.cs`)
- Session Lifecycle → Runtime Coordination: coordinates runtime (evidence: `TwitchCraft_SOURCE/Runtime/MainHandlerState.cs`)
- Runtime Coordination → Command Dispatch: creates service (evidence: `TwitchCraft_SOURCE/Runtime/MainHandlerState.cs`)
- Runtime Coordination → Viewer Tokens: creates service (evidence: `TwitchCraft_SOURCE/Runtime/MainHandlerState.cs`)
- Runtime Coordination → Statistics: creates service (evidence: `TwitchCraft_SOURCE/Runtime/MainHandlerState.cs`)
- Server Process → Minecraft Server: hosts world
- RCON Control → Minecraft Server: sends commands
- Minecraft Runtime → Server Query: queries server
- Server Query → Minecraft Server: reads player status
- Player Monitoring → Server Query: probes players
- Twitch Connection → Twitch Chat: connects to
- Twitch Connection → IRC Messaging: handles messages
- IRC Messaging → Command Dispatch: dispatches commands
- Command Dispatch → Gameplay Commands: routes command
- Command Dispatch → Minigames: routes minigame
- Gameplay Commands → Minecraft Runtime: controls gameplay
- Command Dispatch → Viewer Tokens: checks balances
- Follow Rewards → Viewer Tokens: awards tokens
- Viewer Tokens → Token Persistence: persists balances (evidence: `TwitchCraft_SOURCE/Tokens/TokenService.cs`)
- Statistics → Statistics Persistence: persists statistics (evidence: `TwitchCraft_SOURCE/Statistics/StatisticsService.cs`)
- Session Lifecycle → Statistics: starts session stats (evidence: `TwitchCraft_SOURCE/Runtime/MainHandlerLifecycle.cs`)
- Live Dashboard → Session Lifecycle: sends commands (evidence: `TwitchCraft_SOURCE/Frames/Main.xaml.cs`)
