# liyuanjie0808/home-chat_localareanetworkchat architecture

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

- Interactive diagram: https://gitdiagram.com/liyuanjie0808/home-chat_localareanetworkchat
- Repository: https://github.com/liyuanjie0808/home-chat_localareanetworkchat

## Overview

Home Chat is a self-hosted, LAN-only family messaging application: household members connect from a browser to a Mac-hosted service, authenticate, and exchange messages and media without cloud storage. The principal flow runs from the shared web client through its network layer to the server’s WebSocket hub, which authenticates devices, dispatches messaging operations, and persists chat state. The README also documents group chats, archive recovery, monitoring and device approval, local media relay, discovery, and mobile-specific security and notification features. Unsampled subsystem wiring is shown only where documented.

Main entry points: [`app/js/app.js`](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/app.js) (Chat application), [`server/src/index.js`](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/index.js) (Service entry), [`server/src/hub.js`](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/hub.js) (Message hub), [`app/js/net.js`](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/net.js) (Client networking)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_webapp["Chat application<br/>[app.js]"]
  node_ui["Chat interface<br/>[ui.js]"]
  node_clientnet["Client networking<br/>[net.js]"]
  node_clientstore["Client data<br/>[store.js]"]
  node_media["Media handling<br/>[media.js]"]
  node_clientcrypto["Client encryption<br/>[hc1.js]"]
  node_session["Session restore<br/>[session.js]"]
  node_security["Device protection<br/>[secure.js]"]
  node_notifications["Notifications<br/>[notify.js]"]
  node_archive["Archive recovery<br/>[archive.js]"]
end

subgraph group_service["Chat service"]
  node_server["Service entry<br/>[index.js]"]
  node_hub["Message hub<br/>[hub.js]"]
  node_http["HTTP and uploads<br/>[http.js]"]
  node_relay["Media relay cache<br/>[filecache.js]"]
  node_discovery["LAN discovery<br/>[discovery.js]"]
  node_servercrypto["Server encryption<br/>[crypto.js]"]
end

subgraph group_state["Local state"]
  node_diskstore[("Persistent chat data<br/>[store.js]")]
  node_config["Local configuration<br/>[config.js]"]
end

subgraph group_operations["Admin and device"]
  node_adminpage["Monitoring panel<br/>[HomeChat-监控.html]"]
  node_password["Password management<br/>[setpass.js]"]
  node_networkwatch["Network watchdog<br/>[net.js]"]
end

node_member(("Household member"))
node_browser(("Browser"))
node_adminop(("Administrator"))

node_member -->|"opens chat"| node_browser
node_browser -->|"uses"| node_webapp
node_webapp -->|"renders"| node_ui
node_webapp -->|"connects and syncs"| node_clientnet
node_webapp -->|"sends media"| node_media
node_webapp -->|"manages client data"| node_clientstore
node_clientnet -->|"seals messages"| node_clientcrypto
node_clientnet -->|"WebSocket and HTTP"| node_server
node_server -->|"dispatches connections"| node_hub
node_server -->|"serves HTTP"| node_http
node_server -->|"starts UDP discovery"| node_discovery
node_server -->|"starts watchdog"| node_networkwatch
node_hub -->|"reads and writes chat state"| node_diskstore
node_hub -->|"seals and opens data"| node_servercrypto
node_hub -->|"relays media"| node_relay
node_http -->|"stores and retrieves uploads"| node_relay
node_server -->|"loads settings"| node_config
node_media -->|"uploads and downloads"| node_http
node_clientstore -->|"persists session state"| node_session
node_webapp -.->|"recovers history"| node_archive
node_webapp -.->|"applies device protection"| node_security
node_webapp -.->|"sets up alerts"| node_notifications
node_adminop -->|"opens monitoring"| node_adminpage
node_adminpage -->|"requests monitoring"| node_server
node_server -->|"routes admin connection"| node_hub
node_hub -->|"reads monitoring statistics"| node_diskstore
node_adminop -->|"changes passwords"| node_password
node_password -->|"re-encrypts stored data"| node_diskstore

click node_webapp "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/app.js"
click node_ui "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/ui.js"
click node_clientnet "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/net.js"
click node_clientstore "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/store.js"
click node_media "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/media.js"
click node_clientcrypto "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/hc1.js"
click node_session "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/session.js"
click node_security "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/secure.js"
click node_notifications "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/notify.js"
click node_archive "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/archive.js"
click node_server "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/index.js"
click node_hub "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/hub.js"
click node_http "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/http.js"
click node_relay "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/filecache.js"
click node_discovery "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/discovery.js"
click node_servercrypto "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/crypto.js"
click node_diskstore "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/store.js"
click node_config "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/config.js"
click node_adminpage "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/admin/HomeChat-%E7%9B%91%E6%8E%A7.html"
click node_password "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/setpass.js"
click node_networkwatch "https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/net.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_webapp,node_ui,node_clientnet,node_clientstore,node_media,node_clientcrypto,node_session,node_security,node_notifications,node_archive,node_browser toneBlue
class node_server,node_hub,node_http,node_relay,node_discovery,node_servercrypto toneAmber
class node_diskstore,node_config toneMint
class node_adminpage,node_password,node_networkwatch toneRose
class node_member,node_adminop toneIndigo
```

## Components

### Web client

- [Chat application](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/app.js): `app/js/app.js`
- [Chat interface](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/ui.js): `app/js/ui.js`
- [Client networking](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/net.js): `app/js/net.js`
- [Client data](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/store.js): `app/js/store.js`
- [Media handling](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/media.js): `app/js/media.js`
- [Client encryption](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/hc1.js): `app/js/hc1.js`
- [Session restore](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/session.js): `app/js/session.js`
- [Device protection](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/secure.js): `app/js/secure.js`
- [Notifications](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/notify.js): `app/js/notify.js`
- [Archive recovery](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/app/js/archive.js): `app/js/archive.js`

### Chat service

- [Service entry](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/index.js): `server/src/index.js`
- [Message hub](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/hub.js): `server/src/hub.js`
- [HTTP and uploads](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/http.js): `server/src/http.js`
- [Media relay cache](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/filecache.js): `server/src/filecache.js`
- [LAN discovery](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/discovery.js): `server/src/discovery.js`
- [Server encryption](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/crypto.js): `server/src/crypto.js`

### Local state

- [Persistent chat data](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/store.js): `server/src/store.js`
- [Local configuration](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/config.js): `server/src/config.js`

### Admin and device

- [Monitoring panel](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/admin/HomeChat-%E7%9B%91%E6%8E%A7.html): `admin/HomeChat-监控.html`
- [Password management](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/setpass.js): `server/src/setpass.js`
- [Network watchdog](https://github.com/liyuanjie0808/home-chat_localareanetworkchat/blob/main/server/src/net.js): `server/src/net.js`

### Other components

- **Household member**
- **Browser**
- **Administrator**

## Connections

- Household member → Browser: opens chat
- Browser → Chat application: uses
- Chat application → Chat interface: renders
- Chat application → Client networking: connects and syncs
- Chat application → Media handling: sends media
- Chat application → Client data: manages client data
- Client networking → Client encryption: seals messages
- Client networking → Service entry: WebSocket and HTTP
- Service entry → Message hub: dispatches connections
- Service entry → HTTP and uploads: serves HTTP
- Service entry → LAN discovery: starts UDP discovery
- Service entry → Network watchdog: starts watchdog
- Message hub → Persistent chat data: reads and writes chat state
- Message hub → Server encryption: seals and opens data
- Message hub → Media relay cache: relays media
- HTTP and uploads → Media relay cache: stores and retrieves uploads
- Service entry → Local configuration: loads settings
- Media handling → HTTP and uploads: uploads and downloads
- Client data → Session restore: persists session state
- Chat application → Archive recovery: recovers history
- Chat application → Device protection: applies device protection
- Chat application → Notifications: sets up alerts
- Administrator → Monitoring panel: opens monitoring
- Monitoring panel → Service entry: requests monitoring
- Service entry → Message hub: routes admin connection
- Message hub → Persistent chat data: reads monitoring statistics
- Administrator → Password management: changes passwords
- Password management → Persistent chat data: re-encrypts stored data
