This document explains how EdgeSentry works and why each component was chosen. It is written for reviewers and collaborators
Detection dataclass.Frame from camera
│
▼
┌──────────────┐
│ Detector │ YOLOv8n on Hailo NPU → bounding boxes + confidence
│ (14ms/frame)│
└──────┬───────┘
│
▼
┌──────────────┐
│ ReID │ ResNet on Hailo NPU → person embedding → person_id
└──────┬───────┘
│
▼
┌──────────────┐
│ ZoneMap │ Point-in-polygon test → zone name
└──────┬───────┘
│ Detection(bbox, confidence, person_id, zone)
│
▼
┌──────────────┐ ┌────────────────────┐
│ Ingestor │───────►│ EventStore │ SQLite — precise facts
│ (debounced) │ │ events.sqlite │
│ │ └────────────────────┘
│ │
│ │ ┌────────────────────┐
│ │───────►│ VectorStore │ ChromaDB — semantic memory
│ │ │ MiniLM embeddings │
└──────────────┘ └─────────┬──────────┘
│
│ retrieved context
▼
┌────────────────────┐
│ Agent │ Qwen2.5-3B via Ollama
│ ReAct loop: │
│ 1. read question │
│ 2. pick tool │
│ 3. call tool │
│ 4. answer │
└─────────┬──────────┘
│
┌─────────────┼─────────────┐
▼ ▼ ▼
Flask chat Telegram Journaler
(user asks) (alerts) (hourly self-
review → store)
| Model | Task | Latency | Power |
|---|---|---|---|
YOLOv8n .hef |
Person detection | ~14 ms/frame | <5 W NPU total |
ResNet ReID .hef |
Person re-identification | ~8 ms/crop |
Both run on the Hailo NPU. The CPU does not touch these workloads at all, leaving
room for the LLM. The perception loop runs in a daemon thread; it yields
Detection objects through the Ingestor.
A person standing in frame at 30 FPS would generate 1,800 events per minute. The
ingestor debounces by (person_id, zone) — a new event is only emitted once per
event_debounce_seconds (default 30s) for a given person in a given zone.
Zero-config, file-based, indexed on ts, zone, and person_id. Powers the
agent’s query_logs tool for questions like “how many people in the Front Gate
in the last 2 hours?” where an exact COUNT + WHERE is better than fuzzy search.
Each event is converted to a natural-language sentence
(“P-01 was detected in Front Gate at 14:03”) and embedded using
all-MiniLM-L6-v2 (384-dim, ~30ms/embed on Pi CPU). The embedding is stored in
a local ChromaDB (file-backed, HNSW index, cosine distance). Powers the agent’s
search_events tool for questions like “anything unusual near the back door?”
where semantic similarity beats exact keyword matching.
A quantised 3B-parameter LLM running on the Pi 5’s CPU. The ReAct loop:
max_tool_iterations (default 4), then returns the final text.Available tools:
| Tool | Backend | Best for |
|---|---|---|
search_events |
Vector store | Fuzzy, descriptive questions |
query_logs |
SQLite | Exact counts, time/zone/person filters |
send_alert |
Telegram API | User-requested notifications |
Every hour, the journaler pulls the last hour of raw event sentences, asks the
agent to summarise them into a single paragraph, and stores that paragraph back
into the vector store as a journal memory. This compresses thousands of raw
events into a few high-level narratives, giving the agent a growing long-term
memory that remains efficient to search.
Flask serves:
GET / — dashboard with live feed + chat box + recent events table.POST /api/chat — forwards the user’s message to the agent, returns the answer.GET /api/events — recent events JSON for the table.GET /api/health — LLM online/offline status.| Component | RAM | Notes |
|---|---|---|
| Hailo NPU runtime | ~200 MB | Off-loaded to NPU memory |
| MiniLM embedder | ~100 MB | Loaded lazily on first embed |
| ChromaDB | ~50 MB | HNSW index, grows with events |
| Ollama (Qwen 3B Q4) | ~2 GB | Largest single cost |
| Flask + Python | ~100 MB | |
| Total | ~2.5 GB | Fits comfortably on 4 GB Pi 5 |
The 128 GB storage is more than enough for months of event data, snapshots, and the vector index.
All tests are hardware-independent:
FakeEmbedder generates deterministic 8-dim vectors (no model download).FakeLLM returns scripted responses (no Ollama needed).EventStore tests use a temp-dir SQLite.This lets CI run on any GitHub Actions runner (Ubuntu x86) while the real system runs on aarch64 + Hailo.