Edge AI Surveillance: Raspberry Pi, YOLO, MQTT, and the Parts Everyone Forgets

Cameras are cheap; the interesting work is what happens when they sit on unreliable networks. SentinelVision Edge turns Raspberry Pi cameras into an AI security fleet — YOLO inference at the edge, MediaMTX for video, MQTT for signals — and this post is about the architecture decisions that survived contact with reality.
Push the inference to the edge
The Pi agent runs person and face detection locally and publishes results, not frames. That single decision shapes everything else:
- The cloud never uploads raw video for detection.
- Occupancy and dwell-time logic runs where the pixels are.
- If the network drops, the node keeps counting; it syncs when it returns.
A domain-style layout (adapters/application/domain/infrastructure) keeps edge logic testable without a camera attached — use cases like "is the area full" are pure functions over detection frames.
MQTT topics are an API — design them like one
camera/{id}/status → online/offline + health
detection/{id}/people → counts + confidence
detection/{id}/materials → object counts
Two rules earned their keep. First, status is a heartbeat, not an event: offline detection is derived from missed heartbeats, not from a disconnect message that may never arrive. Second, reconnect logic is the feature. The original checklist had "reconnect/retry with backoff and error logging" as an unchecked box — on real networks it is the difference between a demo and a system.
Video is a separate plane
MediaMTX handles RTSP/WebRTC streams; the application talks to it over its REST API. Keeping video out of the app tier means a camera restart never takes down the control room, and the dashboard can show stream health as data rather than guessing from a frozen frame.
The parts most builds discover too late — and we've written them into the backlog on purpose:
- TURN servers. Users behind corporate firewalls cannot do WebRTC without them. STUN is not enough.
- Stream health checks and automatic restarts of failed camera streams.
- Rate limiting on public-facing endpoints, before an incident teaches you.
- Alert webhooks. Detection events are useless if nobody is told.
What the control room gets
A FastAPI backend (PostgreSQL + Redis + Celery) manages cameras, areas, recordings, and roles; a Vue 3 dashboard shows live status, counts, and dwell time with RBAC for admin and viewer roles. Real-time updates ride WebSockets on top of the same MQTT signals, so there is one source of truth.
Honest status
This is an MVP with a written backlog. The architecture is edge-to-cloud end to end — Pi → MQTT/WS → FastAPI → Vue — and the unchecked items list is published instead of hidden, because the next engineer deserves to know exactly where the floorboards are loose.
