# jemcats/ubox_camera_api architecture

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

- Interactive diagram: https://gitdiagram.com/jemcats/ubox_camera_api
- Repository: https://github.com/jemcats/ubox_camera_api

## Overview

uBox Camera API is a Node.js HTTP interface for authenticated camera-account queries and experimental live streaming. The main workflow is client request → server route handling → authenticated Ubia API call or stream-session control → JSON/video response. The README also documents device listing, SIM details, cloud recordings, event calendars, cloud-video URLs, and subscribed iOS devices. Streaming includes a camera datagram protocol path and H.264 delivery bridges. Sampled excerpts establish several core calls; unsampled route details are represented only at the documented capability level.

Main entry points: [`src/main/requests.js`](https://github.com/jemcats/ubox_camera_api/blob/main/src/main/requests.js) (API Routes), [`src/main/helpers.js`](https://github.com/jemcats/ubox_camera_api/blob/main/src/main/helpers.js) (Request Helpers), [`src/stream/ubox-live-stream.js`](https://github.com/jemcats/ubox_camera_api/blob/main/src/stream/ubox-live-stream.js) (Stream Manager), [`server.js`](https://github.com/jemcats/ubox_camera_api/blob/main/server.js) (HTTP Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_server["HTTP Server<br/>[server.js]"]
  node_routes["API Routes<br/>[requests.js]"]
  node_helpers["Request Helpers<br/>[helpers.js]"]
end

subgraph group_account["Account Data"]
  node_login["Login<br/>[requests.js]"]
  node_devices["Device Listing<br/>[requests.js]"]
  node_sim["SIM Information<br/>[requests.js]"]
  node_cloud["Cloud Recordings<br/>[requests.js]"]
  node_events["Event Calendar<br/>[requests.js]"]
  node_videourl["Cloud Video URL<br/>[requests.js]"]
  node_ios["iOS Subscriptions<br/>[requests.js]"]
end

subgraph group_stream["Live Streaming"]
  node_live["Stream Manager"]
  node_hls["HLS Bridge<br/>[h264-hls.js]"]
  node_rtsp["RTSP Bridge<br/>[h264-rtsp.js]"]
end

subgraph group_media["Media Processing"]
  node_p4p["P4P Protocol<br/>[p4p-codec.js]"]
  node_muxer["Live MP4 Muxer<br/>[live-mp4.js]"]
  node_codec["Video Detection<br/>[video-codec.js]"]
  node_mp4["MP4 Dump Builder<br/>[h264-mp4.js]"]
end

node_client(("API Client"))
node_ubia["Ubia Portal"]
node_camera["uBox Camera"]
node_media_client(("Stream Client"))
node_ffmpeg["FFmpeg"]

node_client -->|"sends HTTP"| node_server
node_server -->|"dispatches routes"| node_routes
node_server -->|"initializes login"| node_login
node_routes -->|"uses helpers"| node_helpers
node_login -->|"authenticates"| node_ubia
node_routes -->|"dispatches query"| node_devices
node_routes -->|"dispatches query"| node_sim
node_routes -->|"dispatches query"| node_cloud
node_routes -->|"dispatches query"| node_events
node_routes -->|"dispatches query"| node_videourl
node_routes -->|"dispatches query"| node_ios
node_devices -->|"requests data"| node_helpers
node_sim -->|"requests data"| node_helpers
node_cloud -->|"requests data"| node_helpers
node_events -->|"requests data"| node_helpers
node_videourl -->|"requests data"| node_helpers
node_ios -->|"requests data"| node_helpers
node_helpers -->|"calls portal"| node_ubia
node_routes -->|"controls session"| node_live
node_live -->|"exchanges datagrams"| node_camera
node_live -->|"encodes packets"| node_p4p
node_live -->|"muxes video"| node_muxer
node_live -->|"detects format"| node_codec
node_media_client -->|"requests stream"| node_server
node_routes -->|"handles HLS"| node_hls
node_routes -->|"configures RTSP"| node_rtsp
node_hls -.->|"starts transcoding"| node_ffmpeg
node_rtsp -.->|"starts transcoding"| node_ffmpeg
node_mp4 -->|"returns MP4"| node_media_client

click node_server "https://github.com/jemcats/ubox_camera_api/blob/main/server.js"
click node_routes "https://github.com/jemcats/ubox_camera_api/blob/main/src/main/requests.js"
click node_helpers "https://github.com/jemcats/ubox_camera_api/blob/main/src/main/helpers.js"
click node_login "https://github.com/jemcats/ubox_camera_api/blob/main/src/main/requests.js"
click node_devices "https://github.com/jemcats/ubox_camera_api/blob/main/src/main/requests.js"
click node_sim "https://github.com/jemcats/ubox_camera_api/blob/main/src/main/requests.js"
click node_cloud "https://github.com/jemcats/ubox_camera_api/blob/main/src/main/requests.js"
click node_events "https://github.com/jemcats/ubox_camera_api/blob/main/src/main/requests.js"
click node_videourl "https://github.com/jemcats/ubox_camera_api/blob/main/src/main/requests.js"
click node_ios "https://github.com/jemcats/ubox_camera_api/blob/main/src/main/requests.js"
click node_live "https://github.com/jemcats/ubox_camera_api/blob/main/src/stream/ubox-live-stream.js"
click node_p4p "https://github.com/jemcats/ubox_camera_api/blob/main/src/stream/p4p-codec.js"
click node_muxer "https://github.com/jemcats/ubox_camera_api/blob/main/src/stream/live-mp4.js"
click node_codec "https://github.com/jemcats/ubox_camera_api/blob/main/src/stream/video-codec.js"
click node_mp4 "https://github.com/jemcats/ubox_camera_api/blob/main/src/stream/h264-mp4.js"
click node_hls "https://github.com/jemcats/ubox_camera_api/blob/main/src/main/h264-hls.js"
click node_rtsp "https://github.com/jemcats/ubox_camera_api/blob/main/src/main/h264-rtsp.js"

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_server,node_routes,node_helpers,node_client,node_media_client toneBlue
class node_login,node_devices,node_sim,node_cloud,node_events,node_videourl,node_ios toneAmber
class node_live,node_hls,node_rtsp toneMint
class node_p4p,node_muxer,node_codec,node_mp4 toneRose
class node_ubia,node_camera,node_ffmpeg toneIndigo
```

## Components

### HTTP API

- [HTTP Server](https://github.com/jemcats/ubox_camera_api/blob/main/server.js): `server.js`
- [API Routes](https://github.com/jemcats/ubox_camera_api/blob/main/src/main/requests.js): `src/main/requests.js`
- [Request Helpers](https://github.com/jemcats/ubox_camera_api/blob/main/src/main/helpers.js): `src/main/helpers.js`

### Account Data

- [Login](https://github.com/jemcats/ubox_camera_api/blob/main/src/main/requests.js): `src/main/requests.js`
- [Device Listing](https://github.com/jemcats/ubox_camera_api/blob/main/src/main/requests.js): `src/main/requests.js`
- [SIM Information](https://github.com/jemcats/ubox_camera_api/blob/main/src/main/requests.js): `src/main/requests.js`
- [Cloud Recordings](https://github.com/jemcats/ubox_camera_api/blob/main/src/main/requests.js): `src/main/requests.js`
- [Event Calendar](https://github.com/jemcats/ubox_camera_api/blob/main/src/main/requests.js): `src/main/requests.js`
- [Cloud Video URL](https://github.com/jemcats/ubox_camera_api/blob/main/src/main/requests.js): `src/main/requests.js`
- [iOS Subscriptions](https://github.com/jemcats/ubox_camera_api/blob/main/src/main/requests.js): `src/main/requests.js`

### Live Streaming

- [Stream Manager](https://github.com/jemcats/ubox_camera_api/blob/main/src/stream/ubox-live-stream.js): `src/stream/ubox-live-stream.js`
- [HLS Bridge](https://github.com/jemcats/ubox_camera_api/blob/main/src/main/h264-hls.js): `src/main/h264-hls.js`
- [RTSP Bridge](https://github.com/jemcats/ubox_camera_api/blob/main/src/main/h264-rtsp.js): `src/main/h264-rtsp.js`

### Media Processing

- [P4P Protocol](https://github.com/jemcats/ubox_camera_api/blob/main/src/stream/p4p-codec.js): `src/stream/p4p-codec.js`
- [Live MP4 Muxer](https://github.com/jemcats/ubox_camera_api/blob/main/src/stream/live-mp4.js): `src/stream/live-mp4.js`
- [Video Detection](https://github.com/jemcats/ubox_camera_api/blob/main/src/stream/video-codec.js): `src/stream/video-codec.js`
- [MP4 Dump Builder](https://github.com/jemcats/ubox_camera_api/blob/main/src/stream/h264-mp4.js): `src/stream/h264-mp4.js`

### Other components

- **API Client**
- **Ubia Portal**
- **uBox Camera**
- **Stream Client**
- **FFmpeg**

## Connections

- API Client → HTTP Server: sends HTTP
- HTTP Server → API Routes: dispatches routes
- HTTP Server → Login: initializes login
- API Routes → Request Helpers: uses helpers
- Login → Ubia Portal: authenticates
- API Routes → Device Listing: dispatches query
- API Routes → SIM Information: dispatches query
- API Routes → Cloud Recordings: dispatches query
- API Routes → Event Calendar: dispatches query
- API Routes → Cloud Video URL: dispatches query
- API Routes → iOS Subscriptions: dispatches query
- Device Listing → Request Helpers: requests data
- SIM Information → Request Helpers: requests data
- Cloud Recordings → Request Helpers: requests data
- Event Calendar → Request Helpers: requests data
- Cloud Video URL → Request Helpers: requests data
- iOS Subscriptions → Request Helpers: requests data
- Request Helpers → Ubia Portal: calls portal
- API Routes → Stream Manager: controls session
- Stream Manager → uBox Camera: exchanges datagrams
- Stream Manager → P4P Protocol: encodes packets
- Stream Manager → Live MP4 Muxer: muxes video
- Stream Manager → Video Detection: detects format
- Stream Client → HTTP Server: requests stream
- API Routes → HLS Bridge: handles HLS
- API Routes → RTSP Bridge: configures RTSP
- HLS Bridge → FFmpeg: starts transcoding
- RTSP Bridge → FFmpeg: starts transcoding
- MP4 Dump Builder → Stream Client: returns MP4
