# sanjay4717/border-surveillance-anomaly-detection architecture

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

- Interactive diagram: https://gitdiagram.com/sanjay4717/border-surveillance-anomaly-detection
- Repository: https://github.com/sanjay4717/border-surveillance-anomaly-detection

## Overview

SENTRY is an academic image-based border-surveillance anomaly dashboard. An operator selects a frame, the React app submits it to the FastAPI detection endpoint, and the backend runs YOLO inference, checks relevant-object boxes against a restricted zone, annotates the frame, and logs the scan. The dashboard then refreshes scan history and summary statistics. The graph includes the major documented dashboard capabilities; source excerpts show the main API, inference, persistence, and UI wiring, but do not expose every implementation detail.

Main entry points: [`backend/app/routes/detection.py`](https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/backend/app/routes/detection.py) (Detection Routes), [`frontend/src/App.jsx`](https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/frontend/src/App.jsx) (Dashboard App), [`frontend/src/api/client.js`](https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/frontend/src/api/client.js) (API Client), [`ml/scripts/detect.py`](https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/ml/scripts/detect.py) (YOLO Detector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Operator Dashboard"]
  node_app["Dashboard App<br/>[App.jsx]"]
  node_upload["Frame Upload<br/>[UploadPanel.jsx]"]
  node_results["Scan Results<br/>[ResultsPanel.jsx]"]
  node_alertlog["Alert Log<br/>[AlertLog.jsx]"]
  node_stats["Summary Stats<br/>[StatsCards.jsx]"]
  node_status["Status Bar<br/>[StatusBar.jsx]"]
  node_client["API Client<br/>[client.js]"]
end

subgraph group_api["Detection API"]
  node_server["FastAPI App<br/>[main.py]"]
  node_routes["Detection Routes<br/>[detection.py]"]
end

subgraph group_analysis["Image Analysis"]
  node_model["Model Loader<br/>[model_loader.py]"]
  node_detector["YOLO Detector<br/>[detect.py]"]
  node_zone["Zone Analysis<br/>[detect.py]"]
  node_annotation["Frame Annotation<br/>[detect.py]"]
end

subgraph group_records["Scan Records"]
  node_uploads["Uploaded Frames"]
  node_annotated["Annotated Frames"]
  node_database[("Detection Database<br/>[database.py]")]
end

node_operator(("Operator"))

node_operator -->|"selects frame"| node_upload
node_upload -->|"submits file"| node_app
node_app -->|"requests scan"| node_client
node_client -->|"calls API"| node_server
node_server -->|"registers routes"| node_routes
node_routes -->|"writes upload"| node_uploads
node_routes -->|"gets detector"| node_model
node_model -->|"loads class"| node_detector
node_routes -->|"runs detection"| node_detector
node_detector -->|"checks overlap"| node_zone
node_detector -->|"draws results"| node_annotation
node_routes -->|"sets save path"| node_annotated
node_routes -->|"logs scan"| node_database
node_client -->|"requests history"| node_routes
node_client -->|"requests stats"| node_routes
node_app -->|"renders result"| node_results
node_app -->|"renders history"| node_alertlog
node_app -->|"renders stats"| node_stats
node_app -->|"renders status"| node_status
node_client -->|"returns response"| node_app

click node_app "https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/frontend/src/App.jsx"
click node_upload "https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/frontend/src/components/UploadPanel.jsx"
click node_results "https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/frontend/src/components/ResultsPanel.jsx"
click node_alertlog "https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/frontend/src/components/AlertLog.jsx"
click node_stats "https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/frontend/src/components/StatsCards.jsx"
click node_status "https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/frontend/src/components/StatusBar.jsx"
click node_client "https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/frontend/src/api/client.js"
click node_server "https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/backend/app/main.py"
click node_routes "https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/backend/app/routes/detection.py"
click node_model "https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/backend/app/models/model_loader.py"
click node_detector "https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/ml/scripts/detect.py"
click node_zone "https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/ml/scripts/detect.py"
click node_annotation "https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/ml/scripts/detect.py"
click node_uploads "https://github.com/sanjay4717/border-surveillance-anomaly-detection/tree/main/backend/uploads"
click node_annotated "https://github.com/sanjay4717/border-surveillance-anomaly-detection/tree/main/backend/detections"
click node_database "https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/backend/app/utils/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_app,node_upload,node_results,node_alertlog,node_stats,node_status,node_client toneBlue
class node_server,node_routes toneAmber
class node_model,node_detector,node_zone,node_annotation toneMint
class node_uploads,node_annotated,node_database toneRose
class node_operator toneIndigo
```

## Components

### Operator Dashboard

- [Dashboard App](https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Frame Upload](https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/frontend/src/components/UploadPanel.jsx): `frontend/src/components/UploadPanel.jsx`
- [Scan Results](https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/frontend/src/components/ResultsPanel.jsx): `frontend/src/components/ResultsPanel.jsx`
- [Alert Log](https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/frontend/src/components/AlertLog.jsx): `frontend/src/components/AlertLog.jsx`
- [Summary Stats](https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/frontend/src/components/StatsCards.jsx): `frontend/src/components/StatsCards.jsx`
- [Status Bar](https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/frontend/src/components/StatusBar.jsx): `frontend/src/components/StatusBar.jsx`
- [API Client](https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/frontend/src/api/client.js): `frontend/src/api/client.js`

### Detection API

- [FastAPI App](https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/backend/app/main.py): `backend/app/main.py`
- [Detection Routes](https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/backend/app/routes/detection.py): `backend/app/routes/detection.py`

### Image Analysis

- [Model Loader](https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/backend/app/models/model_loader.py): `backend/app/models/model_loader.py`
- [YOLO Detector](https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/ml/scripts/detect.py): `ml/scripts/detect.py`
- [Zone Analysis](https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/ml/scripts/detect.py): `ml/scripts/detect.py`
- [Frame Annotation](https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/ml/scripts/detect.py): `ml/scripts/detect.py`

### Scan Records

- [Uploaded Frames](https://github.com/sanjay4717/border-surveillance-anomaly-detection/tree/main/backend/uploads): `backend/uploads`
- [Annotated Frames](https://github.com/sanjay4717/border-surveillance-anomaly-detection/tree/main/backend/detections): `backend/detections`
- [Detection Database](https://github.com/sanjay4717/border-surveillance-anomaly-detection/blob/main/backend/app/utils/database.py): `backend/app/utils/database.py`

### Other components

- **Operator**

## Connections

- Operator → Frame Upload: selects frame (evidence: `frontend/src/components/UploadPanel.jsx`)
- Frame Upload → Dashboard App: submits file (evidence: `frontend/src/App.jsx`)
- Dashboard App → API Client: requests scan (evidence: `frontend/src/App.jsx`)
- API Client → FastAPI App: calls API (evidence: `frontend/src/api/client.js`)
- FastAPI App → Detection Routes: registers routes (evidence: `backend/app/main.py`)
- Detection Routes → Uploaded Frames: writes upload (evidence: `backend/app/routes/detection.py`)
- Detection Routes → Model Loader: gets detector (evidence: `backend/app/routes/detection.py`)
- Model Loader → YOLO Detector: loads class (evidence: `backend/app/models/model_loader.py`)
- Detection Routes → YOLO Detector: runs detection (evidence: `backend/app/routes/detection.py`)
- YOLO Detector → Zone Analysis: checks overlap (evidence: `ml/scripts/detect.py`)
- YOLO Detector → Frame Annotation: draws results (evidence: `ml/scripts/detect.py`)
- Detection Routes → Annotated Frames: sets save path (evidence: `backend/app/routes/detection.py`)
- Detection Routes → Detection Database: logs scan (evidence: `backend/app/routes/detection.py`)
- API Client → Detection Routes: requests history (evidence: `frontend/src/api/client.js`)
- API Client → Detection Routes: requests stats (evidence: `frontend/src/api/client.js`)
- Dashboard App → Scan Results: renders result (evidence: `frontend/src/App.jsx`)
- Dashboard App → Alert Log: renders history (evidence: `frontend/src/App.jsx`)
- Dashboard App → Summary Stats: renders stats (evidence: `frontend/src/App.jsx`)
- Dashboard App → Status Bar: renders status (evidence: `frontend/src/App.jsx`)
- API Client → Dashboard App: returns response (evidence: `frontend/src/App.jsx`)
