# zidian23345/github_webrtc architecture

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

- Interactive diagram: https://gitdiagram.com/zidian23345/github_webrtc
- Repository: https://github.com/zidian23345/github_webrtc

## Overview

This is a browser-based real-time communications product with an Android WebView companion. The main workflow is users entering the chat, exchanging group or friend messages, and starting voice/video calls or screen sharing; the server coordinates signaling and persists selected chat and account state. Separate branches cover friendship, administration, and Android notifications, native screen capture, and app updates. README capabilities inform the broader subsystem map; sampled server and client excerpts are partial, so uncertain internal wiring is omitted.

Main entry points: [`server.js`](https://github.com/zidian23345/github_webrtc/blob/main/server.js) (HTTP and signaling), [`views/home.ejs`](https://github.com/zidian23345/github_webrtc/blob/main/views/home.ejs) (Chat interface), [`public/scripts/webrtc-room.js`](https://github.com/zidian23345/github_webrtc/blob/main/public/scripts/webrtc-room.js) (Room WebRTC), [`_android_project/app/src/main/java/com/webrtc/screenshare/MainActivity.kt`](https://github.com/zidian23345/github_webrtc/blob/main/_android_project/app/src/main/java/com/webrtc/screenshare/MainActivity.kt) (WebView app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_home["Chat interface<br/>[home.ejs]"]
  node_room["Call room<br/>[room.ejs]"]
  node_chatjs["Chat client<br/>[chat.js]"]
  node_utils["Client utilities<br/>[util.js]"]
end

subgraph group_realtime["Realtime media"]
  node_mainjs["Call controls<br/>[main.js]"]
  node_roomjs["Room WebRTC<br/>[webrtc-room.js]"]
end

subgraph group_server["Server services"]
  node_server["HTTP and signaling<br/>[server.js]"]
  node_frienddata[("Friend and message data")]
  node_history[("Chat history<br/>[chat-history.json]")]
  node_adminview["Admin console<br/>[admin.ejs]"]
  node_loginview["Admin login<br/>[admin_login.ejs]"]
end

subgraph group_android["Android companion"]
  node_android["WebView app<br/>[MainActivity.kt]"]
  node_config["Server settings<br/>[ServerConfig.kt]"]
  node_settings["App settings"]
  node_capture["Native screen capture"]
  node_notify["Chat notifications"]
end

node_user(("Participant"))
node_browser(("Web browser"))
node_media(("WebRTC media peers"))
node_stun["STUN service"]
node_os(("Android system"))

node_user -->|"opens chat"| node_home
node_browser -->|"loads page"| node_home
node_home -->|"uses client setup"| node_utils
node_home -->|"loads chat"| node_chatjs
node_home -->|"loads controls"| node_mainjs
node_user -->|"joins call"| node_room
node_browser -->|"loads page"| node_room
node_room -->|"loads WebRTC"| node_roomjs
node_roomjs -->|"signals peers"| node_server
node_mainjs -->|"sends media"| node_media
node_roomjs -->|"sends media"| node_media
node_roomjs -.->|"discovers routes"| node_stun
node_chatjs -->|"sends messages"| node_server
node_server -->|"pushes updates"| node_chatjs
node_server -->|"reads and writes"| node_history
node_server -->|"persists relationships"| node_frienddata
node_user -->|"administers"| node_adminview
node_adminview -->|"requests admin actions"| node_server
node_loginview -->|"authenticates"| node_server
node_user -->|"uses app"| node_android
node_android -->|"loads web app"| node_home
node_android -->|"reads settings"| node_config
node_settings -->|"saves settings"| node_config
node_android -->|"starts capture"| node_capture
node_capture -->|"forwards screen frames"| node_server
node_server -->|"pushes call and chat events"| node_notify
node_notify -->|"shows notifications"| node_os
node_capture -->|"captures display"| node_os
node_settings -->|"checks updates"| node_server

click node_home "https://github.com/zidian23345/github_webrtc/blob/main/views/home.ejs"
click node_room "https://github.com/zidian23345/github_webrtc/blob/main/views/room.ejs"
click node_mainjs "https://github.com/zidian23345/github_webrtc/blob/main/public/scripts/main.js"
click node_roomjs "https://github.com/zidian23345/github_webrtc/blob/main/public/scripts/webrtc-room.js"
click node_chatjs "https://github.com/zidian23345/github_webrtc/blob/main/public/scripts/chat.js"
click node_utils "https://github.com/zidian23345/github_webrtc/blob/main/public/scripts/util.js"
click node_server "https://github.com/zidian23345/github_webrtc/blob/main/server.js"
click node_frienddata "https://github.com/zidian23345/github_webrtc/tree/main/data"
click node_history "https://github.com/zidian23345/github_webrtc/blob/main/data/chat-history.json"
click node_adminview "https://github.com/zidian23345/github_webrtc/blob/main/views/admin.ejs"
click node_loginview "https://github.com/zidian23345/github_webrtc/blob/main/views/admin_login.ejs"
click node_android "https://github.com/zidian23345/github_webrtc/blob/main/_android_project/app/src/main/java/com/webrtc/screenshare/MainActivity.kt"
click node_config "https://github.com/zidian23345/github_webrtc/blob/main/_android_project/app/src/main/java/com/webrtc/screenshare/ServerConfig.kt"
click node_settings "https://github.com/zidian23345/github_webrtc/blob/main/_android_project/app/src/main/java/com/webrtc/screenshare/SettingsActivity.kt"
click node_capture "https://github.com/zidian23345/github_webrtc/blob/main/_android_project/app/src/main/java/com/webrtc/screenshare/ScreenCaptureService.kt"
click node_notify "https://github.com/zidian23345/github_webrtc/blob/main/_android_project/app/src/main/java/com/webrtc/screenshare/ChatNotificationService.kt"

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_home,node_room,node_chatjs,node_utils,node_browser toneBlue
class node_mainjs,node_roomjs toneAmber
class node_server,node_frienddata,node_history,node_adminview,node_loginview toneMint
class node_android,node_config,node_settings,node_capture,node_notify toneRose
class node_user,node_media,node_stun,node_os toneIndigo
```

## Components

### Web experience

- [Chat interface](https://github.com/zidian23345/github_webrtc/blob/main/views/home.ejs): `views/home.ejs`
- [Call room](https://github.com/zidian23345/github_webrtc/blob/main/views/room.ejs): `views/room.ejs`
- [Chat client](https://github.com/zidian23345/github_webrtc/blob/main/public/scripts/chat.js): `public/scripts/chat.js`
- [Client utilities](https://github.com/zidian23345/github_webrtc/blob/main/public/scripts/util.js): `public/scripts/util.js`

### Realtime media

- [Call controls](https://github.com/zidian23345/github_webrtc/blob/main/public/scripts/main.js): `public/scripts/main.js`
- [Room WebRTC](https://github.com/zidian23345/github_webrtc/blob/main/public/scripts/webrtc-room.js): `public/scripts/webrtc-room.js`

### Server services

- [HTTP and signaling](https://github.com/zidian23345/github_webrtc/blob/main/server.js): `server.js`
- [Friend and message data](https://github.com/zidian23345/github_webrtc/tree/main/data): `data`
- [Chat history](https://github.com/zidian23345/github_webrtc/blob/main/data/chat-history.json): `data/chat-history.json`
- [Admin console](https://github.com/zidian23345/github_webrtc/blob/main/views/admin.ejs): `views/admin.ejs`
- [Admin login](https://github.com/zidian23345/github_webrtc/blob/main/views/admin_login.ejs): `views/admin_login.ejs`

### Android companion

- [WebView app](https://github.com/zidian23345/github_webrtc/blob/main/_android_project/app/src/main/java/com/webrtc/screenshare/MainActivity.kt): `_android_project/app/src/main/java/com/webrtc/screenshare/MainActivity.kt`
- [Server settings](https://github.com/zidian23345/github_webrtc/blob/main/_android_project/app/src/main/java/com/webrtc/screenshare/ServerConfig.kt): `_android_project/app/src/main/java/com/webrtc/screenshare/ServerConfig.kt`
- [App settings](https://github.com/zidian23345/github_webrtc/blob/main/_android_project/app/src/main/java/com/webrtc/screenshare/SettingsActivity.kt): `_android_project/app/src/main/java/com/webrtc/screenshare/SettingsActivity.kt`
- [Native screen capture](https://github.com/zidian23345/github_webrtc/blob/main/_android_project/app/src/main/java/com/webrtc/screenshare/ScreenCaptureService.kt): `_android_project/app/src/main/java/com/webrtc/screenshare/ScreenCaptureService.kt`
- [Chat notifications](https://github.com/zidian23345/github_webrtc/blob/main/_android_project/app/src/main/java/com/webrtc/screenshare/ChatNotificationService.kt): `_android_project/app/src/main/java/com/webrtc/screenshare/ChatNotificationService.kt`

### Other components

- **Participant**
- **Web browser**
- **WebRTC media peers**
- **STUN service**
- **Android system**

## Connections

- Participant → Chat interface: opens chat
- Web browser → Chat interface: loads page
- Chat interface → Client utilities: uses client setup
- Chat interface → Chat client: loads chat
- Chat interface → Call controls: loads controls
- Participant → Call room: joins call
- Web browser → Call room: loads page
- Call room → Room WebRTC: loads WebRTC
- Room WebRTC → HTTP and signaling: signals peers
- Call controls → WebRTC media peers: sends media
- Room WebRTC → WebRTC media peers: sends media
- Room WebRTC → STUN service: discovers routes
- Chat client → HTTP and signaling: sends messages
- HTTP and signaling → Chat client: pushes updates
- HTTP and signaling → Chat history: reads and writes
- HTTP and signaling → Friend and message data: persists relationships
- Participant → Admin console: administers
- Admin console → HTTP and signaling: requests admin actions
- Admin login → HTTP and signaling: authenticates
- Participant → WebView app: uses app
- WebView app → Chat interface: loads web app
- WebView app → Server settings: reads settings
- App settings → Server settings: saves settings
- WebView app → Native screen capture: starts capture
- Native screen capture → HTTP and signaling: forwards screen frames
- HTTP and signaling → Chat notifications: pushes call and chat events
- Chat notifications → Android system: shows notifications
- Native screen capture → Android system: captures display
- App settings → HTTP and signaling: checks updates
