# openipc/divinus architecture

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

- Interactive diagram: https://gitdiagram.com/openipc/divinus
- Repository: https://github.com/openipc/divinus

## Overview

Divinus is a multi-platform camera streamer. Its main workflow loads configuration, starts networking and server services, initializes the SoC SDK and media capture, then exposes configured streams and camera features. The graph groups the chip-specific HAL implementations together and retains the documented streaming, snapshot, overlay, recording, ONVIF, and night-mode capabilities. Relationships beyond the shown startup calls are dashed where their runtime wiring was not excerpted; unsampled implementation details are not asserted.

Main entry points: [`src/main.c`](https://github.com/openipc/divinus/blob/master/src/main.c) (Startup and lifecycle), [`src/media.c`](https://github.com/openipc/divinus/blob/master/src/media.c) (Media capture and control), [`src/network.c`](https://github.com/openipc/divinus/blob/master/src/network.c) (Network services), [`src/http_post.c`](https://github.com/openipc/divinus/blob/master/src/http_post.c) (HTTP image posting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application runtime"]
  node_main["Startup and lifecycle<br/>[main.c]"]
  node_config["Application configuration<br/>[app_config.c]"]
end

subgraph group_hardware["Camera hardware"]
  node_hal["SoC hardware abstraction<br/>[support.c]"]
  node_chip_hal["Chip-family HALs"]
end

subgraph group_delivery["Media delivery"]
  node_media["Media capture and control<br/>[media.c]"]
  node_stream["Stream handling<br/>[stream.c]"]
  node_formats["MP4 and FLV formats"]
  node_jpeg["JPEG snapshots<br/>[jpeg.c]"]
  node_audio["MP3 encoding<br/>[layer3.c]"]
  node_recording["Segment recording<br/>[record.c]"]
  node_http_post["HTTP image posting<br/>[http_post.c]"]
end

subgraph group_protocols["Network services"]
  node_server["Web server<br/>[server.c]"]
  node_network["Network services<br/>[network.c]"]
  node_mdns["Service discovery<br/>[tinysvcmdns.c]"]
  node_onvif["ONVIF<br/>[onvif.c]"]
  node_rtsp["RTSP control<br/>[rtsp.c]"]
  node_rtp["RTP media transport<br/>[rtp.c]"]
end

subgraph group_features["Camera features"]
  node_region["On-screen overlays<br/>[region.c]"]
  node_night["Night mode<br/>[night.c]"]
  node_watchdog["Watchdog<br/>[watchdog.c]"]
  node_png["PNG decoding<br/>[spng.c]"]
  node_compression["Compression support<br/>[miniz.c]"]
end

node_operator(("Camera operator"))
node_external_stream_client(("Stream client"))
node_external_post_server(("HTTP endpoint"))

node_operator -->|"starts"| node_main
node_main -->|"loads"| node_config
node_main -->|"starts"| node_network
node_main -->|"starts"| node_server
node_main -->|"starts"| node_media
node_main -->|"creates"| node_rtsp
node_main -->|"starts SDK"| node_hal
node_main -->|"enables"| node_night
node_main -->|"starts"| node_region
node_main -->|"starts"| node_http_post
node_main -->|"starts"| node_recording
node_network -.->|"may use"| node_mdns
node_network -.->|"may serve"| node_onvif
node_media -.->|"captures via"| node_chip_hal
node_hal -.->|"selects implementation"| node_chip_hal
node_media -.->|"produces streams"| node_stream
node_rtsp -.->|"dispatches media"| node_rtp
node_media -.->|"supports fMP4"| node_formats
node_media -.->|"supports snapshots"| node_jpeg
node_media -.->|"encodes audio"| node_audio
node_server -.->|"offers recording"| node_recording
node_media -.->|"may post images"| node_http_post
node_region -.->|"may decode overlays"| node_png
node_png -.->|"uses compression"| node_compression
node_external_stream_client -.->|"requests stream"| node_rtsp
node_http_post -.->|"posts images"| node_external_post_server
node_main -.->|"may start"| node_watchdog

click node_main "https://github.com/openipc/divinus/blob/master/src/main.c"
click node_config "https://github.com/openipc/divinus/blob/master/src/app_config.c"
click node_server "https://github.com/openipc/divinus/blob/master/src/server.c"
click node_network "https://github.com/openipc/divinus/blob/master/src/network.c"
click node_mdns "https://github.com/openipc/divinus/blob/master/src/lib/tinysvcmdns.c"
click node_onvif "https://github.com/openipc/divinus/blob/master/src/onvif.c"
click node_rtsp "https://github.com/openipc/divinus/blob/master/src/rtsp/rtsp.c"
click node_rtp "https://github.com/openipc/divinus/blob/master/src/rtsp/rtp.c"
click node_media "https://github.com/openipc/divinus/blob/master/src/media.c"
click node_hal "https://github.com/openipc/divinus/blob/master/src/hal/support.c"
click node_chip_hal "https://github.com/openipc/divinus/tree/master/src/hal"
click node_stream "https://github.com/openipc/divinus/blob/master/src/stream.c"
click node_formats "https://github.com/openipc/divinus/tree/master/src/fmt"
click node_jpeg "https://github.com/openipc/divinus/blob/master/src/jpeg.c"
click node_audio "https://github.com/openipc/divinus/blob/master/src/lib/shine/layer3.c"
click node_recording "https://github.com/openipc/divinus/blob/master/src/record.c"
click node_http_post "https://github.com/openipc/divinus/blob/master/src/http_post.c"
click node_region "https://github.com/openipc/divinus/blob/master/src/region.c"
click node_night "https://github.com/openipc/divinus/blob/master/src/night.c"
click node_watchdog "https://github.com/openipc/divinus/blob/master/src/watchdog.c"
click node_png "https://github.com/openipc/divinus/blob/master/src/lib/spng.c"
click node_compression "https://github.com/openipc/divinus/blob/master/src/lib/miniz/miniz.c"

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_main,node_config,node_external_stream_client toneBlue
class node_hal,node_chip_hal toneAmber
class node_media,node_stream,node_formats,node_jpeg,node_audio,node_recording,node_http_post toneMint
class node_server,node_network,node_mdns,node_onvif,node_rtsp,node_rtp toneRose
class node_region,node_night,node_watchdog,node_png,node_compression,node_operator,node_external_post_server toneIndigo
```

## Components

### Application runtime

- [Startup and lifecycle](https://github.com/openipc/divinus/blob/master/src/main.c): `src/main.c`
- [Application configuration](https://github.com/openipc/divinus/blob/master/src/app_config.c): `src/app_config.c`

### Camera hardware

- [SoC hardware abstraction](https://github.com/openipc/divinus/blob/master/src/hal/support.c): `src/hal/support.c`
- [Chip-family HALs](https://github.com/openipc/divinus/tree/master/src/hal): `src/hal`

### Media delivery

- [Media capture and control](https://github.com/openipc/divinus/blob/master/src/media.c): `src/media.c`
- [Stream handling](https://github.com/openipc/divinus/blob/master/src/stream.c): `src/stream.c`
- [MP4 and FLV formats](https://github.com/openipc/divinus/tree/master/src/fmt): `src/fmt`
- [JPEG snapshots](https://github.com/openipc/divinus/blob/master/src/jpeg.c): `src/jpeg.c`
- [MP3 encoding](https://github.com/openipc/divinus/blob/master/src/lib/shine/layer3.c): `src/lib/shine/layer3.c`
- [Segment recording](https://github.com/openipc/divinus/blob/master/src/record.c): `src/record.c`
- [HTTP image posting](https://github.com/openipc/divinus/blob/master/src/http_post.c): `src/http_post.c`

### Network services

- [Web server](https://github.com/openipc/divinus/blob/master/src/server.c): `src/server.c`
- [Network services](https://github.com/openipc/divinus/blob/master/src/network.c): `src/network.c`
- [Service discovery](https://github.com/openipc/divinus/blob/master/src/lib/tinysvcmdns.c): `src/lib/tinysvcmdns.c`
- [ONVIF](https://github.com/openipc/divinus/blob/master/src/onvif.c): `src/onvif.c`
- [RTSP control](https://github.com/openipc/divinus/blob/master/src/rtsp/rtsp.c): `src/rtsp/rtsp.c`
- [RTP media transport](https://github.com/openipc/divinus/blob/master/src/rtsp/rtp.c): `src/rtsp/rtp.c`

### Camera features

- [On-screen overlays](https://github.com/openipc/divinus/blob/master/src/region.c): `src/region.c`
- [Night mode](https://github.com/openipc/divinus/blob/master/src/night.c): `src/night.c`
- [Watchdog](https://github.com/openipc/divinus/blob/master/src/watchdog.c): `src/watchdog.c`
- [PNG decoding](https://github.com/openipc/divinus/blob/master/src/lib/spng.c): `src/lib/spng.c`
- [Compression support](https://github.com/openipc/divinus/blob/master/src/lib/miniz/miniz.c): `src/lib/miniz/miniz.c`

### Other components

- **Camera operator**
- **Stream client**
- **HTTP endpoint**

## Connections

- Camera operator → Startup and lifecycle: starts (evidence: `src/main.c`)
- Startup and lifecycle → Application configuration: loads (evidence: `src/main.c`)
- Startup and lifecycle → Network services: starts (evidence: `src/main.c`)
- Startup and lifecycle → Web server: starts (evidence: `src/main.c`)
- Startup and lifecycle → Media capture and control: starts (evidence: `src/main.c`)
- Startup and lifecycle → RTSP control: creates (evidence: `src/main.c`)
- Startup and lifecycle → SoC hardware abstraction: starts SDK (evidence: `src/main.c`)
- Startup and lifecycle → Night mode: enables (evidence: `src/main.c`)
- Startup and lifecycle → On-screen overlays: starts (evidence: `src/main.c`)
- Startup and lifecycle → HTTP image posting: starts (evidence: `src/main.c`)
- Startup and lifecycle → Segment recording: starts (evidence: `src/main.c`)
- Network services → Service discovery: may use
- Network services → ONVIF: may serve
- Media capture and control → Chip-family HALs: captures via
- SoC hardware abstraction → Chip-family HALs: selects implementation
- Media capture and control → Stream handling: produces streams
- RTSP control → RTP media transport: dispatches media
- Media capture and control → MP4 and FLV formats: supports fMP4
- Media capture and control → JPEG snapshots: supports snapshots
- Media capture and control → MP3 encoding: encodes audio
- Web server → Segment recording: offers recording
- Media capture and control → HTTP image posting: may post images
- On-screen overlays → PNG decoding: may decode overlays
- PNG decoding → Compression support: uses compression
- Stream client → RTSP control: requests stream
- HTTP image posting → HTTP endpoint: posts images
- Startup and lifecycle → Watchdog: may start
