# salinda-kumara/skreen architecture

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

- Interactive diagram: https://gitdiagram.com/salinda-kumara/skreen
- Repository: https://github.com/salinda-kumara/skreen

## Overview

Skreen pairs a sender with a receiving browser using a short-lived cast code, then relays WebRTC signaling while media travels directly between peers or through TURN. The map includes the documented capture, quality, statistics, and reachability features. Server relationships are supported by the sampled imports and calls; browser-side details not shown in excerpts are limited to relationships documented in the README.

Main entry points: [`server/http.js`](https://github.com/salinda-kumara/skreen/blob/main/server/http.js) (HTTP API and static files), [`web/sender.js`](https://github.com/salinda-kumara/skreen/blob/main/web/sender.js) (Sender page), [`web/app.js`](https://github.com/salinda-kumara/skreen/blob/main/web/app.js) (Sign-in and pairing), [`web/viewer.js`](https://github.com/salinda-kumara/skreen/blob/main/web/viewer.js) (Viewer page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser_flow["Browser flow"]
  node_entry_ui["Sign-in and pairing<br/>[app.js]"]
  node_login_client["Login client<br/>[session.js]"]
end

subgraph group_casting["Casting and media"]
  node_sender_page["Sender page<br/>[sender.js]"]
  node_viewer_page["Viewer page<br/>[viewer.js]"]
  node_quality["Adaptive quality<br/>[quality.js]"]
  node_stats["WebRTC statistics<br/>[rtcstats.js]"]
  node_ice_diag["ICE diagnostics<br/>[ice.js]"]
  node_web_signaling["Browser signaling client<br/>[signaling.js]"]
end

subgraph group_server_api["Server API and security"]
  node_http_api["HTTP API and static files<br/>[http.js]"]
  node_auth["Passcode authentication<br/>[auth.js]"]
  node_rate_limit["Request limiting<br/>[ratelimit.js]"]
  node_config["Runtime configuration<br/>[config.js]"]
  node_logger["Redacted logging<br/>[log.js]"]
end

subgraph group_session_signaling["Sessions and signaling"]
  node_bootstrap["HTTP and WS bootstrap<br/>[index.js]"]
  node_session_store[("Session and token store<br/>[sessions.js]")]
  node_ws_signaling["WebSocket signaling relay<br/>[signaling.js]"]
end

subgraph group_network["Network services"]
  node_turn_creds["TURN credentials<br/>[turn.js]"]
  node_turn_service["coturn relay"]
end

node_sender_actor(("Sender user"))
node_receiver_actor(("Receiver user"))
node_android_sender["Android sender"]

node_sender_actor -->|"enters code"| node_entry_ui
node_receiver_actor -->|"chooses Receive"| node_entry_ui
node_entry_ui -->|"checks login"| node_login_client
node_login_client -->|"calls auth API"| node_http_api
node_entry_ui -->|"claims code"| node_http_api
node_entry_ui -->|"opens after claim"| node_sender_page
node_entry_ui -->|"opens Receive"| node_viewer_page
node_sender_page -.->|"uses signaling"| node_web_signaling
node_viewer_page -.->|"uses signaling"| node_web_signaling
node_sender_page -.->|"adapts capture"| node_quality
node_sender_page -.->|"samples connection"| node_stats
node_viewer_page -.->|"samples connection"| node_stats
node_sender_page -.->|"checks reachability"| node_ice_diag
node_viewer_page -.->|"checks reachability"| node_ice_diag
node_web_signaling -->|"exchanges SDP and ICE"| node_ws_signaling
node_ws_signaling -->|"authenticates tickets"| node_session_store
node_ws_signaling -->|"updates session peers"| node_session_store
node_bootstrap -->|"creates handler"| node_http_api
node_bootstrap -->|"attaches relay"| node_ws_signaling
node_bootstrap -->|"starts janitor"| node_session_store
node_http_api -->|"authenticates requests"| node_auth
node_http_api -->|"limits requests"| node_rate_limit
node_http_api -->|"creates and manages sessions"| node_session_store
node_http_api -->|"returns ICE servers"| node_turn_creds
node_http_api -->|"logs API events"| node_logger
node_auth -->|"reads secrets"| node_config
node_session_store -->|"reads lifetimes"| node_config
node_session_store -->|"logs session events"| node_logger
node_ws_signaling -->|"reads limits"| node_config
node_turn_creds -->|"reads TURN settings"| node_config
node_turn_creds -.->|"issues temporary credentials"| node_turn_service
node_sender_page -->|"sends encrypted media"| node_viewer_page
node_sender_page -.->|"relays media when needed"| node_turn_service
node_android_sender -.->|"uses same protocol"| node_ws_signaling
node_android_sender -.->|"streams encrypted media"| node_viewer_page

click node_entry_ui "https://github.com/salinda-kumara/skreen/blob/main/web/app.js"
click node_login_client "https://github.com/salinda-kumara/skreen/blob/main/web/lib/session.js"
click node_sender_page "https://github.com/salinda-kumara/skreen/blob/main/web/sender.js"
click node_viewer_page "https://github.com/salinda-kumara/skreen/blob/main/web/viewer.js"
click node_quality "https://github.com/salinda-kumara/skreen/blob/main/web/lib/quality.js"
click node_stats "https://github.com/salinda-kumara/skreen/blob/main/web/lib/rtcstats.js"
click node_ice_diag "https://github.com/salinda-kumara/skreen/blob/main/web/lib/ice.js"
click node_web_signaling "https://github.com/salinda-kumara/skreen/blob/main/web/lib/signaling.js"
click node_http_api "https://github.com/salinda-kumara/skreen/blob/main/server/http.js"
click node_auth "https://github.com/salinda-kumara/skreen/blob/main/server/auth.js"
click node_rate_limit "https://github.com/salinda-kumara/skreen/blob/main/server/ratelimit.js"
click node_config "https://github.com/salinda-kumara/skreen/blob/main/server/config.js"
click node_logger "https://github.com/salinda-kumara/skreen/blob/main/server/log.js"
click node_bootstrap "https://github.com/salinda-kumara/skreen/blob/main/server/index.js"
click node_session_store "https://github.com/salinda-kumara/skreen/blob/main/server/sessions.js"
click node_ws_signaling "https://github.com/salinda-kumara/skreen/blob/main/server/signaling.js"
click node_turn_creds "https://github.com/salinda-kumara/skreen/blob/main/server/turn.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_entry_ui,node_login_client,node_sender_actor,node_receiver_actor toneBlue
class node_sender_page,node_viewer_page,node_quality,node_stats,node_ice_diag,node_web_signaling toneAmber
class node_http_api,node_auth,node_rate_limit,node_config,node_logger toneMint
class node_bootstrap,node_session_store,node_ws_signaling toneRose
class node_turn_creds,node_turn_service,node_android_sender toneIndigo
```

## Components

### Browser flow

- [Sign-in and pairing](https://github.com/salinda-kumara/skreen/blob/main/web/app.js): `web/app.js`
- [Login client](https://github.com/salinda-kumara/skreen/blob/main/web/lib/session.js): `web/lib/session.js`

### Casting and media

- [Sender page](https://github.com/salinda-kumara/skreen/blob/main/web/sender.js): `web/sender.js`
- [Viewer page](https://github.com/salinda-kumara/skreen/blob/main/web/viewer.js): `web/viewer.js`
- [Adaptive quality](https://github.com/salinda-kumara/skreen/blob/main/web/lib/quality.js): `web/lib/quality.js`
- [WebRTC statistics](https://github.com/salinda-kumara/skreen/blob/main/web/lib/rtcstats.js): `web/lib/rtcstats.js`
- [ICE diagnostics](https://github.com/salinda-kumara/skreen/blob/main/web/lib/ice.js): `web/lib/ice.js`
- [Browser signaling client](https://github.com/salinda-kumara/skreen/blob/main/web/lib/signaling.js): `web/lib/signaling.js`

### Server API and security

- [HTTP API and static files](https://github.com/salinda-kumara/skreen/blob/main/server/http.js): `server/http.js`
- [Passcode authentication](https://github.com/salinda-kumara/skreen/blob/main/server/auth.js): `server/auth.js`
- [Request limiting](https://github.com/salinda-kumara/skreen/blob/main/server/ratelimit.js): `server/ratelimit.js`
- [Runtime configuration](https://github.com/salinda-kumara/skreen/blob/main/server/config.js): `server/config.js`
- [Redacted logging](https://github.com/salinda-kumara/skreen/blob/main/server/log.js): `server/log.js`

### Sessions and signaling

- [HTTP and WS bootstrap](https://github.com/salinda-kumara/skreen/blob/main/server/index.js): `server/index.js`
- [Session and token store](https://github.com/salinda-kumara/skreen/blob/main/server/sessions.js): `server/sessions.js`
- [WebSocket signaling relay](https://github.com/salinda-kumara/skreen/blob/main/server/signaling.js): `server/signaling.js`

### Network services

- [TURN credentials](https://github.com/salinda-kumara/skreen/blob/main/server/turn.js): `server/turn.js`
- **coturn relay**

### Other components

- **Sender user**
- **Receiver user**
- **Android sender**

## Connections

- Sender user → Sign-in and pairing: enters code (evidence: `README.md`)
- Receiver user → Sign-in and pairing: chooses Receive (evidence: `README.md`)
- Sign-in and pairing → Login client: checks login (evidence: `web/app.js`)
- Login client → HTTP API and static files: calls auth API (evidence: `README.md`)
- Sign-in and pairing → HTTP API and static files: claims code (evidence: `web/app.js`)
- Sign-in and pairing → Sender page: opens after claim (evidence: `web/app.js`)
- Sign-in and pairing → Viewer page: opens Receive (evidence: `web/app.js`)
- Sender page → Browser signaling client: uses signaling
- Viewer page → Browser signaling client: uses signaling
- Sender page → Adaptive quality: adapts capture
- Sender page → WebRTC statistics: samples connection
- Viewer page → WebRTC statistics: samples connection
- Sender page → ICE diagnostics: checks reachability
- Viewer page → ICE diagnostics: checks reachability
- Browser signaling client → WebSocket signaling relay: exchanges SDP and ICE (evidence: `README.md`)
- WebSocket signaling relay → Session and token store: authenticates tickets (evidence: `server/signaling.js`)
- WebSocket signaling relay → Session and token store: updates session peers (evidence: `server/signaling.js`)
- HTTP and WS bootstrap → HTTP API and static files: creates handler (evidence: `server/index.js`)
- HTTP and WS bootstrap → WebSocket signaling relay: attaches relay (evidence: `server/index.js`)
- HTTP and WS bootstrap → Session and token store: starts janitor (evidence: `server/index.js`)
- HTTP API and static files → Passcode authentication: authenticates requests (evidence: `server/http.js`)
- HTTP API and static files → Request limiting: limits requests (evidence: `server/http.js`)
- HTTP API and static files → Session and token store: creates and manages sessions (evidence: `server/http.js`)
- HTTP API and static files → TURN credentials: returns ICE servers (evidence: `server/http.js`)
- HTTP API and static files → Redacted logging: logs API events (evidence: `server/http.js`)
- Passcode authentication → Runtime configuration: reads secrets (evidence: `server/auth.js`)
- Session and token store → Runtime configuration: reads lifetimes (evidence: `server/sessions.js`)
- Session and token store → Redacted logging: logs session events (evidence: `server/sessions.js`)
- WebSocket signaling relay → Runtime configuration: reads limits (evidence: `server/signaling.js`)
- TURN credentials → Runtime configuration: reads TURN settings (evidence: `server/turn.js`)
- TURN credentials → coturn relay: issues temporary credentials
- Sender page → Viewer page: sends encrypted media (evidence: `README.md`)
- Sender page → coturn relay: relays media when needed (evidence: `README.md`)
- Android sender → WebSocket signaling relay: uses same protocol (evidence: `README.md`)
- Android sender → Viewer page: streams encrypted media (evidence: `README.md`)
