# ivelytechnologies/se_analog_dvr_edge architecture

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

- Interactive diagram: https://gitdiagram.com/ivelytechnologies/se_analog_dvr_edge
- Repository: https://github.com/ivelytechnologies/se_analog_dvr_edge

## Overview

SE Analog DVR Edge is a local service for discovering per-channel RTSP streams from an analog DVR and publishing them into MediaMTX for backend and dashboard playback. The main workflow is setup and configuration, channel probing, then one recoverable FFmpeg publisher per working channel; the service also supports DVR recording searches and cloud-assisted customer/site/camera selection. The graph reflects documented flows and sampled imports/calls. Some recovery and MediaMTX behavior is described only in the README; unsampled implementation details are not inferred.

Main entry points: [`agent/server.py`](https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/server.py) (HTTP service), [`agent/runtime.py`](https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/runtime.py) (Runtime orchestration), [`agent/worker.py`](https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/worker.py) (Channel workers), [`agent/dvr_rtsp.py`](https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/dvr_rtsp.py) (RTSP discovery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Local interface"]
  node_browser["Setup browser"]
  node_http["HTTP service<br/>[server.py]"]
  node_setup["Setup page<br/>[setup_page.py]"]
end

subgraph group_orchestration["Agent orchestration"]
  node_config["Config validation<br/>[config.py]"]
  node_runtime["Runtime orchestration<br/>[runtime.py]"]
  node_diagnostics["Diagnostics<br/>[diagnostics.py]"]
  node_logging["Logging<br/>[logging_config.py]"]
  node_version["Version metadata<br/>[version.py]"]
end

subgraph group_streaming["Stream pipeline"]
  node_probe["RTSP discovery<br/>[dvr_rtsp.py]"]
  node_worker["Channel workers<br/>[worker.py]"]
  node_publisher["FFmpeg command<br/>[publisher.py]"]
  node_path_config["MediaMTX config<br/>[mediamtx_paths.py]"]
  node_archive["Archive search<br/>[dvr_archive.py]"]
end

subgraph group_integrations["External systems"]
  node_dvr["DVR channels"]
  node_ffmpeg["FFmpeg / ffprobe"]
  node_mediamtx[("MediaMTX")]
  node_cloud["Cloud provisioning API"]
  node_playback["Backend and dashboard"]
end

node_operator(("Site operator"))

node_operator -->|"configures"| node_browser
node_browser -->|"calls local API"| node_http
node_http -->|"serves page"| node_setup
node_http -->|"controls runtime"| node_runtime
node_http -->|"loads config"| node_config
node_http -->|"requests diagnostics"| node_diagnostics
node_http -->|"searches recordings"| node_archive
node_http -->|"requests provisioning"| node_cloud
node_http -->|"serves version"| node_version
node_browser -->|"selects site data"| node_cloud
node_runtime -->|"loads and validates"| node_config
node_runtime -->|"probes channels"| node_probe
node_probe -->|"tests RTSP URLs"| node_dvr
node_probe -->|"runs ffprobe"| node_ffmpeg
node_runtime -->|"starts workers"| node_worker
node_worker -->|"builds command"| node_publisher
node_worker -->|"runs and restarts"| node_ffmpeg
node_ffmpeg -->|"publishes streams"| node_mediamtx
node_runtime -->|"registers paths"| node_path_config
node_path_config -->|"updates configuration"| node_mediamtx
node_mediamtx -->|"serves streams"| node_playback
node_archive -->|"searches recordings"| node_dvr
node_http -->|"logs requests"| node_logging
node_worker -->|"logs worker status"| node_logging
node_runtime -->|"logs runtime events"| node_logging

click node_http "https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/server.py"
click node_setup "https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/setup_page.py"
click node_config "https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/config.py"
click node_runtime "https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/runtime.py"
click node_diagnostics "https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/diagnostics.py"
click node_logging "https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/logging_config.py"
click node_version "https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/version.py"
click node_probe "https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/dvr_rtsp.py"
click node_worker "https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/worker.py"
click node_publisher "https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/publisher.py"
click node_path_config "https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/mediamtx_paths.py"
click node_archive "https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/dvr_archive.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_http,node_setup toneBlue
class node_config,node_runtime,node_diagnostics,node_logging,node_version toneAmber
class node_probe,node_worker,node_publisher,node_path_config,node_archive toneMint
class node_dvr,node_ffmpeg,node_mediamtx,node_cloud,node_playback toneRose
class node_operator toneIndigo
```

## Components

### Local interface

- **Setup browser**
- [HTTP service](https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/server.py): `agent/server.py`
- [Setup page](https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/setup_page.py): `agent/setup_page.py`

### Agent orchestration

- [Config validation](https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/config.py): `agent/config.py`
- [Runtime orchestration](https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/runtime.py): `agent/runtime.py`
- [Diagnostics](https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/diagnostics.py): `agent/diagnostics.py`
- [Logging](https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/logging_config.py): `agent/logging_config.py`
- [Version metadata](https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/version.py): `agent/version.py`

### Stream pipeline

- [RTSP discovery](https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/dvr_rtsp.py): `agent/dvr_rtsp.py`
- [Channel workers](https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/worker.py): `agent/worker.py`
- [FFmpeg command](https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/publisher.py): `agent/publisher.py`
- [MediaMTX config](https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/mediamtx_paths.py): `agent/mediamtx_paths.py`
- [Archive search](https://github.com/ivelytechnologies/se_analog_dvr_edge/blob/main/agent/dvr_archive.py): `agent/dvr_archive.py`

### External systems

- **DVR channels**
- **FFmpeg / ffprobe**
- **MediaMTX**
- **Cloud provisioning API**
- **Backend and dashboard**

### Other components

- **Site operator**

## Connections

- Site operator → Setup browser: configures (evidence: `README.md`)
- Setup browser → HTTP service: calls local API (evidence: `README.md`)
- HTTP service → Setup page: serves page (evidence: `agent/server.py`)
- HTTP service → Runtime orchestration: controls runtime (evidence: `agent/server.py`)
- HTTP service → Config validation: loads config (evidence: `agent/server.py`)
- HTTP service → Diagnostics: requests diagnostics (evidence: `agent/server.py`)
- HTTP service → Archive search: searches recordings (evidence: `agent/server.py`)
- HTTP service → Cloud provisioning API: requests provisioning (evidence: `agent/server.py`)
- HTTP service → Version metadata: serves version (evidence: `agent/server.py`)
- Setup browser → Cloud provisioning API: selects site data
- Runtime orchestration → Config validation: loads and validates (evidence: `agent/runtime.py`)
- Runtime orchestration → RTSP discovery: probes channels (evidence: `agent/runtime.py`)
- RTSP discovery → DVR channels: tests RTSP URLs (evidence: `agent/dvr_rtsp.py`)
- RTSP discovery → FFmpeg / ffprobe: runs ffprobe (evidence: `agent/dvr_rtsp.py`)
- Runtime orchestration → Channel workers: starts workers (evidence: `agent/runtime.py`)
- Channel workers → FFmpeg command: builds command (evidence: `agent/worker.py`)
- Channel workers → FFmpeg / ffprobe: runs and restarts (evidence: `agent/worker.py`)
- FFmpeg / ffprobe → MediaMTX: publishes streams (evidence: `README.md`)
- Runtime orchestration → MediaMTX config: registers paths (evidence: `agent/runtime.py`)
- MediaMTX config → MediaMTX: updates configuration (evidence: `agent/mediamtx_paths.py`)
- MediaMTX → Backend and dashboard: serves streams (evidence: `README.md`)
- Archive search → DVR channels: searches recordings (evidence: `agent/dvr_archive.py`)
- HTTP service → Logging: logs requests (evidence: `agent/server.py`)
- Channel workers → Logging: logs worker status (evidence: `agent/worker.py`)
- Runtime orchestration → Logging: logs runtime events (evidence: `agent/runtime.py`)
