# hakkul/chat-group architecture

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

- Interactive diagram: https://gitdiagram.com/hakkul/chat-group
- Repository: https://github.com/hakkul/chat-group

## Overview

Group Chat is a no-login group messaging app: users create or browse groups, enter a group with a chosen or generated name, then exchange live messages. The browser separates group browsing, chat presentation, API access, and socket reconnection; the Worker serves group endpoints and dispatches room connections, while D1 stores group metadata and Durable Objects handle chat history, messages, and presence. The README documents these capabilities; source excerpts show the principal request and message paths.

Main entry points: [`worker/index.ts`](https://github.com/hakkul/chat-group/blob/main/worker/index.ts) (HTTP routes), [`src/views/ChatView.vue`](https://github.com/hakkul/chat-group/blob/main/src/views/ChatView.vue) (Chat interface), [`src/router/index.ts`](https://github.com/hakkul/chat-group/blob/main/src/router/index.ts) (Page routing), [`src/api.ts`](https://github.com/hakkul/chat-group/blob/main/src/api.ts) (HTTP and WS client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser application"]
  node_bootstrap["App bootstrap<br/>[main.ts]"]
  node_shell["App shell<br/>[App.vue]"]
  node_router["Page routing<br/>[index.ts]"]
  node_home["Group browser<br/>[HomeView.vue]"]
  node_chatview["Chat interface<br/>[ChatView.vue]"]
  node_username["Username state<br/>[useUsername.ts]"]
  node_socket["Socket client<br/>[useChatSocket.ts]"]
  node_clientapi["HTTP and WS client<br/>[api.ts]"]
end

subgraph group_http["Group API"]
  node_worker["HTTP routes<br/>[index.ts]"]
  node_validation["Group schema<br/>[index.ts]"]
end

subgraph group_realtime["Realtime chat"]
  node_room["Chat room<br/>[chat-room.ts]"]
end

subgraph group_storage["Persistence"]
  node_groupmodel["Group table<br/>[schema.ts]"]
  node_d1[("Group metadata")]
  node_roomstate[("Message history<br/>[chat-room.ts]")]
end

node_user(("User"))

node_bootstrap -->|"mounts"| node_shell
node_bootstrap -->|"installs"| node_router
node_shell -->|"renders"| node_router
node_router -->|"routes to"| node_home
node_router -->|"routes to"| node_chatview
node_user -->|"browses groups"| node_home
node_home -->|"calls"| node_clientapi
node_home -->|"navigates to"| node_router
node_user -->|"joins and chats"| node_chatview
node_chatview -->|"loads group"| node_clientapi
node_chatview -->|"uses"| node_username
node_username -->|"generates name"| node_clientapi
node_chatview -->|"controls connection"| node_socket
node_socket -->|"opens socket"| node_clientapi
node_clientapi -->|"requests API"| node_worker
node_worker -->|"validates input"| node_validation
node_worker -->|"queries table"| node_groupmodel
node_worker -->|"reads and writes"| node_d1
node_worker -->|"dispatches socket"| node_room
node_room -->|"reads and writes"| node_roomstate

click node_bootstrap "https://github.com/hakkul/chat-group/blob/main/src/main.ts"
click node_shell "https://github.com/hakkul/chat-group/blob/main/src/App.vue"
click node_router "https://github.com/hakkul/chat-group/blob/main/src/router/index.ts"
click node_home "https://github.com/hakkul/chat-group/blob/main/src/views/HomeView.vue"
click node_chatview "https://github.com/hakkul/chat-group/blob/main/src/views/ChatView.vue"
click node_username "https://github.com/hakkul/chat-group/blob/main/src/composables/useUsername.ts"
click node_socket "https://github.com/hakkul/chat-group/blob/main/src/composables/useChatSocket.ts"
click node_clientapi "https://github.com/hakkul/chat-group/blob/main/src/api.ts"
click node_worker "https://github.com/hakkul/chat-group/blob/main/worker/index.ts"
click node_validation "https://github.com/hakkul/chat-group/blob/main/worker/index.ts"
click node_groupmodel "https://github.com/hakkul/chat-group/blob/main/worker/schema.ts"
click node_room "https://github.com/hakkul/chat-group/blob/main/worker/chat-room.ts"
click node_roomstate "https://github.com/hakkul/chat-group/blob/main/worker/chat-room.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_bootstrap,node_shell,node_router,node_home,node_chatview,node_username,node_socket,node_clientapi,node_user toneBlue
class node_worker,node_validation toneAmber
class node_room toneMint
class node_groupmodel,node_d1,node_roomstate toneRose
```

## Components

### Browser application

- [App bootstrap](https://github.com/hakkul/chat-group/blob/main/src/main.ts): `src/main.ts`
- [App shell](https://github.com/hakkul/chat-group/blob/main/src/App.vue): `src/App.vue`
- [Page routing](https://github.com/hakkul/chat-group/blob/main/src/router/index.ts): `src/router/index.ts`
- [Group browser](https://github.com/hakkul/chat-group/blob/main/src/views/HomeView.vue): `src/views/HomeView.vue`
- [Chat interface](https://github.com/hakkul/chat-group/blob/main/src/views/ChatView.vue): `src/views/ChatView.vue`
- [Username state](https://github.com/hakkul/chat-group/blob/main/src/composables/useUsername.ts): `src/composables/useUsername.ts`
- [Socket client](https://github.com/hakkul/chat-group/blob/main/src/composables/useChatSocket.ts): `src/composables/useChatSocket.ts`
- [HTTP and WS client](https://github.com/hakkul/chat-group/blob/main/src/api.ts): `src/api.ts`

### Group API

- [HTTP routes](https://github.com/hakkul/chat-group/blob/main/worker/index.ts): `worker/index.ts`
- [Group schema](https://github.com/hakkul/chat-group/blob/main/worker/index.ts): `worker/index.ts`

### Realtime chat

- [Chat room](https://github.com/hakkul/chat-group/blob/main/worker/chat-room.ts): `worker/chat-room.ts`

### Persistence

- [Group table](https://github.com/hakkul/chat-group/blob/main/worker/schema.ts): `worker/schema.ts`
- **Group metadata**
- [Message history](https://github.com/hakkul/chat-group/blob/main/worker/chat-room.ts): `worker/chat-room.ts`

### Other components

- **User**

## Connections

- App bootstrap → App shell: mounts (evidence: `src/main.ts`)
- App bootstrap → Page routing: installs (evidence: `src/main.ts`)
- App shell → Page routing: renders (evidence: `src/App.vue`)
- Page routing → Group browser: routes to (evidence: `src/router/index.ts`)
- Page routing → Chat interface: routes to (evidence: `src/router/index.ts`)
- User → Group browser: browses groups (evidence: `README.md`)
- Group browser → HTTP and WS client: calls (evidence: `src/views/HomeView.vue`)
- Group browser → Page routing: navigates to (evidence: `src/views/HomeView.vue`)
- User → Chat interface: joins and chats (evidence: `README.md`)
- Chat interface → HTTP and WS client: loads group (evidence: `src/views/ChatView.vue`)
- Chat interface → Username state: uses (evidence: `src/views/ChatView.vue`)
- Username state → HTTP and WS client: generates name (evidence: `src/composables/useUsername.ts`)
- Chat interface → Socket client: controls connection (evidence: `src/views/ChatView.vue`)
- Socket client → HTTP and WS client: opens socket (evidence: `src/composables/useChatSocket.ts`)
- HTTP and WS client → HTTP routes: requests API (evidence: `src/api.ts`)
- HTTP routes → Group schema: validates input (evidence: `worker/index.ts`)
- HTTP routes → Group table: queries table (evidence: `worker/index.ts`)
- HTTP routes → Group metadata: reads and writes (evidence: `worker/index.ts`)
- HTTP routes → Chat room: dispatches socket (evidence: `worker/index.ts`)
- Chat room → Message history: reads and writes (evidence: `worker/chat-room.ts`)
