# vardhan-billakanti/doomchat architecture

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

- Interactive diagram: https://gitdiagram.com/vardhan-billakanti/doomchat
- Repository: https://github.com/vardhan-billakanti/doomchat

## Overview

DoomChat is an account-free, ephemeral group chat. Users create or join a room, connect over WebSockets, exchange messages and typing/participant updates, then leave or disband the room. The React app coordinates this flow; the Worker routes API and socket requests to one Durable Object per room. The README documents room ownership, broadcasts, inactivity alarms, and ephemeral room behavior. Edges reflect shown imports/calls or README architecture; some Durable Object capabilities are documented but their detailed implementation was not sampled.

Main entry points: [`frontend/src/App.tsx`](https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/App.tsx) (App state machine), [`frontend/src/components/ChatRoom.tsx`](https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/ChatRoom.tsx) (Chat room view), [`worker/src/ChatRoom.ts`](https://github.com/vardhan-billakanti/doomchat/blob/main/worker/src/ChatRoom.ts) (Room Durable Object), [`frontend/src/hooks/useChatRoom.ts`](https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/hooks/useChatRoom.ts) (Room state hook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React client"]
  node_app["App state machine<br/>[App.tsx]"]
end

subgraph group_room_flow["Room entry"]
  node_landing["Landing page<br/>[LandingPage.tsx]"]
  node_create["Create room form<br/>[CreateRoom.tsx]"]
  node_join["Join room form<br/>[JoinRoom.tsx]"]
  node_room_created["Room code sharing<br/>[RoomCreated.tsx]"]
  node_api_urls["API URL config<br/>[api.ts]"]
end

subgraph group_realtime["Realtime rooms"]
  node_chat_ui["Chat room view<br/>[ChatRoom.tsx]"]
  node_chat_hook["Room state hook<br/>[useChatRoom.ts]"]
  node_websocket_hook["WebSocket client<br/>[useWebSocket.ts]"]
  node_crypto["Message encryption<br/>[crypto.ts]"]
  node_message_input["Message input<br/>[MessageInput.tsx]"]
  node_message_list["Message history view<br/>[MessageList.tsx]"]
  node_participant_list["Participant list"]
  node_typing_view["Typing indicator"]
  node_connection_status["Connection status"]
  node_confirm_modal["Leave/disband confirm<br/>[ConfirmModal.tsx]"]
  node_room_object["Room Durable Object<br/>[ChatRoom.ts]"]
end

subgraph group_server_support["Worker services"]
  node_worker["Worker router<br/>[index.ts]"]
  node_validation["Validation and sanitizing<br/>[validation.ts]"]
  node_rate_limit["Rate limiter<br/>[rateLimit.ts]"]
end

node_user(("Chat participant"))

node_user -->|"opens chat"| node_app
node_app -->|"shows"| node_landing
node_app -->|"routes to"| node_create
node_app -->|"routes to"| node_join
node_app -->|"shows"| node_room_created
node_app -->|"shows"| node_chat_ui
node_landing -.->|"chooses create/join"| node_app
node_create -->|"builds API request"| node_api_urls
node_join -->|"builds API request"| node_api_urls
node_create -->|"returns room details"| node_app
node_join -->|"returns joined room"| node_app
node_api_urls -->|"targets API"| node_worker
node_worker -->|"routes room requests"| node_room_object
node_worker -->|"validates and generates"| node_validation
node_room_object -->|"uses utilities"| node_validation
node_room_object -->|"limits messages"| node_rate_limit
node_room_object -->|"broadcasts room events"| node_user
node_room_object -->|"manages room lifecycle"| node_room_object
node_chat_ui -->|"reads room state"| node_chat_hook
node_chat_ui -->|"renders"| node_message_input
node_chat_ui -->|"renders"| node_message_list
node_chat_ui -->|"renders"| node_participant_list
node_chat_ui -->|"renders"| node_typing_view
node_chat_ui -->|"renders"| node_connection_status
node_chat_ui -->|"renders"| node_confirm_modal
node_chat_hook -->|"manages connection"| node_websocket_hook
node_chat_hook -->|"encrypts/decrypts messages"| node_crypto
node_websocket_hook -->|"builds socket URL"| node_api_urls
node_websocket_hook -->|"opens WebSocket"| node_worker
node_message_input -->|"sends message/typing"| node_chat_hook
node_chat_hook -.->|"supplies messages"| node_message_list
node_confirm_modal -.->|"confirms leave/disband"| node_chat_hook

click node_app "https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/App.tsx"
click node_landing "https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/LandingPage.tsx"
click node_create "https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/CreateRoom.tsx"
click node_join "https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/JoinRoom.tsx"
click node_room_created "https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/RoomCreated.tsx"
click node_api_urls "https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/lib/api.ts"
click node_chat_ui "https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/ChatRoom.tsx"
click node_chat_hook "https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/hooks/useChatRoom.ts"
click node_websocket_hook "https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/hooks/useWebSocket.ts"
click node_crypto "https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/lib/crypto.ts"
click node_message_input "https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/MessageInput.tsx"
click node_message_list "https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/MessageList.tsx"
click node_participant_list "https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/ParticipantList.tsx"
click node_typing_view "https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/TypingIndicator.tsx"
click node_connection_status "https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/ConnectionStatus.tsx"
click node_confirm_modal "https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/ConfirmModal.tsx"
click node_worker "https://github.com/vardhan-billakanti/doomchat/blob/main/worker/src/index.ts"
click node_room_object "https://github.com/vardhan-billakanti/doomchat/blob/main/worker/src/ChatRoom.ts"
click node_validation "https://github.com/vardhan-billakanti/doomchat/blob/main/worker/src/validation.ts"
click node_rate_limit "https://github.com/vardhan-billakanti/doomchat/blob/main/worker/src/rateLimit.ts"

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_app toneBlue
class node_landing,node_create,node_join,node_room_created,node_api_urls toneAmber
class node_chat_ui,node_chat_hook,node_websocket_hook,node_crypto,node_message_input,node_message_list,node_participant_list,node_typing_view,node_connection_status,node_confirm_modal,node_room_object toneMint
class node_worker,node_validation,node_rate_limit toneRose
class node_user toneIndigo
```

## Components

### React client

- [App state machine](https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`

### Room entry

- [Landing page](https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/LandingPage.tsx): `frontend/src/components/LandingPage.tsx`
- [Create room form](https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/CreateRoom.tsx): `frontend/src/components/CreateRoom.tsx`
- [Join room form](https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/JoinRoom.tsx): `frontend/src/components/JoinRoom.tsx`
- [Room code sharing](https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/RoomCreated.tsx): `frontend/src/components/RoomCreated.tsx`
- [API URL config](https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### Realtime rooms

- [Chat room view](https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/ChatRoom.tsx): `frontend/src/components/ChatRoom.tsx`
- [Room state hook](https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/hooks/useChatRoom.ts): `frontend/src/hooks/useChatRoom.ts`
- [WebSocket client](https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/hooks/useWebSocket.ts): `frontend/src/hooks/useWebSocket.ts`
- [Message encryption](https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/lib/crypto.ts): `frontend/src/lib/crypto.ts`
- [Message input](https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/MessageInput.tsx): `frontend/src/components/MessageInput.tsx`
- [Message history view](https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/MessageList.tsx): `frontend/src/components/MessageList.tsx`
- [Participant list](https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/ParticipantList.tsx): `frontend/src/components/ParticipantList.tsx`
- [Typing indicator](https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/TypingIndicator.tsx): `frontend/src/components/TypingIndicator.tsx`
- [Connection status](https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/ConnectionStatus.tsx): `frontend/src/components/ConnectionStatus.tsx`
- [Leave/disband confirm](https://github.com/vardhan-billakanti/doomchat/blob/main/frontend/src/components/ConfirmModal.tsx): `frontend/src/components/ConfirmModal.tsx`
- [Room Durable Object](https://github.com/vardhan-billakanti/doomchat/blob/main/worker/src/ChatRoom.ts): `worker/src/ChatRoom.ts`

### Worker services

- [Worker router](https://github.com/vardhan-billakanti/doomchat/blob/main/worker/src/index.ts): `worker/src/index.ts`
- [Validation and sanitizing](https://github.com/vardhan-billakanti/doomchat/blob/main/worker/src/validation.ts): `worker/src/validation.ts`
- [Rate limiter](https://github.com/vardhan-billakanti/doomchat/blob/main/worker/src/rateLimit.ts): `worker/src/rateLimit.ts`

### Other components

- **Chat participant**

## Connections

- Chat participant → App state machine: opens chat (evidence: `README.md`)
- App state machine → Landing page: shows (evidence: `frontend/src/App.tsx`)
- App state machine → Create room form: routes to (evidence: `frontend/src/App.tsx`)
- App state machine → Join room form: routes to (evidence: `frontend/src/App.tsx`)
- App state machine → Room code sharing: shows (evidence: `frontend/src/App.tsx`)
- App state machine → Chat room view: shows (evidence: `frontend/src/App.tsx`)
- Landing page → App state machine: chooses create/join (evidence: `frontend/src/App.tsx`)
- Create room form → API URL config: builds API request (evidence: `frontend/src/components/CreateRoom.tsx`)
- Join room form → API URL config: builds API request (evidence: `frontend/src/components/JoinRoom.tsx`)
- Create room form → App state machine: returns room details (evidence: `frontend/src/App.tsx`)
- Join room form → App state machine: returns joined room (evidence: `frontend/src/App.tsx`)
- API URL config → Worker router: targets API (evidence: `README.md`)
- Worker router → Room Durable Object: routes room requests (evidence: `worker/src/index.ts`)
- Worker router → Validation and sanitizing: validates and generates (evidence: `worker/src/index.ts`)
- Room Durable Object → Validation and sanitizing: uses utilities (evidence: `worker/src/ChatRoom.ts`)
- Room Durable Object → Rate limiter: limits messages (evidence: `worker/src/ChatRoom.ts`)
- Room Durable Object → Chat participant: broadcasts room events (evidence: `README.md`)
- Room Durable Object → Room Durable Object: manages room lifecycle (evidence: `README.md`)
- Chat room view → Room state hook: reads room state (evidence: `frontend/src/components/ChatRoom.tsx`)
- Chat room view → Message input: renders (evidence: `frontend/src/components/ChatRoom.tsx`)
- Chat room view → Message history view: renders (evidence: `frontend/src/components/ChatRoom.tsx`)
- Chat room view → Participant list: renders (evidence: `frontend/src/components/ChatRoom.tsx`)
- Chat room view → Typing indicator: renders (evidence: `frontend/src/components/ChatRoom.tsx`)
- Chat room view → Connection status: renders (evidence: `frontend/src/components/ChatRoom.tsx`)
- Chat room view → Leave/disband confirm: renders (evidence: `frontend/src/components/ChatRoom.tsx`)
- Room state hook → WebSocket client: manages connection (evidence: `frontend/src/hooks/useChatRoom.ts`)
- Room state hook → Message encryption: encrypts/decrypts messages (evidence: `frontend/src/hooks/useChatRoom.ts`)
- WebSocket client → API URL config: builds socket URL (evidence: `frontend/src/hooks/useWebSocket.ts`)
- WebSocket client → Worker router: opens WebSocket (evidence: `README.md`)
- Message input → Room state hook: sends message/typing (evidence: `frontend/src/components/ChatRoom.tsx`)
- Room state hook → Message history view: supplies messages
- Leave/disband confirm → Room state hook: confirms leave/disband
