# dharshan-raj/perimeter_fencing_al architecture

> Architecture diagram of the GitHub repository dharshan-raj/perimeter_fencing_al, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dharshan-raj/perimeter_fencing_al
- Repository: https://github.com/dharshan-raj/perimeter_fencing_al

## Overview

IT Furnace is a camera-based perimeter intrusion monitoring system. Its main workflow acquires a configured camera or fallback video, detects and tracks people, evaluates zone transitions, records event evidence and history, then serves live video, alerts, and analytics to a React dashboard. The dashboard also supports zone editing and authenticated monitoring controls. Edges reflect calls and data flows visible in excerpts or documented API capabilities; unsampled subsystems are included where the README establishes their role, with uncertain internal links omitted.

Main entry points: [`backend/main.py`](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/main.py) (FastAPI routes), [`backend/camera/camera_manager.py`](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/camera/camera_manager.py) (Camera worker), [`frontend/src/App.jsx`](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/frontend/src/App.jsx) (Dashboard app), [`frontend/src/components/CameraFeed.jsx`](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/frontend/src/components/CameraFeed.jsx) (Live feed)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Video Capture"]
  node_rtsp["Stream reader<br/>[rtsp_stream.py]"]
  node_worker["Camera worker<br/>[camera_manager.py]"]
end

subgraph group_detection["Detection &amp; Events"]
  node_detector["Person detector<br/>[detector.py]"]
  node_zones["Zone manager<br/>[zone_manager.py]"]
  node_intrusion["Intrusion evaluation"]
  node_evidence["Evidence capture"]
  node_notifications["ntfy notifications"]
end

subgraph group_backend["Monitoring API"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_ws["Alert WebSocket"]
  node_models["Event models<br/>[models.py]"]
  node_database[("SQL database<br/>[database.py]")]
  node_evidence_store[("Evidence files")]
  node_config["Runtime settings<br/>[config.py]"]
end

subgraph group_dashboard["Dashboard"]
  node_app["Dashboard app<br/>[App.jsx]"]
  node_api_client["API client<br/>[api.js]"]
  node_feed["Live feed<br/>[CameraFeed.jsx]"]
  node_zone_editor["Zone editor<br/>[ZoneEditor.jsx]"]
  node_alerts["Alert panel<br/>[AlertPanel.jsx]"]
  node_analytics["Analytics panels"]
  node_status["Camera status<br/>[CameraStatus.jsx]"]
  node_sidebar["Navigation<br/>[Sidebar.jsx]"]
end

node_operator(("Security operator"))
node_camera(("CCTV / webcam"))
node_ntfy_service(("ntfy service"))

node_camera -->|"provides frames"| node_rtsp
node_rtsp -->|"reads stream"| node_worker
node_config -->|"configures"| node_worker
node_worker -->|"runs detection"| node_detector
node_worker -->|"uses zones"| node_zones
node_worker -->|"evaluates tracks"| node_intrusion
node_worker -->|"saves event frame"| node_evidence
node_worker -->|"records events"| node_models
node_evidence -->|"writes images"| node_evidence_store
node_worker -->|"publishes events"| node_api
node_api -->|"broadcasts alerts"| node_ws
node_api -->|"dispatches critical"| node_notifications
node_notifications -->|"posts notification"| node_ntfy_service
node_models -->|"maps records"| node_database
node_api -->|"queries and updates"| node_database
node_api -->|"controls camera"| node_worker
node_api -->|"reads and updates"| node_zones
node_api -->|"serves images"| node_evidence_store
node_operator -->|"uses dashboard"| node_app
node_app -->|"requests data"| node_api_client
node_api_client -->|"calls HTTP API"| node_api
node_app -->|"renders feed"| node_feed
node_app -->|"renders alerts"| node_alerts
node_app -->|"renders analytics"| node_analytics
node_app -->|"renders status"| node_status
node_app -->|"renders navigation"| node_sidebar
node_feed -->|"embeds editor"| node_zone_editor
node_feed -->|"loads MJPEG"| node_api
node_zone_editor -->|"updates zones"| node_api_client
node_api -->|"streams alert events"| node_app

click node_rtsp "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/camera/rtsp_stream.py"
click node_worker "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/camera/camera_manager.py"
click node_detector "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/detection/detector.py"
click node_zones "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/detection/zone_manager.py"
click node_intrusion "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/detection/intrusion_detector.py"
click node_evidence "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/services/evidence_service.py"
click node_notifications "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/services/notification_service.py"
click node_api "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/main.py"
click node_ws "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/services/websocket_manager.py"
click node_models "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/models.py"
click node_database "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/database.py"
click node_evidence_store "https://github.com/dharshan-raj/perimeter_fencing_al/tree/main/evidence"
click node_config "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/config.py"
click node_app "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/frontend/src/App.jsx"
click node_api_client "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/frontend/src/services/api.js"
click node_feed "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/frontend/src/components/CameraFeed.jsx"
click node_zone_editor "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/frontend/src/ZoneEditor.jsx"
click node_alerts "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/frontend/src/components/AlertPanel.jsx"
click node_analytics "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/frontend/src/components/AnalyticsPanels.jsx"
click node_status "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/frontend/src/components/CameraStatus.jsx"
click node_sidebar "https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/frontend/src/components/Sidebar.jsx"

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_rtsp,node_worker toneBlue
class node_detector,node_zones,node_intrusion,node_evidence,node_notifications toneAmber
class node_api,node_ws,node_models,node_database,node_evidence_store,node_config toneMint
class node_app,node_api_client,node_feed,node_zone_editor,node_alerts,node_analytics,node_status,node_sidebar toneRose
class node_operator,node_camera,node_ntfy_service toneIndigo
```

## Components

### Video Capture

- [Stream reader](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/camera/rtsp_stream.py): `backend/camera/rtsp_stream.py`
- [Camera worker](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/camera/camera_manager.py): `backend/camera/camera_manager.py`

### Detection & Events

- [Person detector](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/detection/detector.py): `backend/detection/detector.py`
- [Zone manager](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/detection/zone_manager.py): `backend/detection/zone_manager.py`
- [Intrusion evaluation](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/detection/intrusion_detector.py): `backend/detection/intrusion_detector.py`
- [Evidence capture](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/services/evidence_service.py): `backend/services/evidence_service.py`
- [ntfy notifications](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/services/notification_service.py): `backend/services/notification_service.py`

### Monitoring API

- [FastAPI routes](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/main.py): `backend/main.py`
- [Alert WebSocket](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/services/websocket_manager.py): `backend/services/websocket_manager.py`
- [Event models](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/models.py): `backend/models.py`
- [SQL database](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/database.py): `backend/database.py`
- [Evidence files](https://github.com/dharshan-raj/perimeter_fencing_al/tree/main/evidence): `evidence`
- [Runtime settings](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/backend/config.py): `backend/config.py`

### Dashboard

- [Dashboard app](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [API client](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [Live feed](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/frontend/src/components/CameraFeed.jsx): `frontend/src/components/CameraFeed.jsx`
- [Zone editor](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/frontend/src/ZoneEditor.jsx): `frontend/src/ZoneEditor.jsx`
- [Alert panel](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/frontend/src/components/AlertPanel.jsx): `frontend/src/components/AlertPanel.jsx`
- [Analytics panels](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/frontend/src/components/AnalyticsPanels.jsx): `frontend/src/components/AnalyticsPanels.jsx`
- [Camera status](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/frontend/src/components/CameraStatus.jsx): `frontend/src/components/CameraStatus.jsx`
- [Navigation](https://github.com/dharshan-raj/perimeter_fencing_al/blob/main/frontend/src/components/Sidebar.jsx): `frontend/src/components/Sidebar.jsx`

### Other components

- **Security operator**
- **CCTV / webcam**
- **ntfy service**

## Connections

- CCTV / webcam → Stream reader: provides frames (evidence: `README.md`)
- Stream reader → Camera worker: reads stream (evidence: `backend/camera/camera_manager.py`)
- Runtime settings → Camera worker: configures (evidence: `backend/camera/camera_manager.py`)
- Camera worker → Person detector: runs detection (evidence: `backend/camera/camera_manager.py`)
- Camera worker → Zone manager: uses zones (evidence: `backend/camera/camera_manager.py`)
- Camera worker → Intrusion evaluation: evaluates tracks (evidence: `backend/camera/camera_manager.py`)
- Camera worker → Evidence capture: saves event frame (evidence: `backend/camera/camera_manager.py`)
- Camera worker → Event models: records events (evidence: `backend/camera/camera_manager.py`)
- Evidence capture → Evidence files: writes images (evidence: `backend/services/evidence_service.py`)
- Camera worker → FastAPI routes: publishes events (evidence: `backend/camera/camera_manager.py`)
- FastAPI routes → Alert WebSocket: broadcasts alerts (evidence: `backend/main.py`)
- FastAPI routes → ntfy notifications: dispatches critical (evidence: `backend/main.py`)
- ntfy notifications → ntfy service: posts notification (evidence: `backend/services/notification_service.py`)
- Event models → SQL database: maps records (evidence: `backend/models.py`)
- FastAPI routes → SQL database: queries and updates (evidence: `backend/main.py`)
- FastAPI routes → Camera worker: controls camera (evidence: `backend/main.py`)
- FastAPI routes → Zone manager: reads and updates (evidence: `backend/main.py`)
- FastAPI routes → Evidence files: serves images (evidence: `backend/main.py`)
- Security operator → Dashboard app: uses dashboard (evidence: `README.md`)
- Dashboard app → API client: requests data (evidence: `frontend/src/App.jsx`)
- API client → FastAPI routes: calls HTTP API (evidence: `README.md`)
- Dashboard app → Live feed: renders feed (evidence: `frontend/src/App.jsx`)
- Dashboard app → Alert panel: renders alerts (evidence: `frontend/src/App.jsx`)
- Dashboard app → Analytics panels: renders analytics (evidence: `frontend/src/App.jsx`)
- Dashboard app → Camera status: renders status (evidence: `frontend/src/App.jsx`)
- Dashboard app → Navigation: renders navigation (evidence: `frontend/src/App.jsx`)
- Live feed → Zone editor: embeds editor (evidence: `frontend/src/components/CameraFeed.jsx`)
- Live feed → FastAPI routes: loads MJPEG (evidence: `README.md`)
- Zone editor → API client: updates zones (evidence: `frontend/src/ZoneEditor.jsx`)
- FastAPI routes → Dashboard app: streams alert events (evidence: `README.md`)
