# hungdo2006/crocstream architecture

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

- Interactive diagram: https://gitdiagram.com/hungdo2006/crocstream
- Repository: https://github.com/hungdo2006/crocstream

## Overview

CrocStream is a Windows desktop app for authenticated, encrypted 1-to-1 screen sharing, with local preview and live performance metrics. The main flow is share/watch UI → session lifecycle and desktop API → capture and frame processing → session protocol and relay transport → remote frame display. The graph also includes the documented Tile-Delta recovery and metrics branches, plus the standalone demo relay. Relationship evidence is limited to the README and the excerpts and SOURCE INDEX entries shown; unsampled details are omitted.

Main entry points: [`app/frontend/src/stream.tsx`](https://github.com/hungdo2006/crocstream/blob/main/app/frontend/src/stream.tsx) (Share and watch UI), [`app/internal/session/controller.go`](https://github.com/hungdo2006/crocstream/blob/main/app/internal/session/controller.go) (Session controller), [`app/internal/desktop/service_windows.go`](https://github.com/hungdo2006/crocstream/blob/main/app/internal/desktop/service_windows.go) (Desktop service), [`app/internal/preview/controller.go`](https://github.com/hungdo2006/crocstream/blob/main/app/internal/preview/controller.go) (Preview controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Desktop interface"]
  node_app_ui["Share and watch UI<br/>[stream.tsx]"]
  node_preview_ui["Local preview UI<br/>[local-preview.tsx]"]
  node_app_entry["App navigation<br/>[main.tsx]"]
  node_session_hook["Session hooks<br/>[useSession.ts]"]
  node_lifecycle["Session lifecycle"]
  node_capture_settings["Capture settings"]
  node_frame_stream["Frame stream hook<br/>[useFrameStream.ts]"]
  node_metrics_ui["Metrics dashboard<br/>[stream-metrics.tsx]"]
end

subgraph group_backend["Session backend"]
  node_desktop_api["Desktop API<br/>[api.ts]"]
  node_desktop_service["Desktop service<br/>[service_windows.go]"]
  node_session_controller["Session controller<br/>[controller.go]"]
  node_preview_controller["Preview controller<br/>[controller.go]"]
end

subgraph group_media["Media processing"]
  node_capture["Screen capture<br/>[capture_windows.go]"]
  node_delta_codec["Tile-Delta codec<br/>[codec.go]"]
  node_frame_protocol["Frame protocol<br/>[stream.go]"]
  node_latest_queue["Latest-frame queue<br/>[queue.go]"]
  node_telemetry["Stream telemetry<br/>[meter.go]"]
end

subgraph group_connectivity["Connectivity"]
  node_image_bridge["Preview image bridge<br/>[bridge.go]"]
  node_transport["Relay transport<br/>[factory.go]"]
  node_peer_session["Peer session<br/>[peer.go]"]
  node_demo_relay["Demo relay launcher<br/>[main.go]"]
end

node_sharer(("Sharer"))
node_viewer(("Viewer"))
node_relay{{"TCP relay"}}

node_sharer -->|"starts sharing"| node_app_ui
node_viewer -->|"joins by code"| node_app_ui
node_app_entry -->|"opens"| node_app_ui
node_app_entry -->|"opens preview"| node_preview_ui
node_app_ui -->|"uses"| node_session_hook
node_app_ui -->|"configures"| node_capture_settings
node_app_ui -->|"uses"| node_frame_stream
node_app_ui -->|"manages"| node_lifecycle
node_app_ui -->|"renders"| node_metrics_ui
node_preview_ui -->|"uses"| node_frame_stream
node_preview_ui -->|"configures"| node_capture_settings
node_session_hook -->|"delegates"| node_lifecycle
node_session_hook -->|"calls"| node_desktop_api
node_desktop_api -->|"invokes"| node_desktop_service
node_desktop_service -->|"creates"| node_session_controller
node_desktop_service -->|"creates"| node_preview_controller
node_desktop_service -->|"configures"| node_transport
node_session_controller -->|"captures"| node_capture
node_session_controller -->|"publishes frames"| node_latest_queue
node_session_controller -->|"runs peer"| node_frame_protocol
node_session_controller -->|"opens connection"| node_transport
node_session_controller -->|"uses"| node_image_bridge
node_session_controller -->|"measures"| node_telemetry
node_preview_controller -->|"captures"| node_capture
node_preview_controller -->|"publishes images"| node_image_bridge
node_preview_controller -->|"measures"| node_telemetry
node_capture -.->|"encodes changes"| node_delta_codec
node_delta_codec -.->|"frames"| node_frame_protocol
node_frame_protocol -->|"delivers encrypted frames"| node_viewer
node_transport -->|"connects"| node_relay
node_demo_relay -->|"runs local relay"| node_relay

click node_app_ui "https://github.com/hungdo2006/crocstream/blob/main/app/frontend/src/stream.tsx"
click node_preview_ui "https://github.com/hungdo2006/crocstream/blob/main/app/frontend/src/local-preview.tsx"
click node_app_entry "https://github.com/hungdo2006/crocstream/blob/main/app/frontend/src/main.tsx"
click node_session_hook "https://github.com/hungdo2006/crocstream/blob/main/app/frontend/src/hooks/useSession.ts"
click node_lifecycle "https://github.com/hungdo2006/crocstream/blob/main/app/frontend/src/session-lifecycle.ts"
click node_capture_settings "https://github.com/hungdo2006/crocstream/blob/main/app/frontend/src/capture-settings.tsx"
click node_frame_stream "https://github.com/hungdo2006/crocstream/blob/main/app/frontend/src/hooks/useFrameStream.ts"
click node_metrics_ui "https://github.com/hungdo2006/crocstream/blob/main/app/frontend/src/stream-metrics.tsx"
click node_desktop_api "https://github.com/hungdo2006/crocstream/blob/main/app/frontend/src/api.ts"
click node_desktop_service "https://github.com/hungdo2006/crocstream/blob/main/app/internal/desktop/service_windows.go"
click node_session_controller "https://github.com/hungdo2006/crocstream/blob/main/app/internal/session/controller.go"
click node_preview_controller "https://github.com/hungdo2006/crocstream/blob/main/app/internal/preview/controller.go"
click node_capture "https://github.com/hungdo2006/crocstream/blob/main/app/internal/capture/capture_windows.go"
click node_delta_codec "https://github.com/hungdo2006/crocstream/blob/main/app/internal/delta/codec.go"
click node_frame_protocol "https://github.com/hungdo2006/crocstream/blob/main/app/internal/protocol/stream.go"
click node_latest_queue "https://github.com/hungdo2006/crocstream/blob/main/app/internal/latest/queue.go"
click node_telemetry "https://github.com/hungdo2006/crocstream/blob/main/app/internal/telemetry/meter.go"
click node_image_bridge "https://github.com/hungdo2006/crocstream/blob/main/app/internal/bridge/bridge.go"
click node_transport "https://github.com/hungdo2006/crocstream/blob/main/app/internal/transport/factory.go"
click node_peer_session "https://github.com/hungdo2006/crocstream/blob/main/app/internal/session/peer.go"
click node_demo_relay "https://github.com/hungdo2006/crocstream/blob/main/app/cmd/demo-relay/main.go"

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_ui,node_preview_ui,node_app_entry,node_session_hook,node_lifecycle,node_capture_settings,node_frame_stream,node_metrics_ui,node_viewer toneBlue
class node_desktop_api,node_desktop_service,node_session_controller,node_preview_controller toneAmber
class node_capture,node_delta_codec,node_frame_protocol,node_latest_queue,node_telemetry toneMint
class node_image_bridge,node_transport,node_peer_session,node_demo_relay toneRose
class node_sharer,node_relay toneIndigo
```

## Components

### Desktop interface

- [Share and watch UI](https://github.com/hungdo2006/crocstream/blob/main/app/frontend/src/stream.tsx): `app/frontend/src/stream.tsx`
- [Local preview UI](https://github.com/hungdo2006/crocstream/blob/main/app/frontend/src/local-preview.tsx): `app/frontend/src/local-preview.tsx`
- [App navigation](https://github.com/hungdo2006/crocstream/blob/main/app/frontend/src/main.tsx): `app/frontend/src/main.tsx`
- [Session hooks](https://github.com/hungdo2006/crocstream/blob/main/app/frontend/src/hooks/useSession.ts): `app/frontend/src/hooks/useSession.ts`
- [Session lifecycle](https://github.com/hungdo2006/crocstream/blob/main/app/frontend/src/session-lifecycle.ts): `app/frontend/src/session-lifecycle.ts`
- [Capture settings](https://github.com/hungdo2006/crocstream/blob/main/app/frontend/src/capture-settings.tsx): `app/frontend/src/capture-settings.tsx`
- [Frame stream hook](https://github.com/hungdo2006/crocstream/blob/main/app/frontend/src/hooks/useFrameStream.ts): `app/frontend/src/hooks/useFrameStream.ts`
- [Metrics dashboard](https://github.com/hungdo2006/crocstream/blob/main/app/frontend/src/stream-metrics.tsx): `app/frontend/src/stream-metrics.tsx`

### Session backend

- [Desktop API](https://github.com/hungdo2006/crocstream/blob/main/app/frontend/src/api.ts): `app/frontend/src/api.ts`
- [Desktop service](https://github.com/hungdo2006/crocstream/blob/main/app/internal/desktop/service_windows.go): `app/internal/desktop/service_windows.go`
- [Session controller](https://github.com/hungdo2006/crocstream/blob/main/app/internal/session/controller.go): `app/internal/session/controller.go`
- [Preview controller](https://github.com/hungdo2006/crocstream/blob/main/app/internal/preview/controller.go): `app/internal/preview/controller.go`

### Media processing

- [Screen capture](https://github.com/hungdo2006/crocstream/blob/main/app/internal/capture/capture_windows.go): `app/internal/capture/capture_windows.go`
- [Tile-Delta codec](https://github.com/hungdo2006/crocstream/blob/main/app/internal/delta/codec.go): `app/internal/delta/codec.go`
- [Frame protocol](https://github.com/hungdo2006/crocstream/blob/main/app/internal/protocol/stream.go): `app/internal/protocol/stream.go`
- [Latest-frame queue](https://github.com/hungdo2006/crocstream/blob/main/app/internal/latest/queue.go): `app/internal/latest/queue.go`
- [Stream telemetry](https://github.com/hungdo2006/crocstream/blob/main/app/internal/telemetry/meter.go): `app/internal/telemetry/meter.go`

### Connectivity

- [Preview image bridge](https://github.com/hungdo2006/crocstream/blob/main/app/internal/bridge/bridge.go): `app/internal/bridge/bridge.go`
- [Relay transport](https://github.com/hungdo2006/crocstream/blob/main/app/internal/transport/factory.go): `app/internal/transport/factory.go`
- [Peer session](https://github.com/hungdo2006/crocstream/blob/main/app/internal/session/peer.go): `app/internal/session/peer.go`
- [Demo relay launcher](https://github.com/hungdo2006/crocstream/blob/main/app/cmd/demo-relay/main.go): `app/cmd/demo-relay/main.go`

### Other components

- **Sharer**
- **Viewer**
- **TCP relay**

## Connections

- Sharer → Share and watch UI: starts sharing (evidence: `README.md`)
- Viewer → Share and watch UI: joins by code (evidence: `README.md`)
- App navigation → Share and watch UI: opens (evidence: `app/frontend/src/main.tsx`)
- App navigation → Local preview UI: opens preview (evidence: `app/frontend/src/main.tsx`)
- Share and watch UI → Session hooks: uses (evidence: `app/frontend/src/stream.tsx`)
- Share and watch UI → Capture settings: configures (evidence: `app/frontend/src/stream.tsx`)
- Share and watch UI → Frame stream hook: uses (evidence: `app/frontend/src/stream.tsx`)
- Share and watch UI → Session lifecycle: manages (evidence: `app/frontend/src/stream.tsx`)
- Share and watch UI → Metrics dashboard: renders (evidence: `app/frontend/src/stream.tsx`)
- Local preview UI → Frame stream hook: uses (evidence: `app/frontend/src/local-preview.tsx`)
- Local preview UI → Capture settings: configures (evidence: `app/frontend/src/local-preview.tsx`)
- Session hooks → Session lifecycle: delegates (evidence: `app/frontend/src/hooks/useSession.ts`)
- Session hooks → Desktop API: calls (evidence: `app/frontend/src/hooks/useSession.ts`)
- Desktop API → Desktop service: invokes (evidence: `README.md`)
- Desktop service → Session controller: creates (evidence: `app/internal/desktop/service_windows.go`)
- Desktop service → Preview controller: creates (evidence: `app/internal/desktop/service_windows.go`)
- Desktop service → Relay transport: configures (evidence: `app/internal/desktop/service_windows.go`)
- Session controller → Screen capture: captures (evidence: `app/internal/session/controller.go`)
- Session controller → Latest-frame queue: publishes frames (evidence: `app/internal/session/controller.go`)
- Session controller → Frame protocol: runs peer (evidence: `app/internal/session/controller.go`)
- Session controller → Relay transport: opens connection (evidence: `app/internal/session/controller.go`)
- Session controller → Preview image bridge: uses (evidence: `app/internal/session/controller.go`)
- Session controller → Stream telemetry: measures (evidence: `app/internal/session/controller.go`)
- Preview controller → Screen capture: captures (evidence: `app/internal/preview/controller.go`)
- Preview controller → Preview image bridge: publishes images (evidence: `app/internal/preview/controller.go`)
- Preview controller → Stream telemetry: measures (evidence: `app/internal/preview/controller.go`)
- Screen capture → Tile-Delta codec: encodes changes
- Tile-Delta codec → Frame protocol: frames
- Frame protocol → Viewer: delivers encrypted frames (evidence: `README.md`)
- Relay transport → TCP relay: connects (evidence: `README.md`)
- Demo relay launcher → TCP relay: runs local relay (evidence: `README.md`)
