# karyych/websocket-dump architecture

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

- Interactive diagram: https://gitdiagram.com/karyych/websocket-dump
- Repository: https://github.com/karyych/websocket-dump

## Overview

WebSocket Dump is a small browser-based WebSocket testing console. A user connects the browser to `/chat` to exchange text or binary frames, while console controls invoke HTTP actions to broadcast messages, ping, or close active sessions. The Go server accepts and tracks connections, echoes client frames, and sends periodic pings. The README documents the UI and protocol capabilities; the sampled source shows the server routes and JavaScript wiring, but not the HTML implementation details.

Main entry points: [`static/main.js`](https://github.com/karyych/websocket-dump/blob/main/static/main.js) (Console controls), [`server.go`](https://github.com/karyych/websocket-dump/blob/main/server.go) (HTTP server), [`static/index.html`](https://github.com/karyych/websocket-dump/blob/main/static/index.html) (Console page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser console"]
  node_page["Console page<br/>[index.html]"]
  node_ui["Console controls<br/>[main.js]"]
end

subgraph group_server["Go server"]
  node_server_entry["HTTP server<br/>[server.go]"]
  node_chat["Chat handler<br/>[server.go]"]
  node_api_text["Text broadcast<br/>[server.go]"]
  node_api_long["Long-frame broadcast<br/>[server.go]"]
  node_api_binary["Binary broadcast<br/>[server.go]"]
  node_api_ping["Ping action<br/>[server.go]"]
  node_api_close["Close action<br/>[server.go]"]
end

subgraph group_sessions["WebSocket sessions"]
  node_registry["Client registry<br/>[server.go]"]
  node_session["WebSocket session<br/>[server.go]"]
  node_writer["Serialized writer<br/>[server.go]"]
end

node_user(("Tester"))

node_user -->|"uses"| node_page
node_page -.->|"loads controls"| node_ui
node_ui -->|"opens WebSocket"| node_chat
node_ui -->|"requests broadcast"| node_api_text
node_ui -->|"requests broadcast"| node_api_long
node_ui -->|"requests broadcast"| node_api_binary
node_ui -->|"requests ping"| node_api_ping
node_ui -->|"requests close"| node_api_close
node_server_entry -->|"routes &#96;/chat&#96;"| node_chat
node_server_entry -->|"routes HTTP"| node_api_text
node_server_entry -->|"routes HTTP"| node_api_long
node_server_entry -->|"routes HTTP"| node_api_binary
node_server_entry -->|"routes HTTP"| node_api_ping
node_server_entry -->|"routes HTTP"| node_api_close
node_chat -->|"registers session"| node_registry
node_chat -->|"accepts and reads"| node_session
node_chat -->|"echoes frames"| node_writer
node_chat -->|"sends periodic ping"| node_session
node_api_text -->|"iterates clients"| node_registry
node_api_long -->|"iterates clients"| node_registry
node_api_binary -->|"iterates clients"| node_registry
node_api_ping -->|"iterates clients"| node_registry
node_api_close -->|"iterates clients"| node_registry
node_api_text -->|"sends text"| node_writer
node_api_long -->|"sends long text"| node_writer
node_api_binary -->|"sends binary"| node_writer
node_api_ping -->|"pings clients"| node_session
node_api_close -->|"closes clients"| node_session

click node_page "https://github.com/karyych/websocket-dump/blob/main/static/index.html"
click node_ui "https://github.com/karyych/websocket-dump/blob/main/static/main.js"
click node_server_entry "https://github.com/karyych/websocket-dump/blob/main/server.go"
click node_chat "https://github.com/karyych/websocket-dump/blob/main/server.go"
click node_api_text "https://github.com/karyych/websocket-dump/blob/main/server.go"
click node_api_long "https://github.com/karyych/websocket-dump/blob/main/server.go"
click node_api_binary "https://github.com/karyych/websocket-dump/blob/main/server.go"
click node_api_ping "https://github.com/karyych/websocket-dump/blob/main/server.go"
click node_api_close "https://github.com/karyych/websocket-dump/blob/main/server.go"
click node_registry "https://github.com/karyych/websocket-dump/blob/main/server.go"
click node_session "https://github.com/karyych/websocket-dump/blob/main/server.go"
click node_writer "https://github.com/karyych/websocket-dump/blob/main/server.go"

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_page,node_ui toneBlue
class node_server_entry,node_chat,node_api_text,node_api_long,node_api_binary,node_api_ping,node_api_close toneAmber
class node_registry,node_session,node_writer toneMint
class node_user toneIndigo
```

## Components

### Browser console

- [Console page](https://github.com/karyych/websocket-dump/blob/main/static/index.html): `static/index.html`
- [Console controls](https://github.com/karyych/websocket-dump/blob/main/static/main.js): `static/main.js`

### Go server

- [HTTP server](https://github.com/karyych/websocket-dump/blob/main/server.go): `server.go`
- [Chat handler](https://github.com/karyych/websocket-dump/blob/main/server.go): `server.go`
- [Text broadcast](https://github.com/karyych/websocket-dump/blob/main/server.go): `server.go`
- [Long-frame broadcast](https://github.com/karyych/websocket-dump/blob/main/server.go): `server.go`
- [Binary broadcast](https://github.com/karyych/websocket-dump/blob/main/server.go): `server.go`
- [Ping action](https://github.com/karyych/websocket-dump/blob/main/server.go): `server.go`
- [Close action](https://github.com/karyych/websocket-dump/blob/main/server.go): `server.go`

### WebSocket sessions

- [Client registry](https://github.com/karyych/websocket-dump/blob/main/server.go): `server.go`
- [WebSocket session](https://github.com/karyych/websocket-dump/blob/main/server.go): `server.go`
- [Serialized writer](https://github.com/karyych/websocket-dump/blob/main/server.go): `server.go`

### Other components

- **Tester**

## Connections

- Tester → Console page: uses (evidence: `README.md`)
- Console page → Console controls: loads controls
- Console controls → Chat handler: opens WebSocket (evidence: `README.md`)
- Console controls → Text broadcast: requests broadcast (evidence: `static/main.js`)
- Console controls → Long-frame broadcast: requests broadcast (evidence: `static/main.js`)
- Console controls → Binary broadcast: requests broadcast (evidence: `static/main.js`)
- Console controls → Ping action: requests ping (evidence: `static/main.js`)
- Console controls → Close action: requests close (evidence: `static/main.js`)
- HTTP server → Chat handler: routes `/chat` (evidence: `server.go`)
- HTTP server → Text broadcast: routes HTTP (evidence: `server.go`)
- HTTP server → Long-frame broadcast: routes HTTP (evidence: `server.go`)
- HTTP server → Binary broadcast: routes HTTP (evidence: `server.go`)
- HTTP server → Ping action: routes HTTP (evidence: `server.go`)
- HTTP server → Close action: routes HTTP (evidence: `server.go`)
- Chat handler → Client registry: registers session (evidence: `server.go`)
- Chat handler → WebSocket session: accepts and reads (evidence: `server.go`)
- Chat handler → Serialized writer: echoes frames (evidence: `server.go`)
- Chat handler → WebSocket session: sends periodic ping (evidence: `server.go`)
- Text broadcast → Client registry: iterates clients (evidence: `server.go`)
- Long-frame broadcast → Client registry: iterates clients (evidence: `server.go`)
- Binary broadcast → Client registry: iterates clients (evidence: `server.go`)
- Ping action → Client registry: iterates clients (evidence: `server.go`)
- Close action → Client registry: iterates clients (evidence: `server.go`)
- Text broadcast → Serialized writer: sends text (evidence: `server.go`)
- Long-frame broadcast → Serialized writer: sends long text (evidence: `server.go`)
- Binary broadcast → Serialized writer: sends binary (evidence: `server.go`)
- Ping action → WebSocket session: pings clients (evidence: `server.go`)
- Close action → WebSocket session: closes clients (evidence: `server.go`)
