# danish-m-qureshi/ai-surveillance-drone architecture

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

- Interactive diagram: https://gitdiagram.com/danish-m-qureshi/ai-surveillance-drone
- Repository: https://github.com/danish-m-qureshi/ai-surveillance-drone

## Overview

This is a local-first Raspberry Pi camera application with CLI workflows for diagnostics, still capture, motion monitoring, and YOLO object detection on images or live frames. The CLI owns capture and processing calls, writes annotated images and event summaries, and uses reusable camera, motion, and detection modules. The detector’s preprocessing, ONNX inference, and result parsing are distinct internal stages. README capabilities not evidenced in sampled implementation are shown only where documented; relationships are limited to the excerpts and README.

Main entry points: [`surveillance.py`](https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/surveillance.py) (Command entry), [`ai_surveillance/detection.py`](https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/ai_surveillance/detection.py) (ONNX detector), [`ai_surveillance/camera.py`](https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/ai_surveillance/camera.py) (Camera lifecycle), [`artifacts`](https://github.com/danish-m-qureshi/ai-surveillance-drone/tree/main/artifacts) (Generated artifacts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflows"]
  node_entry["Command entry<br/>[surveillance.py]"]
  node_diagnostics["Camera diagnostics<br/>[surveillance.py]"]
  node_still["Still capture<br/>[surveillance.py]"]
  node_monitor["Motion monitor<br/>[surveillance.py]"]
  node_image_detect["Image detection<br/>[surveillance.py]"]
  node_live_detect["Live detection<br/>[surveillance.py]"]
end

subgraph group_camera["Camera lifecycle"]
  node_camera_api["Camera lifecycle<br/>[camera.py]"]
end

subgraph group_motion["Motion analysis"]
  node_motion_engine["Motion analysis<br/>[motion.py]"]
  node_motion_annotate["Motion annotation<br/>[motion.py]"]
end

subgraph group_ai["AI detection"]
  node_detector["ONNX detector<br/>[detection.py]"]
  node_preprocess["Frame preprocessing<br/>[detection.py]"]
  node_parse["Detection parsing<br/>[detection.py]"]
  node_ai_annotate["Detection annotation<br/>[detection.py]"]
  node_model["YOLO model"]
end

subgraph group_results["Local results"]
  node_artifacts["Generated artifacts"]
end

node_operator(("Operator"))
node_camera_hardware["Pi camera"]
node_onnx_runtime["ONNX Runtime"]

node_operator -->|"runs command"| node_entry
node_entry -->|"dispatches"| node_diagnostics
node_entry -->|"dispatches"| node_still
node_entry -->|"dispatches"| node_monitor
node_entry -->|"dispatches"| node_image_detect
node_entry -->|"dispatches"| node_live_detect
node_diagnostics -->|"discovers cameras"| node_camera_api
node_still -->|"opens camera"| node_camera_api
node_monitor -->|"opens camera"| node_camera_api
node_live_detect -->|"opens camera"| node_camera_api
node_camera_api -->|"controls camera"| node_camera_hardware
node_monitor -->|"analyzes frames"| node_motion_engine
node_monitor -->|"annotates result"| node_motion_annotate
node_image_detect -->|"detects objects"| node_detector
node_live_detect -->|"detects objects"| node_detector
node_detector -->|"prepares frame"| node_preprocess
node_detector -->|"runs inference"| node_onnx_runtime
node_detector -->|"parses output"| node_parse
node_detector -->|"loads model"| node_model
node_image_detect -->|"annotates result"| node_ai_annotate
node_live_detect -->|"annotates result"| node_ai_annotate
node_still -->|"writes capture"| node_artifacts
node_monitor -->|"writes evidence"| node_artifacts
node_image_detect -->|"writes annotated image"| node_artifacts
node_live_detect -->|"writes events and images"| node_artifacts

click node_entry "https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/surveillance.py"
click node_diagnostics "https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/surveillance.py"
click node_still "https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/surveillance.py"
click node_monitor "https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/surveillance.py"
click node_image_detect "https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/surveillance.py"
click node_live_detect "https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/surveillance.py"
click node_camera_api "https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/ai_surveillance/camera.py"
click node_motion_engine "https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/ai_surveillance/motion.py"
click node_motion_annotate "https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/ai_surveillance/motion.py"
click node_detector "https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/ai_surveillance/detection.py"
click node_preprocess "https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/ai_surveillance/detection.py"
click node_parse "https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/ai_surveillance/detection.py"
click node_ai_annotate "https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/ai_surveillance/detection.py"
click node_model "https://github.com/danish-m-qureshi/ai-surveillance-drone/tree/main/models"
click node_artifacts "https://github.com/danish-m-qureshi/ai-surveillance-drone/tree/main/artifacts"

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_entry,node_diagnostics,node_still,node_monitor,node_image_detect,node_live_detect toneBlue
class node_camera_api toneAmber
class node_motion_engine,node_motion_annotate toneMint
class node_detector,node_preprocess,node_parse,node_ai_annotate,node_model toneRose
class node_artifacts,node_operator,node_camera_hardware,node_onnx_runtime toneIndigo
```

## Components

### CLI workflows

- [Command entry](https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/surveillance.py): `surveillance.py`
- [Camera diagnostics](https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/surveillance.py): `surveillance.py`
- [Still capture](https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/surveillance.py): `surveillance.py`
- [Motion monitor](https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/surveillance.py): `surveillance.py`
- [Image detection](https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/surveillance.py): `surveillance.py`
- [Live detection](https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/surveillance.py): `surveillance.py`

### Camera lifecycle

- [Camera lifecycle](https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/ai_surveillance/camera.py): `ai_surveillance/camera.py`

### Motion analysis

- [Motion analysis](https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/ai_surveillance/motion.py): `ai_surveillance/motion.py`
- [Motion annotation](https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/ai_surveillance/motion.py): `ai_surveillance/motion.py`

### AI detection

- [ONNX detector](https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/ai_surveillance/detection.py): `ai_surveillance/detection.py`
- [Frame preprocessing](https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/ai_surveillance/detection.py): `ai_surveillance/detection.py`
- [Detection parsing](https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/ai_surveillance/detection.py): `ai_surveillance/detection.py`
- [Detection annotation](https://github.com/danish-m-qureshi/ai-surveillance-drone/blob/main/ai_surveillance/detection.py): `ai_surveillance/detection.py`
- [YOLO model](https://github.com/danish-m-qureshi/ai-surveillance-drone/tree/main/models): `models`

### Local results

- [Generated artifacts](https://github.com/danish-m-qureshi/ai-surveillance-drone/tree/main/artifacts): `artifacts`

### Other components

- **Operator**
- **Pi camera**
- **ONNX Runtime**

## Connections

- Operator → Command entry: runs command (evidence: `README.md`)
- Command entry → Camera diagnostics: dispatches (evidence: `surveillance.py`)
- Command entry → Still capture: dispatches (evidence: `surveillance.py`)
- Command entry → Motion monitor: dispatches (evidence: `surveillance.py`)
- Command entry → Image detection: dispatches (evidence: `surveillance.py`)
- Command entry → Live detection: dispatches (evidence: `surveillance.py`)
- Camera diagnostics → Camera lifecycle: discovers cameras (evidence: `surveillance.py`)
- Still capture → Camera lifecycle: opens camera (evidence: `surveillance.py`)
- Motion monitor → Camera lifecycle: opens camera (evidence: `surveillance.py`)
- Live detection → Camera lifecycle: opens camera (evidence: `surveillance.py`)
- Camera lifecycle → Pi camera: controls camera (evidence: `ai_surveillance/camera.py`)
- Motion monitor → Motion analysis: analyzes frames (evidence: `surveillance.py`)
- Motion monitor → Motion annotation: annotates result (evidence: `surveillance.py`)
- Image detection → ONNX detector: detects objects (evidence: `surveillance.py`)
- Live detection → ONNX detector: detects objects (evidence: `surveillance.py`)
- ONNX detector → Frame preprocessing: prepares frame (evidence: `ai_surveillance/detection.py`)
- ONNX detector → ONNX Runtime: runs inference (evidence: `ai_surveillance/detection.py`)
- ONNX detector → Detection parsing: parses output (evidence: `ai_surveillance/detection.py`)
- ONNX detector → YOLO model: loads model (evidence: `ai_surveillance/detection.py`)
- Image detection → Detection annotation: annotates result (evidence: `surveillance.py`)
- Live detection → Detection annotation: annotates result (evidence: `surveillance.py`)
- Still capture → Generated artifacts: writes capture (evidence: `surveillance.py`)
- Motion monitor → Generated artifacts: writes evidence (evidence: `surveillance.py`)
- Image detection → Generated artifacts: writes annotated image (evidence: `surveillance.py`)
- Live detection → Generated artifacts: writes events and images (evidence: `surveillance.py`)
