# avishkar-chavan1/ai-camera-detection architecture

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

- Interactive diagram: https://gitdiagram.com/avishkar-chavan1/ai-camera-detection
- Repository: https://github.com/avishkar-chavan1/ai-camera-detection

## Overview

Industrial Safety AI is a PPE detection and compliance platform: a user uploads an image or video in the Streamlit dashboard, which sends media bytes to the FastAPI service; inference produces detections and worker compliance results, which the dashboard displays. The dashboard also supports a host-local webcam workflow. A separate local vision runtime handles camera/video tracking and PPE association. README documents health, readiness, metrics, event history, and upload validation; sampled source shows the main API and local-pipeline wiring. Unsampled route details are not expanded beyond documented capabilities.

Main entry points: [`vision/pipeline.py`](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/pipeline.py) (Video pipeline), [`backend/app/main.py`](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/backend/app/main.py) (API application), [`dashboard/app.py`](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/dashboard/app.py) (Streamlit dashboard), [`vision/inference.py`](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/inference.py) (YOLO inference)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_dashboard["Streamlit dashboard<br/>[app.py]"]
end

subgraph group_api["Inference API"]
  node_api_routes["API routes<br/>[routes.py]"]
  node_app["API application<br/>[main.py]"]
  node_inference_service["Response adapter"]
end

subgraph group_vision["Vision processing"]
  node_engine["YOLO inference<br/>[inference.py]"]
  node_compliance["Compliance rules<br/>[compliance.py]"]
  node_domain_models["Vision data types<br/>[models.py]"]
  node_local_cli["Local vision CLI<br/>[cli.py]"]
  node_pipeline["Video pipeline<br/>[pipeline.py]"]
  node_video_input["Camera/video input<br/>[video_input.py]"]
  node_person_tracking["Person tracking<br/>[tracking.py]"]
  node_ppe_detection["PPE detection<br/>[detection.py]"]
  node_association["Worker PPE association<br/>[association.py]"]
  node_visualization["Frame annotation<br/>[visualization.py]"]
end

subgraph group_state["Configuration and records"]
  node_config["Settings<br/>[config.py]"]
  node_logging["Application logging<br/>[logging.py]"]
  node_event_log[("Inference event log<br/>[event_log.py]")]
  node_model_artifact["PPE checkpoint<br/>[best.pt]"]
end

node_user(("Operator"))
node_ultralytics["Ultralytics runtime"]

node_user -->|"submits media"| node_dashboard
node_dashboard -->|"sends media bytes"| node_api_routes
node_api_routes -->|"requests inference"| node_inference_service
node_inference_service -->|"runs inference"| node_engine
node_inference_service -->|"analyzes compliance"| node_compliance
node_app -->|"registers routes"| node_api_routes
node_app -->|"loads settings"| node_config
node_app -->|"loads model"| node_engine
node_app -->|"initializes logger"| node_event_log
node_app -->|"configures logging"| node_logging
node_app -->|"loads checkpoint"| node_model_artifact
node_engine -->|"loads YOLO"| node_ultralytics
node_engine -->|"creates detections"| node_domain_models
node_compliance -->|"uses bounding boxes"| node_domain_models
node_local_cli -->|"starts pipeline"| node_pipeline
node_pipeline -->|"reads frames"| node_video_input
node_pipeline -->|"tracks workers"| node_person_tracking
node_pipeline -->|"detects PPE"| node_ppe_detection
node_pipeline -->|"associates detections"| node_association
node_pipeline -->|"annotates frames"| node_visualization
node_pipeline -->|"builds from settings"| node_config
node_dashboard -.->|"runs local inference"| node_engine
node_dashboard -.->|"shows compliance"| node_compliance
node_dashboard -.->|"records local events"| node_event_log
node_api_routes -->|"reads event history"| node_event_log

click node_dashboard "https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/dashboard/app.py"
click node_api_routes "https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/backend/app/api/routes.py"
click node_app "https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/backend/app/main.py"
click node_inference_service "https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/backend/app/services/inference_service.py"
click node_engine "https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/inference.py"
click node_compliance "https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/compliance.py"
click node_domain_models "https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/models.py"
click node_local_cli "https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/cli.py"
click node_pipeline "https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/pipeline.py"
click node_video_input "https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/video_input.py"
click node_person_tracking "https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/tracking.py"
click node_ppe_detection "https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/detection.py"
click node_association "https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/association.py"
click node_visualization "https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/visualization.py"
click node_config "https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/backend/app/core/config.py"
click node_logging "https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/backend/app/core/logging.py"
click node_event_log "https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/event_log.py"
click node_model_artifact "https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/best.pt"

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_dashboard toneBlue
class node_api_routes,node_app,node_inference_service toneAmber
class node_engine,node_compliance,node_domain_models,node_local_cli,node_pipeline,node_video_input,node_person_tracking,node_ppe_detection,node_association,node_visualization toneMint
class node_config,node_logging,node_event_log,node_model_artifact toneRose
class node_user,node_ultralytics toneIndigo
```

## Components

### User experience

- [Streamlit dashboard](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/dashboard/app.py): `dashboard/app.py`

### Inference API

- [API routes](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/backend/app/api/routes.py): `backend/app/api/routes.py`
- [API application](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/backend/app/main.py): `backend/app/main.py`
- [Response adapter](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/backend/app/services/inference_service.py): `backend/app/services/inference_service.py`

### Vision processing

- [YOLO inference](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/inference.py): `vision/inference.py`
- [Compliance rules](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/compliance.py): `vision/compliance.py`
- [Vision data types](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/models.py): `vision/models.py`
- [Local vision CLI](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/cli.py): `vision/cli.py`
- [Video pipeline](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/pipeline.py): `vision/pipeline.py`
- [Camera/video input](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/video_input.py): `vision/video_input.py`
- [Person tracking](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/tracking.py): `vision/tracking.py`
- [PPE detection](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/detection.py): `vision/detection.py`
- [Worker PPE association](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/association.py): `vision/association.py`
- [Frame annotation](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/visualization.py): `vision/visualization.py`

### Configuration and records

- [Settings](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/backend/app/core/config.py): `backend/app/core/config.py`
- [Application logging](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/backend/app/core/logging.py): `backend/app/core/logging.py`
- [Inference event log](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/vision/event_log.py): `vision/event_log.py`
- [PPE checkpoint](https://github.com/avishkar-chavan1/ai-camera-detection/blob/main/best.pt): `best.pt`

### Other components

- **Operator**
- **Ultralytics runtime**

## Connections

- Operator → Streamlit dashboard: submits media (evidence: `README.md`)
- Streamlit dashboard → API routes: sends media bytes (evidence: `dashboard/app.py`)
- API routes → Response adapter: requests inference (evidence: `backend/app/api/routes.py`)
- Response adapter → YOLO inference: runs inference (evidence: `backend/app/services/inference_service.py`)
- Response adapter → Compliance rules: analyzes compliance (evidence: `backend/app/services/inference_service.py`)
- API application → API routes: registers routes (evidence: `backend/app/main.py`)
- API application → Settings: loads settings (evidence: `backend/app/main.py`)
- API application → YOLO inference: loads model (evidence: `backend/app/main.py`)
- API application → Inference event log: initializes logger (evidence: `backend/app/main.py`)
- API application → Application logging: configures logging (evidence: `backend/app/main.py`)
- API application → PPE checkpoint: loads checkpoint (evidence: `backend/app/main.py`)
- YOLO inference → Ultralytics runtime: loads YOLO (evidence: `vision/inference.py`)
- YOLO inference → Vision data types: creates detections (evidence: `vision/inference.py`)
- Compliance rules → Vision data types: uses bounding boxes (evidence: `vision/compliance.py`)
- Local vision CLI → Video pipeline: starts pipeline (evidence: `vision/cli.py`)
- Video pipeline → Camera/video input: reads frames (evidence: `vision/pipeline.py`)
- Video pipeline → Person tracking: tracks workers (evidence: `vision/pipeline.py`)
- Video pipeline → PPE detection: detects PPE (evidence: `vision/pipeline.py`)
- Video pipeline → Worker PPE association: associates detections (evidence: `vision/pipeline.py`)
- Video pipeline → Frame annotation: annotates frames (evidence: `vision/pipeline.py`)
- Video pipeline → Settings: builds from settings (evidence: `vision/pipeline.py`)
- Streamlit dashboard → YOLO inference: runs local inference (evidence: `README.md`)
- Streamlit dashboard → Compliance rules: shows compliance (evidence: `README.md`)
- Streamlit dashboard → Inference event log: records local events (evidence: `dashboard/app.py`)
- API routes → Inference event log: reads event history (evidence: `backend/app/api/routes.py`)
