# chillbroz005/chat_room architecture

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

- Interactive diagram: https://gitdiagram.com/chillbroz005/chat_room
- Repository: https://github.com/chillbroz005/chat_room

## Overview

Husky Chat Room is a temporary, browser-based chat application. Users create or join rooms, exchange messages and rich content, and can use moderation and account features; the Pages API handles requests and persists state in D1. WebSockets carry room and room-list invalidations through a separate Durable Object worker. The graph preserves README-documented capabilities even where their handlers were not excerpted; those links cite the README. Source excerpts confirm account persistence, Telegram reply handling, and realtime-worker behavior.

Main entry points: [`functions/api/[[path]].js`](https://github.com/chillbroz005/chat_room/blob/main/functions/api/%5B%5Bpath%5D%5D.js) (API request handling), [`app.js`](https://github.com/chillbroz005/chat_room/blob/main/app.js) (Chat interface), [`realtime-worker.js`](https://github.com/chillbroz005/chat_room/blob/main/realtime-worker.js) (WebSocket hub), [`migrations`](https://github.com/chillbroz005/chat_room/tree/main/migrations) (D1 schema)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser client"]
  node_frontend["Chat interface<br/>[app.js]"]
  node_room_ui["Room interactions<br/>[app.js]"]
  node_account_ui["Account interactions<br/>[app.js]"]
end

subgraph group_api["Pages API"]
  node_pages_api["API request handling<br/>[&#91;&#91;path&#93;&#93;.js]"]
  node_identity["Browser identity<br/>[&#91;&#91;path&#93;&#93;.js]"]
  node_room_ops["Room management<br/>[&#91;&#91;path&#93;&#93;.js]"]
  node_chat_ops["Chat and activity<br/>[&#91;&#91;path&#93;&#93;.js]"]
  node_moderation["Moderation controls<br/>[&#91;&#91;path&#93;&#93;.js]"]
  node_accounts["Account authentication<br/>[&#91;&#91;path&#93;&#93;.js]"]
  node_telegram_handler["Telegram webhook<br/>[&#91;&#91;path&#93;&#93;.js]"]
  node_schema["D1 schema"]
end

subgraph group_realtime["Realtime delivery"]
  node_realtime_worker["WebSocket hub<br/>[realtime-worker.js]"]
  node_durable_state[("Durable Object state<br/>[realtime-worker.js]")]
end

subgraph group_integrations["External services"]
  node_d1[("Cloudflare D1")]
  node_giphy["GIPHY API"]
  node_telegram["Telegram Bot API"]
end

node_browser(("Room participants"))

node_browser -->|"uses"| node_frontend
node_frontend -->|"requests"| node_pages_api
node_frontend -->|"opens WebSocket"| node_realtime_worker
node_frontend -->|"renders"| node_room_ui
node_frontend -->|"renders"| node_account_ui
node_room_ui -->|"requests room actions"| node_pages_api
node_account_ui -->|"requests account actions"| node_pages_api
node_room_ui -->|"searches GIFs"| node_giphy
node_pages_api -->|"issues sessions"| node_identity
node_pages_api -->|"handles room actions"| node_room_ops
node_pages_api -->|"handles chat actions"| node_chat_ops
node_pages_api -->|"handles moderation"| node_moderation
node_pages_api -->|"handles sign-in"| node_accounts
node_pages_api -->|"routes webhook"| node_telegram_handler
node_room_ops -->|"stores room data"| node_d1
node_chat_ops -->|"stores messages"| node_d1
node_moderation -->|"stores activity"| node_d1
node_accounts -->|"reads and writes accounts"| node_d1
node_schema -->|"defines schema"| node_d1
node_pages_api -->|"publishes invalidations"| node_realtime_worker
node_realtime_worker -->|"accepts sockets"| node_durable_state
node_realtime_worker -->|"broadcasts invalidations"| node_frontend
node_telegram_handler -->|"reads rooms and writes replies"| node_d1
node_telegram_handler -->|"sends notices"| node_telegram
node_telegram -->|"delivers webhook"| node_telegram_handler

click node_frontend "https://github.com/chillbroz005/chat_room/blob/main/app.js"
click node_room_ui "https://github.com/chillbroz005/chat_room/blob/main/app.js"
click node_account_ui "https://github.com/chillbroz005/chat_room/blob/main/app.js"
click node_pages_api "https://github.com/chillbroz005/chat_room/blob/main/functions/api/%5B%5Bpath%5D%5D.js"
click node_identity "https://github.com/chillbroz005/chat_room/blob/main/functions/api/%5B%5Bpath%5D%5D.js"
click node_room_ops "https://github.com/chillbroz005/chat_room/blob/main/functions/api/%5B%5Bpath%5D%5D.js"
click node_chat_ops "https://github.com/chillbroz005/chat_room/blob/main/functions/api/%5B%5Bpath%5D%5D.js"
click node_moderation "https://github.com/chillbroz005/chat_room/blob/main/functions/api/%5B%5Bpath%5D%5D.js"
click node_accounts "https://github.com/chillbroz005/chat_room/blob/main/functions/api/%5B%5Bpath%5D%5D.js"
click node_telegram_handler "https://github.com/chillbroz005/chat_room/blob/main/functions/api/%5B%5Bpath%5D%5D.js"
click node_schema "https://github.com/chillbroz005/chat_room/tree/main/migrations"
click node_realtime_worker "https://github.com/chillbroz005/chat_room/blob/main/realtime-worker.js"
click node_durable_state "https://github.com/chillbroz005/chat_room/blob/main/realtime-worker.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_frontend,node_room_ui,node_account_ui toneBlue
class node_pages_api,node_identity,node_room_ops,node_chat_ops,node_moderation,node_accounts,node_telegram_handler,node_schema toneAmber
class node_realtime_worker,node_durable_state toneMint
class node_d1,node_giphy,node_telegram toneRose
class node_browser toneIndigo
```

## Components

### Browser client

- [Chat interface](https://github.com/chillbroz005/chat_room/blob/main/app.js): `app.js`
- [Room interactions](https://github.com/chillbroz005/chat_room/blob/main/app.js): `app.js`
- [Account interactions](https://github.com/chillbroz005/chat_room/blob/main/app.js): `app.js`

### Pages API

- [API request handling](https://github.com/chillbroz005/chat_room/blob/main/functions/api/%5B%5Bpath%5D%5D.js): `functions/api/[[path]].js`
- [Browser identity](https://github.com/chillbroz005/chat_room/blob/main/functions/api/%5B%5Bpath%5D%5D.js): `functions/api/[[path]].js`
- [Room management](https://github.com/chillbroz005/chat_room/blob/main/functions/api/%5B%5Bpath%5D%5D.js): `functions/api/[[path]].js`
- [Chat and activity](https://github.com/chillbroz005/chat_room/blob/main/functions/api/%5B%5Bpath%5D%5D.js): `functions/api/[[path]].js`
- [Moderation controls](https://github.com/chillbroz005/chat_room/blob/main/functions/api/%5B%5Bpath%5D%5D.js): `functions/api/[[path]].js`
- [Account authentication](https://github.com/chillbroz005/chat_room/blob/main/functions/api/%5B%5Bpath%5D%5D.js): `functions/api/[[path]].js`
- [Telegram webhook](https://github.com/chillbroz005/chat_room/blob/main/functions/api/%5B%5Bpath%5D%5D.js): `functions/api/[[path]].js`
- [D1 schema](https://github.com/chillbroz005/chat_room/tree/main/migrations): `migrations`

### Realtime delivery

- [WebSocket hub](https://github.com/chillbroz005/chat_room/blob/main/realtime-worker.js): `realtime-worker.js`
- [Durable Object state](https://github.com/chillbroz005/chat_room/blob/main/realtime-worker.js): `realtime-worker.js`

### External services

- **Cloudflare D1**
- **GIPHY API**
- **Telegram Bot API**

### Other components

- **Room participants**

## Connections

- Room participants → Chat interface: uses (evidence: `README.md`)
- Chat interface → API request handling: requests (evidence: `README.md`)
- Chat interface → WebSocket hub: opens WebSocket (evidence: `README.md`)
- Chat interface → Room interactions: renders (evidence: `app.js`)
- Chat interface → Account interactions: renders (evidence: `app.js`)
- Room interactions → API request handling: requests room actions (evidence: `README.md`)
- Account interactions → API request handling: requests account actions (evidence: `README.md`)
- Room interactions → GIPHY API: searches GIFs (evidence: `README.md`)
- API request handling → Browser identity: issues sessions (evidence: `README.md`)
- API request handling → Room management: handles room actions (evidence: `README.md`)
- API request handling → Chat and activity: handles chat actions (evidence: `README.md`)
- API request handling → Moderation controls: handles moderation (evidence: `README.md`)
- API request handling → Account authentication: handles sign-in (evidence: `functions/api/[[path]].js`)
- API request handling → Telegram webhook: routes webhook (evidence: `README.md`)
- Room management → Cloudflare D1: stores room data (evidence: `README.md`)
- Chat and activity → Cloudflare D1: stores messages (evidence: `README.md`)
- Moderation controls → Cloudflare D1: stores activity (evidence: `README.md`)
- Account authentication → Cloudflare D1: reads and writes accounts (evidence: `functions/api/[[path]].js`)
- D1 schema → Cloudflare D1: defines schema (evidence: `README.md`)
- API request handling → WebSocket hub: publishes invalidations (evidence: `README.md`)
- WebSocket hub → Durable Object state: accepts sockets (evidence: `realtime-worker.js`)
- WebSocket hub → Chat interface: broadcasts invalidations (evidence: `README.md`)
- Telegram webhook → Cloudflare D1: reads rooms and writes replies (evidence: `functions/api/[[path]].js`)
- Telegram webhook → Telegram Bot API: sends notices (evidence: `functions/api/[[path]].js`)
- Telegram Bot API → Telegram webhook: delivers webhook (evidence: `README.md`)
