# nico579/blink2video architecture

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

- Interactive diagram: https://gitdiagram.com/nico579/blink2video
- Repository: https://github.com/nico579/blink2video

## Overview

blink2video is a local desktop companion for Blink cameras: users sign in, configure storage, view and control cameras, retrieve recordings, and browse or assemble a lasting archive. The main runtime spans authentication, camera access, clip acquisition, local state, and video assembly; the local web interface also supports live recording, snapshots, alerts, and settings. Paths and responsibilities reflect the README and sampled excerpts; several feature implementations were not sampled, so uncertain internal wiring is omitted.

Main entry points: [`serve.py`](https://github.com/nico579/blink2video/blob/main/serve.py) (Local web server), [`blink_engine.py`](https://github.com/nico579/blink2video/blob/main/blink_engine.py) (Clip downloader), [`serve_app.js`](https://github.com/nico579/blink2video/blob/main/serve_app.js) (Browser UI), [`merge_daily.py`](https://github.com/nico579/blink2video/blob/main/merge_daily.py) (Video assembly)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Local interface"]
  node_browser["Browser UI<br/>[serve_app.js]"]
  node_server["Local web server<br/>[serve.py]"]
end

subgraph group_camera["Blink access"]
  node_session["Blink session<br/>[blink_auth.py]"]
  node_camera_control["Camera controls<br/>[serve.py]"]
  node_live["Live view<br/>[serve.py]"]
  node_webrtc["WebRTC transport<br/>[blink_webrtc.py]"]
  node_ts_demux["MSE transport<br/>[blink_ts_demux.py]"]
  node_snapshot["Snapshots<br/>[serve.py]"]
end

subgraph group_archive["Clip archive"]
  node_download["Clip downloader<br/>[blink_engine.py]"]
  node_registry[("Clip registry<br/>[blink_registre.py]")]
  node_models["Clip matching<br/>[blink_models.py]"]
  node_clips[("Downloaded clips")]
  node_assembler["Video assembly<br/>[merge_daily.py]"]
  node_archives[("Daily, weekly, monthly videos")]
end

subgraph group_operations["Runtime operations"]
  node_monitor["Monitoring and alerts<br/>[blink_cli.py]"]
  node_settings[("Runtime settings<br/>[runtime.py]")]
  node_tray["Tray controls<br/>[tray.py]"]
end

node_user(("User"))
node_blink{{"Blink services"}}
node_local_storage[("Module storage")]
node_cloud{{"Blink cloud"}}
node_webhook{{"Webhook recipient"}}

node_user -->|"uses"| node_browser
node_browser -->|"HTTP requests"| node_server
node_server -->|"serves UI"| node_browser
node_server -->|"authenticates"| node_session
node_session -->|"opens session"| node_blink
node_server -->|"dispatches controls"| node_camera_control
node_camera_control -->|"arms cameras"| node_blink
node_server -->|"starts live view"| node_live
node_live -->|"requests stream"| node_blink
node_browser -.->|"plays stream"| node_webrtc
node_browser -.->|"plays stream"| node_ts_demux
node_server -->|"requests snapshot"| node_snapshot
node_snapshot -->|"captures image"| node_blink
node_snapshot -.->|"notifies on completion"| node_webhook
node_monitor -->|"schedules polling"| node_download
node_download -->|"uses session"| node_session
node_download -->|"reads clips"| node_local_storage
node_download -->|"fetches clips"| node_cloud
node_download -->|"matches recordings"| node_models
node_download -->|"checks and updates"| node_registry
node_download -->|"writes downloads"| node_clips
node_assembler -->|"reads clip state"| node_registry
node_assembler -->|"reads source videos"| node_clips
node_assembler -->|"writes assembled videos"| node_archives
node_server -->|"reads and updates"| node_registry
node_server -->|"serves recordings"| node_clips
node_server -->|"reads and applies"| node_settings
node_monitor -->|"checks camera state"| node_blink
node_monitor -.->|"sends alerts"| node_webhook
node_tray -->|"opens or controls"| node_server

click node_browser "https://github.com/nico579/blink2video/blob/main/serve_app.js"
click node_server "https://github.com/nico579/blink2video/blob/main/serve.py"
click node_session "https://github.com/nico579/blink2video/blob/main/blink_auth.py"
click node_camera_control "https://github.com/nico579/blink2video/blob/main/serve.py"
click node_live "https://github.com/nico579/blink2video/blob/main/serve.py"
click node_webrtc "https://github.com/nico579/blink2video/blob/main/blink_webrtc.py"
click node_ts_demux "https://github.com/nico579/blink2video/blob/main/blink_ts_demux.py"
click node_snapshot "https://github.com/nico579/blink2video/blob/main/serve.py"
click node_download "https://github.com/nico579/blink2video/blob/main/blink_engine.py"
click node_registry "https://github.com/nico579/blink2video/blob/main/blink_registre.py"
click node_models "https://github.com/nico579/blink2video/blob/main/blink_models.py"
click node_assembler "https://github.com/nico579/blink2video/blob/main/merge_daily.py"
click node_monitor "https://github.com/nico579/blink2video/blob/main/blink_cli.py"
click node_settings "https://github.com/nico579/blink2video/blob/main/runtime.py"
click node_tray "https://github.com/nico579/blink2video/blob/main/tray.py"

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_browser,node_server,node_user toneBlue
class node_session,node_camera_control,node_live,node_webrtc,node_ts_demux,node_snapshot,node_local_storage toneAmber
class node_download,node_registry,node_models,node_clips,node_assembler,node_archives,node_webhook toneMint
class node_monitor,node_settings,node_tray toneRose
class node_blink,node_cloud toneIndigo
```

## Components

### Local interface

- [Browser UI](https://github.com/nico579/blink2video/blob/main/serve_app.js): `serve_app.js`
- [Local web server](https://github.com/nico579/blink2video/blob/main/serve.py): `serve.py`

### Blink access

- [Blink session](https://github.com/nico579/blink2video/blob/main/blink_auth.py): `blink_auth.py`
- [Camera controls](https://github.com/nico579/blink2video/blob/main/serve.py): `serve.py`
- [Live view](https://github.com/nico579/blink2video/blob/main/serve.py): `serve.py`
- [WebRTC transport](https://github.com/nico579/blink2video/blob/main/blink_webrtc.py): `blink_webrtc.py`
- [MSE transport](https://github.com/nico579/blink2video/blob/main/blink_ts_demux.py): `blink_ts_demux.py`
- [Snapshots](https://github.com/nico579/blink2video/blob/main/serve.py): `serve.py`

### Clip archive

- [Clip downloader](https://github.com/nico579/blink2video/blob/main/blink_engine.py): `blink_engine.py`
- [Clip registry](https://github.com/nico579/blink2video/blob/main/blink_registre.py): `blink_registre.py`
- [Clip matching](https://github.com/nico579/blink2video/blob/main/blink_models.py): `blink_models.py`
- **Downloaded clips**
- [Video assembly](https://github.com/nico579/blink2video/blob/main/merge_daily.py): `merge_daily.py`
- **Daily, weekly, monthly videos**

### Runtime operations

- [Monitoring and alerts](https://github.com/nico579/blink2video/blob/main/blink_cli.py): `blink_cli.py`
- [Runtime settings](https://github.com/nico579/blink2video/blob/main/runtime.py): `runtime.py`
- [Tray controls](https://github.com/nico579/blink2video/blob/main/tray.py): `tray.py`

### Other components

- **User**
- **Blink services**
- **Module storage**
- **Blink cloud**
- **Webhook recipient**

## Connections

- User → Browser UI: uses
- Browser UI → Local web server: HTTP requests
- Local web server → Browser UI: serves UI
- Local web server → Blink session: authenticates
- Blink session → Blink services: opens session
- Local web server → Camera controls: dispatches controls
- Camera controls → Blink services: arms cameras
- Local web server → Live view: starts live view
- Live view → Blink services: requests stream
- Browser UI → WebRTC transport: plays stream
- Browser UI → MSE transport: plays stream
- Local web server → Snapshots: requests snapshot
- Snapshots → Blink services: captures image
- Snapshots → Webhook recipient: notifies on completion
- Monitoring and alerts → Clip downloader: schedules polling
- Clip downloader → Blink session: uses session
- Clip downloader → Module storage: reads clips
- Clip downloader → Blink cloud: fetches clips
- Clip downloader → Clip matching: matches recordings
- Clip downloader → Clip registry: checks and updates
- Clip downloader → Downloaded clips: writes downloads
- Video assembly → Clip registry: reads clip state
- Video assembly → Downloaded clips: reads source videos
- Video assembly → Daily, weekly, monthly videos: writes assembled videos
- Local web server → Clip registry: reads and updates
- Local web server → Downloaded clips: serves recordings
- Local web server → Runtime settings: reads and applies
- Monitoring and alerts → Blink services: checks camera state
- Monitoring and alerts → Webhook recipient: sends alerts
- Tray controls → Local web server: opens or controls
