# prathap2349/smart-vision architecture

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

- Interactive diagram: https://gitdiagram.com/prathap2349/smart-vision
- Repository: https://github.com/prathap2349/smart-vision

## Overview

Smart Vision Sentry is a local edge-AI CCTV security system: it captures camera frames, detects and tracks people in protected zones, checks resident identity, and alerts on verified threats. Operators manage cameras, zones, residents, alerts, and system status through the web dashboard. The README documents the detection stages; source-index references support the backend orchestration and major frontend/API connections. Some route and integration internals were not excerpted, so those relationships are shown only where documented or indexed.

Main entry points: [`src/App.tsx`](https://github.com/prathap2349/smart-vision/blob/main/src/App.tsx) (Dashboard routing), [`backend/main.py`](https://github.com/prathap2349/smart-vision/blob/main/backend/main.py) (FastAPI application), [`backend/detection_loop.py`](https://github.com/prathap2349/smart-vision/blob/main/backend/detection_loop.py) (Detection loop), [`backend/database.py`](https://github.com/prathap2349/smart-vision/blob/main/backend/database.py) (SQLite data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Capture and Detection"]
  node_stream["RTSP capture<br/>[rtsp_stream.py]"]
  node_detector["Person detector<br/>[detector.py]"]
  node_loop["Detection loop<br/>[detection_loop.py]"]
end

subgraph group_analysis["Tracking and Decisions"]
  node_tracker["IoU tracking<br/>[tracker.py]"]
  node_zones["Zone checks<br/>[zone_checker.py]"]
  node_recognizer["Face recognition<br/>[recognizer.py]"]
  node_cache["Resident cache<br/>[cache.py]"]
  node_decision["Triple-gate engine<br/>[decision_engine.py]"]
end

subgraph group_security["Security Operations"]
  node_alerts["Alert dispatch<br/>[alert_manager.py]"]
end

subgraph group_api["API and Persistence"]
  node_api["FastAPI application<br/>[main.py]"]
  node_database[("SQLite data<br/>[database.py]")]
  node_people["Resident enrollment<br/>[people.py]"]
  node_camera_api["Camera management<br/>[cameras.py]"]
  node_alerts_api["Alert and history APIs<br/>[alerts.py]"]
  node_analytics_api["Analytics API<br/>[analytics.py]"]
  node_health_api["Health API<br/>[health.py]"]
end

subgraph group_web["Operator Dashboard"]
  node_app["Dashboard routing<br/>[App.tsx]"]
  node_security_context["Security state"]
  node_api_client["API client<br/>[api.ts]"]
  node_overview["Security overview<br/>[OverviewPage.tsx]"]
  node_alerts_page["Alerts view<br/>[AlertsPage.tsx]"]
  node_people_page["People view<br/>[PeoplePage.tsx]"]
  node_cameras_page["Camera view<br/>[CamerasPage.tsx]"]
  node_live_page["Live monitor"]
  node_zones_page["Zone editor"]
  node_analytics_page["Analytics view<br/>[AnalyticsPage.tsx]"]
  node_health_page["System health"]
end

node_camera(("RTSP camera"))
node_telegram(("Telegram"))
node_operator(("Security operator"))

node_camera -->|"sends frames"| node_stream
node_stream -->|"supplies frames"| node_loop
node_loop -->|"detects people"| node_detector
node_loop -->|"updates tracks"| node_tracker
node_tracker -->|"checks zones"| node_zones
node_loop -->|"verifies faces"| node_recognizer
node_recognizer -->|"matches residents"| node_cache
node_cache -->|"loads embeddings"| node_database
node_loop -->|"evaluates gates"| node_decision
node_decision -->|"flags threats"| node_alerts
node_loop -->|"dispatches alerts"| node_alerts
node_alerts -->|"records alerts"| node_database
node_alerts -->|"notifies"| node_telegram
node_api -->|"starts processing"| node_loop
node_api -->|"registers routes"| node_camera_api
node_api -->|"registers routes"| node_alerts_api
node_api -->|"registers routes"| node_people
node_api -->|"registers routes"| node_analytics_api
node_api -->|"registers routes"| node_health_api
node_people -->|"stores enrollments"| node_database
node_people -->|"validates faces"| node_recognizer
node_camera_api -->|"manages cameras"| node_database
node_alerts_api -->|"reads alerts"| node_database
node_analytics_api -->|"reads events"| node_database
node_health_api -->|"checks storage"| node_database
node_operator -.->|"uses dashboard"| node_app
node_app -->|"routes to"| node_overview
node_app -->|"routes to"| node_live_page
node_app -->|"routes to"| node_alerts_page
node_app -->|"routes to"| node_people_page
node_app -->|"routes to"| node_cameras_page
node_app -->|"routes to"| node_zones_page
node_app -->|"routes to"| node_analytics_page
node_app -->|"routes to"| node_health_page
node_overview -->|"reads state"| node_security_context
node_alerts_page -->|"reads state"| node_security_context
node_people_page -->|"reads state"| node_security_context
node_cameras_page -->|"reads state"| node_security_context
node_security_context -->|"requests data"| node_api_client
node_api_client -.->|"calls backend"| node_api

click node_stream "https://github.com/prathap2349/smart-vision/blob/main/backend/camera/rtsp_stream.py"
click node_detector "https://github.com/prathap2349/smart-vision/blob/main/backend/ai/detector.py"
click node_loop "https://github.com/prathap2349/smart-vision/blob/main/backend/detection_loop.py"
click node_tracker "https://github.com/prathap2349/smart-vision/blob/main/backend/tracking/tracker.py"
click node_zones "https://github.com/prathap2349/smart-vision/blob/main/backend/tracking/zone_checker.py"
click node_recognizer "https://github.com/prathap2349/smart-vision/blob/main/backend/face/recognizer.py"
click node_cache "https://github.com/prathap2349/smart-vision/blob/main/backend/face/cache.py"
click node_decision "https://github.com/prathap2349/smart-vision/blob/main/backend/ai/decision_engine.py"
click node_alerts "https://github.com/prathap2349/smart-vision/blob/main/backend/alerts/alert_manager.py"
click node_api "https://github.com/prathap2349/smart-vision/blob/main/backend/main.py"
click node_database "https://github.com/prathap2349/smart-vision/blob/main/backend/database.py"
click node_people "https://github.com/prathap2349/smart-vision/blob/main/backend/api/people.py"
click node_camera_api "https://github.com/prathap2349/smart-vision/blob/main/backend/api/cameras.py"
click node_alerts_api "https://github.com/prathap2349/smart-vision/blob/main/backend/api/alerts.py"
click node_analytics_api "https://github.com/prathap2349/smart-vision/blob/main/backend/api/analytics.py"
click node_health_api "https://github.com/prathap2349/smart-vision/blob/main/backend/api/health.py"
click node_app "https://github.com/prathap2349/smart-vision/blob/main/src/App.tsx"
click node_security_context "https://github.com/prathap2349/smart-vision/blob/main/src/context/SecurityContext.tsx"
click node_api_client "https://github.com/prathap2349/smart-vision/blob/main/src/services/api.ts"
click node_overview "https://github.com/prathap2349/smart-vision/blob/main/src/pages/OverviewPage.tsx"
click node_alerts_page "https://github.com/prathap2349/smart-vision/blob/main/src/pages/AlertsPage.tsx"
click node_people_page "https://github.com/prathap2349/smart-vision/blob/main/src/pages/PeoplePage.tsx"
click node_cameras_page "https://github.com/prathap2349/smart-vision/blob/main/src/pages/CamerasPage.tsx"
click node_live_page "https://github.com/prathap2349/smart-vision/blob/main/src/pages/LiveMonitorPage.tsx"
click node_zones_page "https://github.com/prathap2349/smart-vision/blob/main/src/pages/DetectionZonesPage.tsx"
click node_analytics_page "https://github.com/prathap2349/smart-vision/blob/main/src/pages/AnalyticsPage.tsx"
click node_health_page "https://github.com/prathap2349/smart-vision/blob/main/src/pages/SystemHealthPage.tsx"

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_stream,node_detector,node_loop toneBlue
class node_tracker,node_zones,node_recognizer,node_cache,node_decision toneAmber
class node_alerts toneMint
class node_api,node_database,node_people,node_camera_api,node_alerts_api,node_analytics_api,node_health_api toneRose
class node_app,node_security_context,node_api_client,node_overview,node_alerts_page,node_people_page,node_cameras_page,node_live_page,node_zones_page,node_analytics_page,node_health_page,node_camera,node_telegram,node_operator toneIndigo
```

## Components

### Capture and Detection

- [RTSP capture](https://github.com/prathap2349/smart-vision/blob/main/backend/camera/rtsp_stream.py): `backend/camera/rtsp_stream.py`
- [Person detector](https://github.com/prathap2349/smart-vision/blob/main/backend/ai/detector.py): `backend/ai/detector.py`
- [Detection loop](https://github.com/prathap2349/smart-vision/blob/main/backend/detection_loop.py): `backend/detection_loop.py`

### Tracking and Decisions

- [IoU tracking](https://github.com/prathap2349/smart-vision/blob/main/backend/tracking/tracker.py): `backend/tracking/tracker.py`
- [Zone checks](https://github.com/prathap2349/smart-vision/blob/main/backend/tracking/zone_checker.py): `backend/tracking/zone_checker.py`
- [Face recognition](https://github.com/prathap2349/smart-vision/blob/main/backend/face/recognizer.py): `backend/face/recognizer.py`
- [Resident cache](https://github.com/prathap2349/smart-vision/blob/main/backend/face/cache.py): `backend/face/cache.py`
- [Triple-gate engine](https://github.com/prathap2349/smart-vision/blob/main/backend/ai/decision_engine.py): `backend/ai/decision_engine.py`

### Security Operations

- [Alert dispatch](https://github.com/prathap2349/smart-vision/blob/main/backend/alerts/alert_manager.py): `backend/alerts/alert_manager.py`

### API and Persistence

- [FastAPI application](https://github.com/prathap2349/smart-vision/blob/main/backend/main.py): `backend/main.py`
- [SQLite data](https://github.com/prathap2349/smart-vision/blob/main/backend/database.py): `backend/database.py`
- [Resident enrollment](https://github.com/prathap2349/smart-vision/blob/main/backend/api/people.py): `backend/api/people.py`
- [Camera management](https://github.com/prathap2349/smart-vision/blob/main/backend/api/cameras.py): `backend/api/cameras.py`
- [Alert and history APIs](https://github.com/prathap2349/smart-vision/blob/main/backend/api/alerts.py): `backend/api/alerts.py`
- [Analytics API](https://github.com/prathap2349/smart-vision/blob/main/backend/api/analytics.py): `backend/api/analytics.py`
- [Health API](https://github.com/prathap2349/smart-vision/blob/main/backend/api/health.py): `backend/api/health.py`

### Operator Dashboard

- [Dashboard routing](https://github.com/prathap2349/smart-vision/blob/main/src/App.tsx): `src/App.tsx`
- [Security state](https://github.com/prathap2349/smart-vision/blob/main/src/context/SecurityContext.tsx): `src/context/SecurityContext.tsx`
- [API client](https://github.com/prathap2349/smart-vision/blob/main/src/services/api.ts): `src/services/api.ts`
- [Security overview](https://github.com/prathap2349/smart-vision/blob/main/src/pages/OverviewPage.tsx): `src/pages/OverviewPage.tsx`
- [Alerts view](https://github.com/prathap2349/smart-vision/blob/main/src/pages/AlertsPage.tsx): `src/pages/AlertsPage.tsx`
- [People view](https://github.com/prathap2349/smart-vision/blob/main/src/pages/PeoplePage.tsx): `src/pages/PeoplePage.tsx`
- [Camera view](https://github.com/prathap2349/smart-vision/blob/main/src/pages/CamerasPage.tsx): `src/pages/CamerasPage.tsx`
- [Live monitor](https://github.com/prathap2349/smart-vision/blob/main/src/pages/LiveMonitorPage.tsx): `src/pages/LiveMonitorPage.tsx`
- [Zone editor](https://github.com/prathap2349/smart-vision/blob/main/src/pages/DetectionZonesPage.tsx): `src/pages/DetectionZonesPage.tsx`
- [Analytics view](https://github.com/prathap2349/smart-vision/blob/main/src/pages/AnalyticsPage.tsx): `src/pages/AnalyticsPage.tsx`
- [System health](https://github.com/prathap2349/smart-vision/blob/main/src/pages/SystemHealthPage.tsx): `src/pages/SystemHealthPage.tsx`

### Other components

- **RTSP camera**
- **Telegram**
- **Security operator**

## Connections

- RTSP camera → RTSP capture: sends frames
- RTSP capture → Detection loop: supplies frames (evidence: `backend/detection_loop.py`)
- Detection loop → Person detector: detects people (evidence: `backend/detection_loop.py`)
- Detection loop → IoU tracking: updates tracks (evidence: `backend/detection_loop.py`)
- IoU tracking → Zone checks: checks zones (evidence: `backend/tracking/tracker.py`)
- Detection loop → Face recognition: verifies faces (evidence: `backend/detection_loop.py`)
- Face recognition → Resident cache: matches residents (evidence: `backend/face/recognizer.py`)
- Resident cache → SQLite data: loads embeddings (evidence: `backend/face/cache.py`)
- Detection loop → Triple-gate engine: evaluates gates (evidence: `backend/detection_loop.py`)
- Triple-gate engine → Alert dispatch: flags threats
- Detection loop → Alert dispatch: dispatches alerts (evidence: `backend/detection_loop.py`)
- Alert dispatch → SQLite data: records alerts (evidence: `backend/alerts/alert_manager.py`)
- Alert dispatch → Telegram: notifies
- FastAPI application → Detection loop: starts processing (evidence: `backend/main.py`)
- FastAPI application → Camera management: registers routes (evidence: `backend/main.py`)
- FastAPI application → Alert and history APIs: registers routes (evidence: `backend/main.py`)
- FastAPI application → Resident enrollment: registers routes (evidence: `backend/main.py`)
- FastAPI application → Analytics API: registers routes (evidence: `backend/main.py`)
- FastAPI application → Health API: registers routes (evidence: `backend/main.py`)
- Resident enrollment → SQLite data: stores enrollments (evidence: `backend/api/people.py`)
- Resident enrollment → Face recognition: validates faces (evidence: `backend/api/people.py`)
- Camera management → SQLite data: manages cameras (evidence: `backend/api/cameras.py`)
- Alert and history APIs → SQLite data: reads alerts (evidence: `backend/api/alerts.py`)
- Analytics API → SQLite data: reads events (evidence: `backend/api/analytics.py`)
- Health API → SQLite data: checks storage (evidence: `backend/api/health.py`)
- Security operator → Dashboard routing: uses dashboard
- Dashboard routing → Security overview: routes to (evidence: `src/App.tsx`)
- Dashboard routing → Live monitor: routes to (evidence: `src/App.tsx`)
- Dashboard routing → Alerts view: routes to (evidence: `src/App.tsx`)
- Dashboard routing → People view: routes to (evidence: `src/App.tsx`)
- Dashboard routing → Camera view: routes to (evidence: `src/App.tsx`)
- Dashboard routing → Zone editor: routes to (evidence: `src/App.tsx`)
- Dashboard routing → Analytics view: routes to (evidence: `src/App.tsx`)
- Dashboard routing → System health: routes to (evidence: `src/App.tsx`)
- Security overview → Security state: reads state (evidence: `src/pages/OverviewPage.tsx`)
- Alerts view → Security state: reads state (evidence: `src/pages/AlertsPage.tsx`)
- People view → Security state: reads state (evidence: `src/pages/PeoplePage.tsx`)
- Camera view → Security state: reads state (evidence: `src/pages/CamerasPage.tsx`)
- Security state → API client: requests data (evidence: `src/context/SecurityContext.tsx`)
- API client → FastAPI application: calls backend
