# jimhasaburger/youtube-chat-vm architecture

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

- Interactive diagram: https://gitdiagram.com/jimhasaburger/youtube-chat-vm
- Repository: https://github.com/jimhasaburger/youtube-chat-vm

## Overview

youtube-chat-vm is a lightweight YouTube live-chat-to-Windows-VM controller. Its main workflow fetches chat messages, broadcasts them to a browser overlay, and dispatches `!` commands to keyboard, mouse, or VM operations. The browser reconnects to the WebSocket and renders message history and live updates. README capabilities are represented at the command-dispatch level; sampled excerpts show representative command implementations, but not every command or VM lifecycle routine. The repository is small, so several responsibilities share `main.py`.

Main entry points: [`main.py`](https://github.com/jimhasaburger/youtube-chat-vm/blob/main/main.py) (Fetch chat), [`static/script.js`](https://github.com/jimhasaburger/youtube-chat-vm/blob/main/static/script.js) (Overlay rendering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_chat["Chat ingestion"]
  node_chat_fetch["Fetch chat<br/>[main.py]"]
  node_chat_history["Message history<br/>[main.py]"]
end

subgraph group_control["Command and VM control"]
  node_command_dispatch["Command dispatch<br/>[main.py]"]
  node_input_commands["Input commands<br/>[main.py]"]
  node_vm_commands["VM commands<br/>[main.py]"]
  node_vm_input["VM keyboard and mouse<br/>[main.py]"]
end

subgraph group_overlay["Chat overlay"]
  node_websocket["WebSocket service<br/>[main.py]"]
  node_overlay_client["Overlay rendering<br/>[script.js]"]
end

node_youtube(("YouTube chat"))
node_virtualbox["VirtualBox VM"]
node_browser(("Overlay browser"))

node_chat_fetch -->|"fetches messages"| node_youtube
node_chat_fetch -->|"records messages"| node_chat_history
node_chat_fetch -->|"dispatches commands"| node_command_dispatch
node_command_dispatch -->|"routes input"| node_input_commands
node_command_dispatch -->|"routes VM actions"| node_vm_commands
node_input_commands -->|"sends keystrokes"| node_vm_input
node_vm_commands -->|"controls VM"| node_virtualbox
node_vm_input -->|"sends input"| node_virtualbox
node_websocket -->|"sends history"| node_chat_history
node_websocket -->|"pushes chat events"| node_browser
node_browser -->|"loads overlay"| node_overlay_client
node_overlay_client -->|"connects to /ws"| node_websocket

click node_chat_fetch "https://github.com/jimhasaburger/youtube-chat-vm/blob/main/main.py"
click node_chat_history "https://github.com/jimhasaburger/youtube-chat-vm/blob/main/main.py"
click node_command_dispatch "https://github.com/jimhasaburger/youtube-chat-vm/blob/main/main.py"
click node_input_commands "https://github.com/jimhasaburger/youtube-chat-vm/blob/main/main.py"
click node_vm_commands "https://github.com/jimhasaburger/youtube-chat-vm/blob/main/main.py"
click node_vm_input "https://github.com/jimhasaburger/youtube-chat-vm/blob/main/main.py"
click node_websocket "https://github.com/jimhasaburger/youtube-chat-vm/blob/main/main.py"
click node_overlay_client "https://github.com/jimhasaburger/youtube-chat-vm/blob/main/static/script.js"

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_chat_fetch,node_chat_history,node_browser toneBlue
class node_command_dispatch,node_input_commands,node_vm_commands,node_vm_input toneAmber
class node_websocket,node_overlay_client toneMint
class node_youtube,node_virtualbox toneIndigo
```

## Components

### Chat ingestion

- [Fetch chat](https://github.com/jimhasaburger/youtube-chat-vm/blob/main/main.py): `main.py`
- [Message history](https://github.com/jimhasaburger/youtube-chat-vm/blob/main/main.py): `main.py`

### Command and VM control

- [Command dispatch](https://github.com/jimhasaburger/youtube-chat-vm/blob/main/main.py): `main.py`
- [Input commands](https://github.com/jimhasaburger/youtube-chat-vm/blob/main/main.py): `main.py`
- [VM commands](https://github.com/jimhasaburger/youtube-chat-vm/blob/main/main.py): `main.py`
- [VM keyboard and mouse](https://github.com/jimhasaburger/youtube-chat-vm/blob/main/main.py): `main.py`

### Chat overlay

- [WebSocket service](https://github.com/jimhasaburger/youtube-chat-vm/blob/main/main.py): `main.py`
- [Overlay rendering](https://github.com/jimhasaburger/youtube-chat-vm/blob/main/static/script.js): `static/script.js`

### Other components

- **YouTube chat**
- **VirtualBox VM**
- **Overlay browser**

## Connections

- Fetch chat → YouTube chat: fetches messages (evidence: `main.py`)
- Fetch chat → Message history: records messages (evidence: `main.py`)
- Fetch chat → Command dispatch: dispatches commands (evidence: `main.py`)
- Command dispatch → Input commands: routes input (evidence: `main.py`)
- Command dispatch → VM commands: routes VM actions (evidence: `main.py`)
- Input commands → VM keyboard and mouse: sends keystrokes (evidence: `main.py`)
- VM commands → VirtualBox VM: controls VM (evidence: `main.py`)
- VM keyboard and mouse → VirtualBox VM: sends input (evidence: `main.py`)
- WebSocket service → Message history: sends history (evidence: `main.py`)
- WebSocket service → Overlay browser: pushes chat events (evidence: `main.py`)
- Overlay browser → Overlay rendering: loads overlay (evidence: `static/script.js`)
- Overlay rendering → WebSocket service: connects to /ws (evidence: `static/script.js`)
