# racmanmontes09-cyber/firmware-camera architecture

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

- Interactive diagram: https://gitdiagram.com/racmanmontes09-cyber/firmware-camera
- Repository: https://github.com/racmanmontes09-cyber/firmware-camera

## Overview

Project L.E.A.F. Camera combines ESP32 camera/audio firmware, LAN live-view endpoints, and a Go relay for remote camera streams. The main workflow captures video and audio, serves local viewers and telemetry, and can uplink to relay services; viewers receive streams through the relay. The README documents the dashboard, snapshots, controls, diagnostics, and backend heartbeat. Edges are limited to relationships visible in excerpts or the README; unsampled implementation details are not inferred.

Main entry points: [`src/main.cpp`](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/src/main.cpp) (Firmware Loop), [`relay/main.go`](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/relay/main.go) (Go Relay Server), [`include/StreamServer.h`](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/StreamServer.h) (HTTP Stream Server), [`include/CameraManager.h`](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/CameraManager.h) (Camera Capture)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Device Capture"]
  node_main["Firmware Loop<br/>[main.cpp]"]
  node_config["Device Configuration<br/>[Config.h]"]
  node_camera["Camera Capture<br/>[CameraManager.h]"]
  node_audio["Microphone Capture<br/>[AudioManager.h]"]
end

subgraph group_local["Local Experience"]
  node_localserver["HTTP Stream Server<br/>[StreamServer.h]"]
  node_dashboard["Live Dashboard<br/>[StreamServer.h]"]
  node_snapshot["JPEG Snapshot<br/>[StreamServer.h]"]
  node_telemetry["Status Telemetry<br/>[StreamServer.h]"]
  node_controls["Camera Controls<br/>[StreamServer.h]"]
end

subgraph group_uplink["Connectivity and Uplink"]
  node_wifi["Wi-Fi Manager<br/>[NetworkManager.h]"]
  node_heartbeat["Backend Heartbeat<br/>[main.cpp]"]
  node_relayclient["WebSocket Uplink<br/>[RelayClient.h]"]
  node_rtp["RTP Video Pusher<br/>[RtpPusher.h]"]
  node_tls["TLS Trust Anchor<br/>[TlsCertificates.h]"]
end

subgraph group_relay["Remote Relay"]
  node_relaysvc["Go Relay Server<br/>[main.go]"]
  node_auth["Camera Authentication<br/>[auth.go]"]
  node_sessions[("Camera Sessions<br/>[session.go]")]
  node_cameraapi["Camera WebSocket<br/>[camera.go]"]
  node_videostream["Video Stream Handler<br/>[stream.go]"]
  node_audiostream["Audio Stream Handler<br/>[audio.go]"]
  node_credentials["Credential Handler<br/>[credentials.go]"]
end

node_operator(("Camera Viewer"))
node_backend["Laravel Backend"]
node_relayviewer(("Remote Viewer"))
node_rtpreceiver["RTP Receiver"]

node_main -->|"manages"| node_camera
node_main -->|"manages"| node_audio
node_main -->|"manages"| node_wifi
node_main -->|"monitors"| node_localserver
node_main -->|"checks status"| node_relayclient
node_main -->|"runs"| node_heartbeat
node_main -->|"uses"| node_config
node_localserver -->|"streams frames"| node_camera
node_localserver -->|"serves audio"| node_audio
node_operator -->|"opens"| node_dashboard
node_dashboard -->|"requests"| node_localserver
node_operator -->|"requests"| node_snapshot
node_snapshot -->|"handled by"| node_localserver
node_operator -->|"requests"| node_telemetry
node_telemetry -->|"handled by"| node_localserver
node_operator -->|"adjusts"| node_controls
node_controls -->|"sets quality"| node_camera
node_heartbeat -->|"posts heartbeat"| node_backend
node_relayclient -->|"uses trust"| node_tls
node_relayclient -->|"connects by WSS"| node_relaysvc
node_rtp -->|"captures frames"| node_camera
node_rtp -.->|"sends RTP"| node_rtpreceiver
node_relaysvc -->|"routes camera"| node_auth
node_relaysvc -->|"routes stream"| node_videostream
node_relaysvc -->|"routes audio"| node_audiostream
node_relaysvc -->|"routes credentials"| node_credentials
node_relaysvc -->|"creates manager"| node_sessions
node_relayviewer -.->|"requests streams"| node_relaysvc

click node_main "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/src/main.cpp"
click node_config "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/Config.h"
click node_camera "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/CameraManager.h"
click node_audio "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/AudioManager.h"
click node_wifi "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/NetworkManager.h"
click node_localserver "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/StreamServer.h"
click node_dashboard "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/StreamServer.h"
click node_snapshot "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/StreamServer.h"
click node_telemetry "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/StreamServer.h"
click node_controls "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/StreamServer.h"
click node_heartbeat "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/src/main.cpp"
click node_relayclient "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/RelayClient.h"
click node_rtp "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/RtpPusher.h"
click node_tls "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/TlsCertificates.h"
click node_relaysvc "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/relay/main.go"
click node_auth "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/relay/auth.go"
click node_sessions "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/relay/session.go"
click node_cameraapi "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/relay/camera.go"
click node_videostream "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/relay/stream.go"
click node_audiostream "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/relay/audio.go"
click node_credentials "https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/relay/credentials.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_main,node_config,node_camera,node_audio,node_operator,node_relayviewer toneBlue
class node_localserver,node_dashboard,node_snapshot,node_telemetry,node_controls toneAmber
class node_wifi,node_heartbeat,node_relayclient,node_rtp,node_tls toneMint
class node_relaysvc,node_auth,node_sessions,node_cameraapi,node_videostream,node_audiostream,node_credentials toneRose
class node_backend,node_rtpreceiver toneIndigo
```

## Components

### Device Capture

- [Firmware Loop](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/src/main.cpp): `src/main.cpp`
- [Device Configuration](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/Config.h): `include/Config.h`
- [Camera Capture](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/CameraManager.h): `include/CameraManager.h`
- [Microphone Capture](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/AudioManager.h): `include/AudioManager.h`

### Local Experience

- [HTTP Stream Server](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/StreamServer.h): `include/StreamServer.h`
- [Live Dashboard](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/StreamServer.h): `include/StreamServer.h`
- [JPEG Snapshot](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/StreamServer.h): `include/StreamServer.h`
- [Status Telemetry](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/StreamServer.h): `include/StreamServer.h`
- [Camera Controls](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/StreamServer.h): `include/StreamServer.h`

### Connectivity and Uplink

- [Wi-Fi Manager](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/NetworkManager.h): `include/NetworkManager.h`
- [Backend Heartbeat](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/src/main.cpp): `src/main.cpp`
- [WebSocket Uplink](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/RelayClient.h): `include/RelayClient.h`
- [RTP Video Pusher](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/RtpPusher.h): `include/RtpPusher.h`
- [TLS Trust Anchor](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/include/TlsCertificates.h): `include/TlsCertificates.h`

### Remote Relay

- [Go Relay Server](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/relay/main.go): `relay/main.go`
- [Camera Authentication](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/relay/auth.go): `relay/auth.go`
- [Camera Sessions](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/relay/session.go): `relay/session.go`
- [Camera WebSocket](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/relay/camera.go): `relay/camera.go`
- [Video Stream Handler](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/relay/stream.go): `relay/stream.go`
- [Audio Stream Handler](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/relay/audio.go): `relay/audio.go`
- [Credential Handler](https://github.com/racmanmontes09-cyber/firmware-camera/blob/main/relay/credentials.go): `relay/credentials.go`

### Other components

- **Camera Viewer**
- **Laravel Backend**
- **Remote Viewer**
- **RTP Receiver**

## Connections

- Firmware Loop → Camera Capture: manages (evidence: `src/main.cpp`)
- Firmware Loop → Microphone Capture: manages (evidence: `src/main.cpp`)
- Firmware Loop → Wi-Fi Manager: manages (evidence: `src/main.cpp`)
- Firmware Loop → HTTP Stream Server: monitors (evidence: `src/main.cpp`)
- Firmware Loop → WebSocket Uplink: checks status (evidence: `src/main.cpp`)
- Firmware Loop → Backend Heartbeat: runs (evidence: `src/main.cpp`)
- Firmware Loop → Device Configuration: uses (evidence: `src/main.cpp`)
- HTTP Stream Server → Camera Capture: streams frames (evidence: `include/StreamServer.h`)
- HTTP Stream Server → Microphone Capture: serves audio (evidence: `include/StreamServer.h`)
- Camera Viewer → Live Dashboard: opens (evidence: `README.md`)
- Live Dashboard → HTTP Stream Server: requests (evidence: `include/StreamServer.h`)
- Camera Viewer → JPEG Snapshot: requests (evidence: `README.md`)
- JPEG Snapshot → HTTP Stream Server: handled by (evidence: `README.md`)
- Camera Viewer → Status Telemetry: requests (evidence: `README.md`)
- Status Telemetry → HTTP Stream Server: handled by (evidence: `README.md`)
- Camera Viewer → Camera Controls: adjusts (evidence: `include/StreamServer.h`)
- Camera Controls → Camera Capture: sets quality (evidence: `include/StreamServer.h`)
- Backend Heartbeat → Laravel Backend: posts heartbeat (evidence: `src/main.cpp`)
- WebSocket Uplink → TLS Trust Anchor: uses trust (evidence: `include/RelayClient.h`)
- WebSocket Uplink → Go Relay Server: connects by WSS (evidence: `include/RelayClient.h`)
- RTP Video Pusher → Camera Capture: captures frames (evidence: `include/RtpPusher.h`)
- RTP Video Pusher → RTP Receiver: sends RTP
- Go Relay Server → Camera Authentication: routes camera (evidence: `relay/main.go`)
- Go Relay Server → Video Stream Handler: routes stream (evidence: `relay/main.go`)
- Go Relay Server → Audio Stream Handler: routes audio (evidence: `relay/main.go`)
- Go Relay Server → Credential Handler: routes credentials (evidence: `relay/main.go`)
- Go Relay Server → Camera Sessions: creates manager (evidence: `relay/main.go`)
- Remote Viewer → Go Relay Server: requests streams
