# meatballs1/arlo-cam-api architecture

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

- Interactive diagram: https://gitdiagram.com/meatballs1/arlo-cam-api
- Repository: https://github.com/meatballs1/arlo-cam-api

## Overview

Arlo Cam API emulates an Arlo basestation so compatible cameras can connect and be controlled as RTSP sources. Cameras register and send status or alerts over TCP; the server processes those messages, persists camera state, acknowledges them, and can trigger recordings and motion webhooks. A separate REST API exposes camera status and controls, including recording, snapshots, audio, and activity zones. The excerpts show the main control and alert paths; Wi-Fi pairing is documented operational setup, not an implemented subsystem in the sampled runtime.

Main entry points: [`server.py`](https://github.com/meatballs1/arlo-cam-api/blob/master/server.py) (TCP server), [`arlo/camera.py`](https://github.com/meatballs1/arlo-cam-api/blob/master/arlo/camera.py) (Camera control), [`api/api.py`](https://github.com/meatballs1/arlo-cam-api/blob/master/api/api.py) (REST API), [`arlo/socket.py`](https://github.com/meatballs1/arlo-cam-api/blob/master/arlo/socket.py) (Socket framing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Service entry points"]
  node_server["TCP server<br/>[server.py]"]
  node_rest_api["REST API<br/>[api.py]"]
  node_snapshot_upload["Snapshot upload<br/>[api.py]"]
end

subgraph group_protocol["Camera protocol"]
  node_arlo_socket["Socket framing<br/>[socket.py]"]
  node_messages["Protocol messages<br/>[messages.py]"]
end

subgraph group_state["Camera control and state"]
  node_camera["Camera control<br/>[camera.py]"]
  node_camera_db[("Camera database<br/>[server.py]")]
end

subgraph group_media["Recording and alerts"]
  node_recorder["RTSP recorder<br/>[recorder.py]"]
  node_webhook["Motion webhook<br/>[webhook_manager.py]"]
end

node_api_client(("API client"))
node_camera_device(("Arlo camera"))
node_webhook_service(("Webhook receiver"))

node_api_client -->|"calls"| node_rest_api
node_rest_api -->|"controls"| node_camera
node_rest_api -->|"reads"| node_camera_db
node_server -->|"initializes"| node_camera_db
node_server -->|"receives"| node_arlo_socket
node_server -->|"builds"| node_messages
node_camera_device -.->|"sends events"| node_server
node_server -->|"updates"| node_camera
node_server -->|"persists"| node_camera_db
node_camera -->|"sends commands"| node_arlo_socket
node_arlo_socket -->|"encodes"| node_messages
node_camera -->|"creates"| node_messages
node_camera -->|"reads and writes"| node_camera_db
node_server -->|"starts recording"| node_recorder
node_camera -->|"starts recording"| node_recorder
node_recorder -->|"opens RTSP"| node_camera_device
node_server -->|"notifies motion"| node_webhook
node_webhook -->|"posts event"| node_webhook_service
node_api_client -->|"uploads image"| node_snapshot_upload

click node_server "https://github.com/meatballs1/arlo-cam-api/blob/master/server.py"
click node_rest_api "https://github.com/meatballs1/arlo-cam-api/blob/master/api/api.py"
click node_arlo_socket "https://github.com/meatballs1/arlo-cam-api/blob/master/arlo/socket.py"
click node_messages "https://github.com/meatballs1/arlo-cam-api/blob/master/arlo/messages.py"
click node_camera "https://github.com/meatballs1/arlo-cam-api/blob/master/arlo/camera.py"
click node_camera_db "https://github.com/meatballs1/arlo-cam-api/blob/master/server.py"
click node_recorder "https://github.com/meatballs1/arlo-cam-api/blob/master/helpers/recorder.py"
click node_webhook "https://github.com/meatballs1/arlo-cam-api/blob/master/helpers/webhook_manager.py"
click node_snapshot_upload "https://github.com/meatballs1/arlo-cam-api/blob/master/api/api.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_server,node_rest_api,node_snapshot_upload,node_api_client toneBlue
class node_arlo_socket,node_messages toneAmber
class node_camera,node_camera_db,node_webhook_service toneMint
class node_recorder,node_webhook toneRose
class node_camera_device toneIndigo
```

## Components

### Service entry points

- [TCP server](https://github.com/meatballs1/arlo-cam-api/blob/master/server.py): `server.py`
- [REST API](https://github.com/meatballs1/arlo-cam-api/blob/master/api/api.py): `api/api.py`
- [Snapshot upload](https://github.com/meatballs1/arlo-cam-api/blob/master/api/api.py): `api/api.py`

### Camera protocol

- [Socket framing](https://github.com/meatballs1/arlo-cam-api/blob/master/arlo/socket.py): `arlo/socket.py`
- [Protocol messages](https://github.com/meatballs1/arlo-cam-api/blob/master/arlo/messages.py): `arlo/messages.py`

### Camera control and state

- [Camera control](https://github.com/meatballs1/arlo-cam-api/blob/master/arlo/camera.py): `arlo/camera.py`
- [Camera database](https://github.com/meatballs1/arlo-cam-api/blob/master/server.py): `server.py`

### Recording and alerts

- [RTSP recorder](https://github.com/meatballs1/arlo-cam-api/blob/master/helpers/recorder.py): `helpers/recorder.py`
- [Motion webhook](https://github.com/meatballs1/arlo-cam-api/blob/master/helpers/webhook_manager.py): `helpers/webhook_manager.py`

### Other components

- **API client**
- **Arlo camera**
- **Webhook receiver**

## Connections

- API client → REST API: calls (evidence: `api/api.py`)
- REST API → Camera control: controls (evidence: `api/api.py`)
- REST API → Camera database: reads (evidence: `api/api.py`)
- TCP server → Camera database: initializes (evidence: `server.py`)
- TCP server → Socket framing: receives (evidence: `server.py`)
- TCP server → Protocol messages: builds (evidence: `server.py`)
- Arlo camera → TCP server: sends events (evidence: `README.md`)
- TCP server → Camera control: updates (evidence: `server.py`)
- TCP server → Camera database: persists (evidence: `server.py`)
- Camera control → Socket framing: sends commands (evidence: `arlo/camera.py`)
- Socket framing → Protocol messages: encodes (evidence: `arlo/socket.py`)
- Camera control → Protocol messages: creates (evidence: `arlo/camera.py`)
- Camera control → Camera database: reads and writes (evidence: `arlo/camera.py`)
- TCP server → RTSP recorder: starts recording (evidence: `server.py`)
- Camera control → RTSP recorder: starts recording (evidence: `arlo/camera.py`)
- RTSP recorder → Arlo camera: opens RTSP (evidence: `helpers/recorder.py`)
- TCP server → Motion webhook: notifies motion (evidence: `server.py`)
- Motion webhook → Webhook receiver: posts event (evidence: `helpers/webhook_manager.py`)
- API client → Snapshot upload: uploads image (evidence: `api/api.py`)
