# umershk2003/smart-surveillance-system architecture

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

- Interactive diagram: https://gitdiagram.com/umershk2003/smart-surveillance-system
- Repository: https://github.com/umershk2003/smart-surveillance-system

## Overview

A smart CCTV surveillance product: camera feeds are captured and analyzed for weapons, restricted objects, people, faces, and zone intrusions; resulting identities and events are persisted and surfaced in live streams, dashboards, and alerts. The React application provides role-based workspaces for reviewing events, managing known and unknown people, editing zones, and monitoring health. The graph follows documented capabilities and visible references; some backend routes and integrations are represented at subsystem level where implementation excerpts were unavailable.

Main entry points: [`backend/app/camera_worker.py`](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/camera_worker.py) (Camera worker), [`backend/app/main.py`](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/main.py) (FastAPI application), [`frontend/src/api.js`](https://github.com/umershk2003/smart-surveillance-system/blob/main/frontend/src/api.js) (API client), [`backend/app/face_engine.py`](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/face_engine.py) (Face recognition)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Dashboard and access"]
  node_app["Application routes<br/>[App.jsx]"]
  node_auth_ui["Auth context<br/>[useAuth.jsx]"]
  node_api_client["API client<br/>[api.js]"]
  node_review_ui["Review dashboards"]
  node_zone_ui["Zone editor<br/>[ZoneEditorPage.jsx]"]
  node_health_ui["Health dashboard<br/>[HealthPage.jsx]"]
end

subgraph group_api["API and management"]
  node_api_app["FastAPI application<br/>[main.py]"]
  node_auth["JWT authorization<br/>[auth.py]"]
  node_camera_routes["Camera controls<br/>[camera.py]"]
  node_event_routes["Events and alerts<br/>[alerts.py]"]
  node_face_routes["Face management<br/>[faces.py]"]
  node_unknown_routes["Unknown review<br/>[unknown_persons.py]"]
end

subgraph group_vision["Camera analytics"]
  node_camera(("Camera feeds"))
  node_worker["Camera worker<br/>[camera_worker.py]"]
  node_weapon["Weapon detection<br/>[weapon_engine.py]"]
  node_objects["Object detection<br/>[object_engine.py]"]
end

subgraph group_identity["Identity and records"]
  node_faces["Face recognition<br/>[face_engine.py]"]
  node_quality["Face quality checks<br/>[face_quality.py]"]
  node_unknown_service["Unknown identity service"]
end

subgraph group_infra["Stores and notifications"]
  node_records[("Surveillance records<br/>[models.py]")]
  node_postgres[("PostgreSQL and pgvector")]
  node_redis["Redis event stream<br/>[redis_stream.py]"]
  node_stream["Live video stream<br/>[stream_manager.py]"]
  node_dispatcher["Alert dispatcher"]
  node_whatsapp["WhatsApp delivery<br/>[whatsapp.py]"]
  node_telegram["Telegram delivery<br/>[telegram.py]"]
end

node_operator(("Operator"))

node_operator -->|"uses workspace"| node_app
node_app -->|"provides auth"| node_auth_ui
node_auth_ui -->|"checks identity"| node_api_client
node_review_ui -->|"loads review data"| node_api_client
node_zone_ui -->|"saves zones"| node_api_client
node_health_ui -->|"loads health"| node_api_client
node_api_client -->|"requests API"| node_api_app
node_api_app -->|"uses authorization"| node_auth
node_api_app -->|"registers routes"| node_camera_routes
node_api_app -->|"registers routes"| node_event_routes
node_api_app -->|"registers routes"| node_face_routes
node_api_app -->|"registers routes"| node_unknown_routes
node_camera -->|"supplies frames"| node_worker
node_worker -->|"detects threats"| node_weapon
node_worker -->|"detects objects"| node_objects
node_worker -->|"analyzes faces"| node_faces
node_faces -->|"filters faces"| node_quality
node_faces -->|"matches embeddings"| node_records
node_worker -->|"records events"| node_records
node_worker -->|"tracks unknowns"| node_unknown_service
node_unknown_routes -->|"manages identities"| node_unknown_service
node_face_routes -->|"registers faces"| node_faces
node_records -->|"persists records"| node_postgres
node_worker -->|"publishes events"| node_redis
node_worker -->|"publishes live frames"| node_stream
node_worker -->|"triggers alerts"| node_dispatcher
node_dispatcher -->|"dispatches notifications"| node_whatsapp
node_dispatcher -->|"dispatches notifications"| node_telegram
node_redis -->|"feeds alert worker"| node_whatsapp

click node_app "https://github.com/umershk2003/smart-surveillance-system/blob/main/frontend/src/App.jsx"
click node_auth_ui "https://github.com/umershk2003/smart-surveillance-system/blob/main/frontend/src/hooks/useAuth.jsx"
click node_api_client "https://github.com/umershk2003/smart-surveillance-system/blob/main/frontend/src/api.js"
click node_review_ui "https://github.com/umershk2003/smart-surveillance-system/blob/main/frontend/src/pages/UnknownReviewPage.jsx"
click node_zone_ui "https://github.com/umershk2003/smart-surveillance-system/blob/main/frontend/src/pages/ZoneEditorPage.jsx"
click node_health_ui "https://github.com/umershk2003/smart-surveillance-system/blob/main/frontend/src/pages/HealthPage.jsx"
click node_api_app "https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/main.py"
click node_auth "https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/auth.py"
click node_camera_routes "https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/routers/camera.py"
click node_event_routes "https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/routers/alerts.py"
click node_face_routes "https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/routers/faces.py"
click node_unknown_routes "https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/routers/unknown_persons.py"
click node_worker "https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/camera_worker.py"
click node_weapon "https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/weapon_engine.py"
click node_objects "https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/object_engine.py"
click node_faces "https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/face_engine.py"
click node_quality "https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/face_quality.py"
click node_unknown_service "https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/unknown_person_service.py"
click node_records "https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/models.py"
click node_redis "https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/redis_stream.py"
click node_stream "https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/stream_manager.py"
click node_dispatcher "https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/alert_dispatcher.py"
click node_whatsapp "https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/whatsapp.py"
click node_telegram "https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/telegram.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_app,node_auth_ui,node_api_client,node_review_ui,node_zone_ui,node_health_ui toneBlue
class node_api_app,node_auth,node_camera_routes,node_event_routes,node_face_routes,node_unknown_routes toneAmber
class node_camera,node_worker,node_weapon,node_objects toneMint
class node_faces,node_quality,node_unknown_service toneRose
class node_records,node_postgres,node_redis,node_stream,node_dispatcher,node_whatsapp,node_telegram,node_operator toneIndigo
```

## Components

### Dashboard and access

- [Application routes](https://github.com/umershk2003/smart-surveillance-system/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Auth context](https://github.com/umershk2003/smart-surveillance-system/blob/main/frontend/src/hooks/useAuth.jsx): `frontend/src/hooks/useAuth.jsx`
- [API client](https://github.com/umershk2003/smart-surveillance-system/blob/main/frontend/src/api.js): `frontend/src/api.js`
- [Review dashboards](https://github.com/umershk2003/smart-surveillance-system/blob/main/frontend/src/pages/UnknownReviewPage.jsx): `frontend/src/pages/UnknownReviewPage.jsx`
- [Zone editor](https://github.com/umershk2003/smart-surveillance-system/blob/main/frontend/src/pages/ZoneEditorPage.jsx): `frontend/src/pages/ZoneEditorPage.jsx`
- [Health dashboard](https://github.com/umershk2003/smart-surveillance-system/blob/main/frontend/src/pages/HealthPage.jsx): `frontend/src/pages/HealthPage.jsx`

### API and management

- [FastAPI application](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/main.py): `backend/app/main.py`
- [JWT authorization](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/auth.py): `backend/app/auth.py`
- [Camera controls](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/routers/camera.py): `backend/app/routers/camera.py`
- [Events and alerts](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/routers/alerts.py): `backend/app/routers/alerts.py`
- [Face management](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/routers/faces.py): `backend/app/routers/faces.py`
- [Unknown review](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/routers/unknown_persons.py): `backend/app/routers/unknown_persons.py`

### Camera analytics

- **Camera feeds**
- [Camera worker](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/camera_worker.py): `backend/app/camera_worker.py`
- [Weapon detection](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/weapon_engine.py): `backend/app/weapon_engine.py`
- [Object detection](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/object_engine.py): `backend/app/object_engine.py`

### Identity and records

- [Face recognition](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/face_engine.py): `backend/app/face_engine.py`
- [Face quality checks](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/face_quality.py): `backend/app/face_quality.py`
- [Unknown identity service](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/unknown_person_service.py): `backend/app/unknown_person_service.py`

### Stores and notifications

- [Surveillance records](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/models.py): `backend/app/models.py`
- **PostgreSQL and pgvector**
- [Redis event stream](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/redis_stream.py): `backend/app/redis_stream.py`
- [Live video stream](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/stream_manager.py): `backend/app/stream_manager.py`
- [Alert dispatcher](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/alert_dispatcher.py): `backend/app/alert_dispatcher.py`
- [WhatsApp delivery](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/whatsapp.py): `backend/app/whatsapp.py`
- [Telegram delivery](https://github.com/umershk2003/smart-surveillance-system/blob/main/backend/app/telegram.py): `backend/app/telegram.py`

### Other components

- **Operator**

## Connections

- Operator → Application routes: uses workspace (evidence: `frontend/src/App.jsx`)
- Application routes → Auth context: provides auth (evidence: `frontend/src/App.jsx`)
- Auth context → API client: checks identity (evidence: `frontend/src/hooks/useAuth.jsx`)
- Review dashboards → API client: loads review data (evidence: `frontend/src/pages/UnknownReviewPage.jsx`)
- Zone editor → API client: saves zones (evidence: `frontend/src/api.js`)
- Health dashboard → API client: loads health (evidence: `frontend/src/pages/HealthPage.jsx`)
- API client → FastAPI application: requests API (evidence: `frontend/src/api.js`)
- FastAPI application → JWT authorization: uses authorization (evidence: `backend/app/main.py`)
- FastAPI application → Camera controls: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Events and alerts: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Face management: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Unknown review: registers routes (evidence: `backend/app/main.py`)
- Camera feeds → Camera worker: supplies frames (evidence: `README.md`)
- Camera worker → Weapon detection: detects threats (evidence: `backend/app/camera_worker.py`)
- Camera worker → Object detection: detects objects (evidence: `backend/app/camera_worker.py`)
- Camera worker → Face recognition: analyzes faces (evidence: `backend/app/camera_worker.py`)
- Face recognition → Face quality checks: filters faces (evidence: `backend/app/face_engine.py`)
- Face recognition → Surveillance records: matches embeddings (evidence: `backend/app/face_engine.py`)
- Camera worker → Surveillance records: records events (evidence: `README.md`)
- Camera worker → Unknown identity service: tracks unknowns (evidence: `backend/app/camera_worker.py`)
- Unknown review → Unknown identity service: manages identities (evidence: `backend/app/routers/unknown_persons.py`)
- Face management → Face recognition: registers faces (evidence: `backend/app/routers/faces.py`)
- Surveillance records → PostgreSQL and pgvector: persists records
- Camera worker → Redis event stream: publishes events (evidence: `README.md`)
- Camera worker → Live video stream: publishes live frames (evidence: `README.md`)
- Camera worker → Alert dispatcher: triggers alerts (evidence: `backend/app/camera_worker.py`)
- Alert dispatcher → WhatsApp delivery: dispatches notifications (evidence: `backend/app/alert_dispatcher.py`)
- Alert dispatcher → Telegram delivery: dispatches notifications (evidence: `backend/app/alert_dispatcher.py`)
- Redis event stream → WhatsApp delivery: feeds alert worker (evidence: `README.md`)
