# cr1py/pi-cams architecture

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

- Interactive diagram: https://gitdiagram.com/cr1py/pi-cams
- Repository: https://github.com/cr1py/pi-cams

## Overview

PiCams is a home-surveillance application with a React Native UI and a Wt/SQLite backend. The documented workflow is users managing accounts and subscriptions, a device producing an event, and the backend recording it and creating notifications for matching subscriptions; event listing exposes history. The README also describes motion detection and facial recognition, while the tree contains camera and motion-detector modules. Source evidence is incomplete, so UI-to-API and detector-to-device links are not asserted.

Main entry points: [`frontend/securityUI/app/navbar.tsx`](https://github.com/cr1py/pi-cams/blob/main/frontend/securityUI/app/navbar.tsx) (Navigation), [`backend/main.cpp`](https://github.com/cr1py/pi-cams/blob/main/backend/main.cpp) (HTTP server), [`backend/controllers/EventController.cpp`](https://github.com/cr1py/pi-cams/blob/main/backend/controllers/EventController.cpp) (Event controller), [`homesecurity.db`](https://github.com/cr1py/pi-cams/blob/main/homesecurity.db) (SQLite database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_app["Security app<br/>[App.tsx]"]
  node_signup["Signup<br/>[signup.tsx]"]
  node_home["Home view<br/>[home.tsx]"]
  node_devices["Devices view<br/>[devices.tsx]"]
  node_history["Event history<br/>[history.tsx]"]
  node_display["Display view<br/>[display.tsx]"]
  node_settings["Settings view<br/>[settings.tsx]"]
  node_navigation["Navigation<br/>[navbar.tsx]"]
end

subgraph group_api["Backend API"]
  node_server["HTTP server<br/>[main.cpp]"]
  node_users["User endpoints<br/>[UsersResource.cpp]"]
  node_subscriptions["Subscription endpoints"]
  node_eventapi["Event endpoints<br/>[EventsResource.cpp]"]
end

subgraph group_detection["Device detection"]
  node_device["Device event thread"]
  node_motion["Motion detection<br/>[MotionDetector.py]"]
  node_camera["Camera processing<br/>[camera.py]"]
end

subgraph group_domain["Events and persistence"]
  node_eventcontroller["Event controller"]
  node_models["Domain models<br/>[models.cpp]"]
  node_database[("SQLite database<br/>[homesecurity.db]")]
end

node_resident(("Resident"))
node_email["Email service"]

node_resident -->|"uses"| node_app
node_server -->|"registers"| node_users
node_server -->|"registers"| node_subscriptions
node_server -->|"registers"| node_eventapi
node_server -->|"starts thread"| node_device
node_device -->|"fires events"| node_eventcontroller
node_eventcontroller -->|"creates records"| node_models
node_eventcontroller -->|"reads and writes"| node_database
node_eventcontroller -->|"sends alerts"| node_email
node_users -->|"manages users"| node_database
node_subscriptions -->|"manages subscriptions"| node_database
node_eventapi -->|"lists events"| node_database
node_navigation -->|"links to"| node_home
node_navigation -->|"links to"| node_devices
node_navigation -->|"links to"| node_history
node_navigation -->|"links to"| node_settings
node_navigation -->|"links to"| node_signup

click node_app "https://github.com/cr1py/pi-cams/blob/main/frontend/securityUI/App.tsx"
click node_signup "https://github.com/cr1py/pi-cams/blob/main/frontend/securityUI/app/signup.tsx"
click node_home "https://github.com/cr1py/pi-cams/blob/main/frontend/securityUI/app/home.tsx"
click node_devices "https://github.com/cr1py/pi-cams/blob/main/frontend/securityUI/app/devices.tsx"
click node_history "https://github.com/cr1py/pi-cams/blob/main/frontend/securityUI/app/history.tsx"
click node_display "https://github.com/cr1py/pi-cams/blob/main/frontend/securityUI/app/display.tsx"
click node_settings "https://github.com/cr1py/pi-cams/blob/main/frontend/securityUI/app/settings.tsx"
click node_navigation "https://github.com/cr1py/pi-cams/blob/main/frontend/securityUI/app/navbar.tsx"
click node_server "https://github.com/cr1py/pi-cams/blob/main/backend/main.cpp"
click node_users "https://github.com/cr1py/pi-cams/blob/main/backend/controllers/UsersResource.cpp"
click node_subscriptions "https://github.com/cr1py/pi-cams/blob/main/backend/controllers/SubscriptionsResource.cpp"
click node_eventapi "https://github.com/cr1py/pi-cams/blob/main/backend/controllers/EventsResource.cpp"
click node_device "https://github.com/cr1py/pi-cams/blob/main/backend/device/DeviceController.cpp"
click node_motion "https://github.com/cr1py/pi-cams/blob/main/backend/models/MotionDetector.py"
click node_camera "https://github.com/cr1py/pi-cams/blob/main/backend/models/camera.py"
click node_eventcontroller "https://github.com/cr1py/pi-cams/blob/main/backend/controllers/EventController.cpp"
click node_models "https://github.com/cr1py/pi-cams/blob/main/backend/models/models.cpp"
click node_database "https://github.com/cr1py/pi-cams/blob/main/homesecurity.db"

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_app,node_signup,node_home,node_devices,node_history,node_display,node_settings,node_navigation toneBlue
class node_server,node_users,node_subscriptions,node_eventapi toneAmber
class node_device,node_motion,node_camera toneMint
class node_eventcontroller,node_models,node_database toneRose
class node_resident,node_email toneIndigo
```

## Components

### User interface

- [Security app](https://github.com/cr1py/pi-cams/blob/main/frontend/securityUI/App.tsx): `frontend/securityUI/App.tsx`
- [Signup](https://github.com/cr1py/pi-cams/blob/main/frontend/securityUI/app/signup.tsx): `frontend/securityUI/app/signup.tsx`
- [Home view](https://github.com/cr1py/pi-cams/blob/main/frontend/securityUI/app/home.tsx): `frontend/securityUI/app/home.tsx`
- [Devices view](https://github.com/cr1py/pi-cams/blob/main/frontend/securityUI/app/devices.tsx): `frontend/securityUI/app/devices.tsx`
- [Event history](https://github.com/cr1py/pi-cams/blob/main/frontend/securityUI/app/history.tsx): `frontend/securityUI/app/history.tsx`
- [Display view](https://github.com/cr1py/pi-cams/blob/main/frontend/securityUI/app/display.tsx): `frontend/securityUI/app/display.tsx`
- [Settings view](https://github.com/cr1py/pi-cams/blob/main/frontend/securityUI/app/settings.tsx): `frontend/securityUI/app/settings.tsx`
- [Navigation](https://github.com/cr1py/pi-cams/blob/main/frontend/securityUI/app/navbar.tsx): `frontend/securityUI/app/navbar.tsx`

### Backend API

- [HTTP server](https://github.com/cr1py/pi-cams/blob/main/backend/main.cpp): `backend/main.cpp`
- [User endpoints](https://github.com/cr1py/pi-cams/blob/main/backend/controllers/UsersResource.cpp): `backend/controllers/UsersResource.cpp`
- [Subscription endpoints](https://github.com/cr1py/pi-cams/blob/main/backend/controllers/SubscriptionsResource.cpp): `backend/controllers/SubscriptionsResource.cpp`
- [Event endpoints](https://github.com/cr1py/pi-cams/blob/main/backend/controllers/EventsResource.cpp): `backend/controllers/EventsResource.cpp`

### Device detection

- [Device event thread](https://github.com/cr1py/pi-cams/blob/main/backend/device/DeviceController.cpp): `backend/device/DeviceController.cpp`
- [Motion detection](https://github.com/cr1py/pi-cams/blob/main/backend/models/MotionDetector.py): `backend/models/MotionDetector.py`
- [Camera processing](https://github.com/cr1py/pi-cams/blob/main/backend/models/camera.py): `backend/models/camera.py`

### Events and persistence

- [Event controller](https://github.com/cr1py/pi-cams/blob/main/backend/controllers/EventController.cpp): `backend/controllers/EventController.cpp`
- [Domain models](https://github.com/cr1py/pi-cams/blob/main/backend/models/models.cpp): `backend/models/models.cpp`
- [SQLite database](https://github.com/cr1py/pi-cams/blob/main/homesecurity.db): `homesecurity.db`

### Other components

- **Resident**
- **Email service**

## Connections

- Resident → Security app: uses (evidence: `README.md`)
- HTTP server → User endpoints: registers (evidence: `backend/main.cpp`)
- HTTP server → Subscription endpoints: registers (evidence: `backend/main.cpp`)
- HTTP server → Event endpoints: registers (evidence: `backend/main.cpp`)
- HTTP server → Device event thread: starts thread (evidence: `backend/main.cpp`)
- Device event thread → Event controller: fires events (evidence: `backend/device/DeviceController.cpp`)
- Event controller → Domain models: creates records (evidence: `backend/controllers/EventController.cpp`)
- Event controller → SQLite database: reads and writes (evidence: `backend/controllers/EventController.cpp`)
- Event controller → Email service: sends alerts (evidence: `backend/controllers/EventController.cpp`)
- User endpoints → SQLite database: manages users (evidence: `backend/controllers/UsersResource.cpp`)
- Subscription endpoints → SQLite database: manages subscriptions (evidence: `backend/controllers/SubscriptionsResource.cpp`)
- Event endpoints → SQLite database: lists events (evidence: `README.md`)
- Navigation → Home view: links to (evidence: `frontend/securityUI/app/navbar.tsx`)
- Navigation → Devices view: links to (evidence: `frontend/securityUI/app/navbar.tsx`)
- Navigation → Event history: links to (evidence: `frontend/securityUI/app/navbar.tsx`)
- Navigation → Settings view: links to (evidence: `frontend/securityUI/app/navbar.tsx`)
- Navigation → Signup: links to (evidence: `frontend/securityUI/app/navbar.tsx`)
