# dhanush7git/rstp architecture

> Architecture diagram of the GitHub repository dhanush7git/rstp, 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/dhanush7git/rstp
- Repository: https://github.com/dhanush7git/rstp

## Overview

KAVACH’s RTSP simulator turns configured video files into LAN-accessible camera streams. The main workflow loads and validates configuration, starts MediaMTX, launches one looping FFmpeg publisher per enabled camera, and exposes each stream for KAVACH clients. Separate commands validate local assets and probe server and stream reachability; synthetic CCTV footage is also available for demonstrations. The graph reflects the sampled runtime modules and README-described capabilities; video generation and binary setup are shown as separate supporting branches.

Main entry points: [`src/main.py`](https://github.com/dhanush7git/rstp/blob/main/src/main.py) (Command interface), [`src/stream_publisher.py`](https://github.com/dhanush7git/rstp/blob/main/src/stream_publisher.py) (Process manager), [`mediamtx`](https://github.com/dhanush7git/rstp/tree/main/mediamtx) (MediaMTX server), [`src/health_check.py`](https://github.com/dhanush7git/rstp/blob/main/src/health_check.py) (Connectivity checks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Runtime orchestration"]
  node_cli["Command interface<br/>[main.py]"]
  node_configuration["Config and validation<br/>[config.py]"]
  node_settings["Simulator settings<br/>[config.yaml]"]
  node_process_manager["Process manager"]
end

subgraph group_streaming["RTSP streaming"]
  node_mediamtx_config["Generated server config"]
  node_mediamtx["MediaMTX server"]
  node_publisher["FFmpeg publishers"]
  node_ffmpeg["FFmpeg"]
  node_videos[("Camera video files")]
  node_rtsp["RTSP camera streams"]
end

subgraph group_operations["Setup and checks"]
  node_health["Connectivity checks<br/>[health_check.py]"]
  node_setup["MediaMTX setup<br/>[setup_binaries.py]"]
end

subgraph group_demo["Demo media"]
  node_video_generator["Synthetic video generator"]
  node_demo_videos[("Generated CCTV videos")]
end

node_operator(("Operator"))
node_kavach(("KAVACH client"))
node_mediamtx_release["MediaMTX release"]

node_operator -->|"runs commands"| node_cli
node_cli -->|"loads settings"| node_configuration
node_settings -->|"defines cameras"| node_configuration
node_cli -->|"starts processes"| node_process_manager
node_process_manager -->|"writes config"| node_mediamtx_config
node_process_manager -->|"starts server"| node_mediamtx
node_process_manager -->|"starts publishers"| node_publisher
node_publisher -->|"launches"| node_ffmpeg
node_ffmpeg -->|"reads clips"| node_videos
node_ffmpeg -->|"publishes streams"| node_rtsp
node_mediamtx -->|"reads config"| node_mediamtx_config
node_mediamtx -->|"serves streams"| node_rtsp
node_kavach -->|"connects to"| node_rtsp
node_operator -->|"runs probes"| node_health
node_cli -->|"runs checks"| node_health
node_health -->|"probes streams"| node_rtsp
node_operator -.->|"requests setup"| node_setup
node_setup -.->|"downloads binary"| node_mediamtx_release
node_operator -.->|"generates footage"| node_video_generator
node_video_generator -.->|"writes videos"| node_demo_videos
node_demo_videos -.->|"provides clips"| node_videos

click node_cli "https://github.com/dhanush7git/rstp/blob/main/src/main.py"
click node_configuration "https://github.com/dhanush7git/rstp/blob/main/src/config.py"
click node_settings "https://github.com/dhanush7git/rstp/blob/main/config.yaml"
click node_process_manager "https://github.com/dhanush7git/rstp/blob/main/src/stream_publisher.py"
click node_mediamtx_config "https://github.com/dhanush7git/rstp/blob/main/src/stream_publisher.py"
click node_mediamtx "https://github.com/dhanush7git/rstp/tree/main/mediamtx"
click node_publisher "https://github.com/dhanush7git/rstp/blob/main/src/stream_publisher.py"
click node_videos "https://github.com/dhanush7git/rstp/tree/main/videos"
click node_health "https://github.com/dhanush7git/rstp/blob/main/src/health_check.py"
click node_setup "https://github.com/dhanush7git/rstp/blob/main/src/setup_binaries.py"
click node_video_generator "https://github.com/dhanush7git/rstp/blob/main/src/generate_test_videos.py"
click node_demo_videos "https://github.com/dhanush7git/rstp/tree/main/videos"

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_cli,node_configuration,node_settings,node_process_manager,node_kavach toneBlue
class node_mediamtx_config,node_mediamtx,node_publisher,node_ffmpeg,node_videos,node_rtsp toneAmber
class node_health,node_setup toneMint
class node_video_generator,node_demo_videos toneRose
class node_operator,node_mediamtx_release toneIndigo
```

## Components

### Runtime orchestration

- [Command interface](https://github.com/dhanush7git/rstp/blob/main/src/main.py): `src/main.py`
- [Config and validation](https://github.com/dhanush7git/rstp/blob/main/src/config.py): `src/config.py`
- [Simulator settings](https://github.com/dhanush7git/rstp/blob/main/config.yaml): `config.yaml`
- [Process manager](https://github.com/dhanush7git/rstp/blob/main/src/stream_publisher.py): `src/stream_publisher.py`

### RTSP streaming

- [Generated server config](https://github.com/dhanush7git/rstp/blob/main/src/stream_publisher.py): `src/stream_publisher.py`
- [MediaMTX server](https://github.com/dhanush7git/rstp/tree/main/mediamtx): `mediamtx`
- [FFmpeg publishers](https://github.com/dhanush7git/rstp/blob/main/src/stream_publisher.py): `src/stream_publisher.py`
- **FFmpeg**
- [Camera video files](https://github.com/dhanush7git/rstp/tree/main/videos): `videos`
- **RTSP camera streams**

### Setup and checks

- [Connectivity checks](https://github.com/dhanush7git/rstp/blob/main/src/health_check.py): `src/health_check.py`
- [MediaMTX setup](https://github.com/dhanush7git/rstp/blob/main/src/setup_binaries.py): `src/setup_binaries.py`

### Demo media

- [Synthetic video generator](https://github.com/dhanush7git/rstp/blob/main/src/generate_test_videos.py): `src/generate_test_videos.py`
- [Generated CCTV videos](https://github.com/dhanush7git/rstp/tree/main/videos): `videos`

### Other components

- **Operator**
- **KAVACH client**
- **MediaMTX release**

## Connections

- Operator → Command interface: runs commands
- Command interface → Config and validation: loads settings
- Simulator settings → Config and validation: defines cameras
- Command interface → Process manager: starts processes
- Process manager → Generated server config: writes config
- Process manager → MediaMTX server: starts server
- Process manager → FFmpeg publishers: starts publishers
- FFmpeg publishers → FFmpeg: launches
- FFmpeg → Camera video files: reads clips
- FFmpeg → RTSP camera streams: publishes streams
- MediaMTX server → Generated server config: reads config
- MediaMTX server → RTSP camera streams: serves streams
- KAVACH client → RTSP camera streams: connects to
- Operator → Connectivity checks: runs probes
- Command interface → Connectivity checks: runs checks
- Connectivity checks → RTSP camera streams: probes streams
- Operator → MediaMTX setup: requests setup
- MediaMTX setup → MediaMTX release: downloads binary
- Operator → Synthetic video generator: generates footage
- Synthetic video generator → Generated CCTV videos: writes videos
- Generated CCTV videos → Camera video files: provides clips
