# rohithgp05/ai-construction-safety-monitoring-system architecture

> Architecture diagram of the GitHub repository rohithgp05/ai-construction-safety-monitoring-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rohithgp05/ai-construction-safety-monitoring-system
- Repository: https://github.com/rohithgp05/ai-construction-safety-monitoring-system

## Overview

This is a construction-site safety monitoring application. The main workflow is a user submitting an image or video, or enabling webcam capture; the Flask backend runs object detection and spatial safety checks, annotates frames, and records violations and summary metrics. The dashboard presents logs and analytics, while a report endpoint generates CSV/PDF exports. Training is represented as a separate model-development capability. Some dashboard and video-route details are documented but not fully excerpted, so those links cite the README.

Main entry points: [`backend/app.py`](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/app.py) (Flask API), [`frontend/js/app.js`](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/frontend/js/app.js) (Analytics Dashboard), [`backend/inference.py`](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/inference.py) (YOLO Inference), [`backend/database.py`](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/database.py) (Audit Database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Dashboard and Capture"]
  node_dashboard["Analytics Dashboard<br/>[app.js]"]
  node_image_video_capture["Image and Video Upload<br/>[app.js]"]
  node_webcam_capture["Webcam Capture<br/>[app.js]"]
end

subgraph group_processing["Detection and Safety"]
  node_api["Flask API<br/>[app.py]"]
  node_frame_processing["Frame Processing<br/>[app.py]"]
  node_video_processing["Video Processing<br/>[app.py]"]
  node_yolo_inference["YOLO Inference<br/>[inference.py]"]
  node_safety_rules["Safety Rules<br/>[safety_logic.py]"]
  node_annotated_frames["Annotated Frames<br/>[inference.py]"]
end

subgraph group_records["Audit and Analytics"]
  node_audit_store[("Audit Database<br/>[database.py]")]
  node_dashboard_metrics["Statistics Aggregation<br/>[database.py]"]
  node_violation_logs["Violation Logs<br/>[database.py]"]
end

subgraph group_reporting["Compliance Reports"]
  node_report_endpoint["Report Download API<br/>[app.py]"]
  node_report_generator["CSV and PDF Reports<br/>[generator.py]"]
end

subgraph group_modeling["Model Training"]
  node_training["YOLO Training<br/>[train.py]"]
  node_model_weights["Model Weights<br/>[best.pt]"]
end

node_user(("Safety Officer"))

node_user -->|"uses"| node_dashboard
node_dashboard -->|"submits media"| node_image_video_capture
node_dashboard -->|"captures frames"| node_webcam_capture
node_image_video_capture -->|"uploads media"| node_api
node_webcam_capture -->|"posts frames"| node_api
node_api -->|"processes images"| node_frame_processing
node_api -->|"starts processing"| node_video_processing
node_frame_processing -->|"runs inference"| node_yolo_inference
node_video_processing -->|"runs inference"| node_yolo_inference
node_yolo_inference -->|"evaluates detections"| node_safety_rules
node_yolo_inference -->|"draws overlays"| node_annotated_frames
node_frame_processing -->|"logs results"| node_audit_store
node_video_processing -->|"logs results"| node_audit_store
node_audit_store -->|"aggregates metrics"| node_dashboard_metrics
node_dashboard -->|"requests statistics"| node_api
node_dashboard -->|"displays audit logs"| node_violation_logs
node_api -->|"routes downloads"| node_report_endpoint
node_report_endpoint -->|"generates exports"| node_report_generator
node_report_generator -->|"reads logs and metrics"| node_audit_store
node_training -->|"produces weights"| node_model_weights
node_model_weights -->|"loads model"| node_yolo_inference

click node_dashboard "https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/frontend/js/app.js"
click node_image_video_capture "https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/frontend/js/app.js"
click node_webcam_capture "https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/frontend/js/app.js"
click node_api "https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/app.py"
click node_frame_processing "https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/app.py"
click node_video_processing "https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/app.py"
click node_yolo_inference "https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/inference.py"
click node_safety_rules "https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/safety_logic.py"
click node_annotated_frames "https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/inference.py"
click node_audit_store "https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/database.py"
click node_dashboard_metrics "https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/database.py"
click node_violation_logs "https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/database.py"
click node_report_endpoint "https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/app.py"
click node_report_generator "https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/reports/generator.py"
click node_training "https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/models/train.py"
click node_model_weights "https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/models/weights/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,node_image_video_capture,node_webcam_capture toneBlue
class node_api,node_frame_processing,node_video_processing,node_yolo_inference,node_safety_rules,node_annotated_frames toneAmber
class node_audit_store,node_dashboard_metrics,node_violation_logs toneMint
class node_report_endpoint,node_report_generator toneRose
class node_training,node_model_weights,node_user toneIndigo
```

## Components

### Dashboard and Capture

- [Analytics Dashboard](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/frontend/js/app.js): `frontend/js/app.js`
- [Image and Video Upload](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/frontend/js/app.js): `frontend/js/app.js`
- [Webcam Capture](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/frontend/js/app.js): `frontend/js/app.js`

### Detection and Safety

- [Flask API](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/app.py): `backend/app.py`
- [Frame Processing](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/app.py): `backend/app.py`
- [Video Processing](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/app.py): `backend/app.py`
- [YOLO Inference](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/inference.py): `backend/inference.py`
- [Safety Rules](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/safety_logic.py): `backend/safety_logic.py`
- [Annotated Frames](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/inference.py): `backend/inference.py`

### Audit and Analytics

- [Audit Database](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/database.py): `backend/database.py`
- [Statistics Aggregation](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/database.py): `backend/database.py`
- [Violation Logs](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/database.py): `backend/database.py`

### Compliance Reports

- [Report Download API](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/backend/app.py): `backend/app.py`
- [CSV and PDF Reports](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/reports/generator.py): `reports/generator.py`

### Model Training

- [YOLO Training](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/models/train.py): `models/train.py`
- [Model Weights](https://github.com/rohithgp05/ai-construction-safety-monitoring-system/blob/main/models/weights/best.pt): `models/weights/best.pt`

### Other components

- **Safety Officer**

## Connections

- Safety Officer → Analytics Dashboard: uses (evidence: `README.md`)
- Analytics Dashboard → Image and Video Upload: submits media (evidence: `README.md`)
- Analytics Dashboard → Webcam Capture: captures frames (evidence: `README.md`)
- Image and Video Upload → Flask API: uploads media (evidence: `README.md`)
- Webcam Capture → Flask API: posts frames (evidence: `frontend/js/app.js`)
- Flask API → Frame Processing: processes images (evidence: `backend/app.py`)
- Flask API → Video Processing: starts processing (evidence: `backend/app.py`)
- Frame Processing → YOLO Inference: runs inference (evidence: `backend/app.py`)
- Video Processing → YOLO Inference: runs inference (evidence: `backend/app.py`)
- YOLO Inference → Safety Rules: evaluates detections (evidence: `backend/inference.py`)
- YOLO Inference → Annotated Frames: draws overlays (evidence: `backend/inference.py`)
- Frame Processing → Audit Database: logs results (evidence: `backend/app.py`)
- Video Processing → Audit Database: logs results (evidence: `backend/app.py`)
- Audit Database → Statistics Aggregation: aggregates metrics (evidence: `backend/database.py`)
- Analytics Dashboard → Flask API: requests statistics (evidence: `README.md`)
- Analytics Dashboard → Violation Logs: displays audit logs (evidence: `README.md`)
- Flask API → Report Download API: routes downloads (evidence: `backend/app.py`)
- Report Download API → CSV and PDF Reports: generates exports (evidence: `backend/app.py`)
- CSV and PDF Reports → Audit Database: reads logs and metrics (evidence: `reports/generator.py`)
- YOLO Training → Model Weights: produces weights (evidence: `README.md`)
- Model Weights → YOLO Inference: loads model (evidence: `README.md`)
