# sandeepsawhney2015/rpi-facial-recognition-door-chime architecture

> Architecture diagram of the GitHub repository sandeepsawhney2015/rpi-facial-recognition-door-chime, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sandeepsawhney2015/rpi-facial-recognition-door-chime
- Repository: https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime

## Overview

The product is a Raspberry Pi smart doorbell with a Mac webcam prototype. Its implemented workflows capture frames, run object and/or face recognition, annotate results, and either display them locally or stream them to a browser; a separate tool enrolls faces into the shared local database. The graph distinguishes these runnable paths and the face-processing and persistence layers. Door-state gating, greetings, and notifications are documented goals, not implemented components. Relationships for unsampled enrollment behavior and networking follow README descriptions.

Main entry points: [`camera_stream.py`](https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/camera_stream.py) (Pi recognition stream), [`database.py`](https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/database.py) (Face database), [`main.py`](https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/main.py) (Mac doorbell app), [`face_identifier.py`](https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/face_identifier.py) (Face detection and embeddings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture and detection"]
  node_pi_camera["Pi camera"]
  node_mac_camera["Mac webcam"]
  node_yolo["YOLO detection<br/>[main.py]"]
end

subgraph group_identity["Face identity"]
  node_face_processing["Face detection and embeddings<br/>[face_identifier.py]"]
  node_face_matching["Face matching and labels<br/>[main.py]"]
  node_pi_matching["Pi face matching<br/>[camera_stream.py]"]
  node_enrollment["Face enrollment<br/>[test_faces.py]"]
  node_face_database[("Face database<br/>[database.py]")]
end

subgraph group_delivery["Display and streaming"]
  node_pi_recognition["Pi recognition stream<br/>[camera_stream.py]"]
  node_pi_yolo["Pi YOLO stream"]
  node_pi_raw["Pi camera check"]
  node_mac_app["Mac doorbell app<br/>[main.py]"]
end

node_visitor(("Entrance visitor"))
node_browser(("Browser viewer"))
node_tailscale{{"Tailscale tunnel"}}

node_visitor -.->|"appears before"| node_pi_camera
node_visitor -.->|"appears before"| node_mac_camera
node_pi_camera -->|"captures frames"| node_pi_recognition
node_pi_camera -->|"captures frames"| node_pi_yolo
node_pi_camera -->|"captures frames"| node_pi_raw
node_mac_camera -->|"reads frames"| node_mac_app
node_mac_app -->|"runs detection"| node_yolo
node_mac_app -->|"gets face data"| node_face_processing
node_mac_app -->|"matches embeddings"| node_face_matching
node_face_matching -->|"loads embeddings"| node_face_database
node_pi_recognition -->|"gets face data"| node_face_processing
node_pi_recognition -->|"matches embeddings"| node_pi_matching
node_pi_recognition -->|"loads embeddings"| node_face_database
node_enrollment -.->|"extracts embeddings"| node_face_processing
node_enrollment -.->|"saves embeddings"| node_face_database
node_face_database -->|"reads and writes SQLite"| node_face_database
node_pi_recognition -->|"streams MJPEG"| node_browser
node_pi_yolo -->|"streams MJPEG"| node_browser
node_pi_raw -->|"streams MJPEG"| node_browser
node_tailscale -.->|"forwards stream access"| node_browser

click node_pi_recognition "https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/camera_stream.py"
click node_pi_yolo "https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/camera_stream_yolo_backup.py"
click node_pi_raw "https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/camera_stream_backup.py"
click node_mac_app "https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/main.py"
click node_yolo "https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/main.py"
click node_face_processing "https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/face_identifier.py"
click node_face_matching "https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/main.py"
click node_pi_matching "https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/camera_stream.py"
click node_enrollment "https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/test_faces.py"
click node_face_database "https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/database.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_pi_camera,node_mac_camera,node_yolo,node_browser toneBlue
class node_face_processing,node_face_matching,node_pi_matching,node_enrollment,node_face_database toneAmber
class node_pi_recognition,node_pi_yolo,node_pi_raw,node_mac_app toneMint
class node_visitor,node_tailscale toneIndigo
```

## Components

### Capture and detection

- **Pi camera**
- **Mac webcam**
- [YOLO detection](https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/main.py): `main.py`

### Face identity

- [Face detection and embeddings](https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/face_identifier.py): `face_identifier.py`
- [Face matching and labels](https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/main.py): `main.py`
- [Pi face matching](https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/camera_stream.py): `camera_stream.py`
- [Face enrollment](https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/test_faces.py): `test_faces.py`
- [Face database](https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/database.py): `database.py`

### Display and streaming

- [Pi recognition stream](https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/camera_stream.py): `camera_stream.py`
- [Pi YOLO stream](https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/camera_stream_yolo_backup.py): `camera_stream_yolo_backup.py`
- [Pi camera check](https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/camera_stream_backup.py): `camera_stream_backup.py`
- [Mac doorbell app](https://github.com/sandeepsawhney2015/rpi-facial-recognition-door-chime/blob/main/main.py): `main.py`

### Other components

- **Entrance visitor**
- **Browser viewer**
- **Tailscale tunnel**

## Connections

- Entrance visitor → Pi camera: appears before
- Entrance visitor → Mac webcam: appears before
- Pi camera → Pi recognition stream: captures frames (evidence: `camera_stream.py`)
- Pi camera → Pi YOLO stream: captures frames (evidence: `camera_stream_yolo_backup.py`)
- Pi camera → Pi camera check: captures frames (evidence: `camera_stream_backup.py`)
- Mac webcam → Mac doorbell app: reads frames (evidence: `main.py`)
- Mac doorbell app → YOLO detection: runs detection (evidence: `main.py`)
- Mac doorbell app → Face detection and embeddings: gets face data (evidence: `main.py`)
- Mac doorbell app → Face matching and labels: matches embeddings (evidence: `main.py`)
- Face matching and labels → Face database: loads embeddings (evidence: `main.py`)
- Pi recognition stream → Face detection and embeddings: gets face data (evidence: `camera_stream.py`)
- Pi recognition stream → Pi face matching: matches embeddings (evidence: `camera_stream.py`)
- Pi recognition stream → Face database: loads embeddings (evidence: `camera_stream.py`)
- Face enrollment → Face detection and embeddings: extracts embeddings (evidence: `README.md`)
- Face enrollment → Face database: saves embeddings (evidence: `README.md`)
- Face database → Face database: reads and writes SQLite (evidence: `database.py`)
- Pi recognition stream → Browser viewer: streams MJPEG (evidence: `README.md`)
- Pi YOLO stream → Browser viewer: streams MJPEG (evidence: `camera_stream_yolo_backup.py`)
- Pi camera check → Browser viewer: streams MJPEG (evidence: `camera_stream_backup.py`)
- Tailscale tunnel → Browser viewer: forwards stream access (evidence: `README.md`)
