# fikrifz-17/fire-smoke-detection architecture

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

- Interactive diagram: https://gitdiagram.com/fikrifz-17/fire-smoke-detection
- Repository: https://github.com/fikrifz-17/fire-smoke-detection

## Overview

This Flask application detects fire and smoke in webcam frames or uploaded videos, annotates detections, and streams or returns processed media. The main runtime lives in app.py: its routes coordinate input handling, the shared YOLO detector, and media output. The README documents the live and upload pages; source excerpts show the detection and processing implementation. The templates and model artifact are present in the tree but were not sampled, so their internal behavior is not inferred.

Main entry points: [`app.py`](https://github.com/fikrifz-17/fire-smoke-detection/blob/master/app.py) (Flask routes), [`templates/live.html`](https://github.com/fikrifz-17/fire-smoke-detection/blob/master/templates/live.html) (Live page), [`templates/image.html`](https://github.com/fikrifz-17/fire-smoke-detection/blob/master/templates/image.html) (Upload page), [`models/best.pt`](https://github.com/fikrifz-17/fire-smoke-detection/blob/master/models/best.pt) (YOLO weights)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_flask["Flask routes<br/>[app.py]"]
  node_live_page["Live page<br/>[live.html]"]
  node_upload_page["Upload page<br/>[image.html]"]
end

subgraph group_detect["Detection runtime"]
  node_detector["Fire-smoke detector<br/>[app.py]"]
  node_weights["YOLO weights<br/>[best.pt]"]
  node_yolo["YOLO runtime"]
end

subgraph group_media["Media processing"]
  node_webcam["Webcam"]
  node_frame_loop["Live frame loop<br/>[app.py]"]
  node_video_input["Uploaded video"]
  node_video_output["Processed video"]
end

node_user(("User"))

node_user -->|"opens live page"| node_flask
node_flask -->|"renders"| node_live_page
node_user -->|"opens upload page"| node_flask
node_flask -->|"renders"| node_upload_page
node_flask -->|"starts stream"| node_frame_loop
node_frame_loop -->|"reads frames"| node_webcam
node_frame_loop -->|"detects objects"| node_detector
node_frame_loop -->|"streams frames"| node_flask
node_detector -->|"runs prediction"| node_yolo
node_detector -->|"loads weights"| node_weights
node_user -.->|"provides video"| node_video_input
node_video_input -.->|"uploads for detection"| node_flask
node_flask -->|"processes frames"| node_detector
node_flask -->|"writes processed video"| node_video_output
node_flask -->|"returns video"| node_user

click node_flask "https://github.com/fikrifz-17/fire-smoke-detection/blob/master/app.py"
click node_live_page "https://github.com/fikrifz-17/fire-smoke-detection/blob/master/templates/live.html"
click node_upload_page "https://github.com/fikrifz-17/fire-smoke-detection/blob/master/templates/image.html"
click node_detector "https://github.com/fikrifz-17/fire-smoke-detection/blob/master/app.py"
click node_weights "https://github.com/fikrifz-17/fire-smoke-detection/blob/master/models/best.pt"
click node_frame_loop "https://github.com/fikrifz-17/fire-smoke-detection/blob/master/app.py"
click node_video_output "https://github.com/fikrifz-17/fire-smoke-detection/tree/master/uploads"

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_flask,node_live_page,node_upload_page,node_user toneBlue
class node_detector,node_weights,node_yolo toneAmber
class node_webcam,node_frame_loop,node_video_input,node_video_output toneMint
```

## Components

### Web interface

- [Flask routes](https://github.com/fikrifz-17/fire-smoke-detection/blob/master/app.py): `app.py`
- [Live page](https://github.com/fikrifz-17/fire-smoke-detection/blob/master/templates/live.html): `templates/live.html`
- [Upload page](https://github.com/fikrifz-17/fire-smoke-detection/blob/master/templates/image.html): `templates/image.html`

### Detection runtime

- [Fire-smoke detector](https://github.com/fikrifz-17/fire-smoke-detection/blob/master/app.py): `app.py`
- [YOLO weights](https://github.com/fikrifz-17/fire-smoke-detection/blob/master/models/best.pt): `models/best.pt`
- **YOLO runtime**

### Media processing

- **Webcam**
- [Live frame loop](https://github.com/fikrifz-17/fire-smoke-detection/blob/master/app.py): `app.py`
- **Uploaded video**
- [Processed video](https://github.com/fikrifz-17/fire-smoke-detection/tree/master/uploads): `uploads`

### Other components

- **User**

## Connections

- User → Flask routes: opens live page (evidence: `README.md`)
- Flask routes → Live page: renders (evidence: `app.py`)
- User → Flask routes: opens upload page (evidence: `README.md`)
- Flask routes → Upload page: renders (evidence: `app.py`)
- Flask routes → Live frame loop: starts stream (evidence: `app.py`)
- Live frame loop → Webcam: reads frames (evidence: `app.py`)
- Live frame loop → Fire-smoke detector: detects objects (evidence: `app.py`)
- Live frame loop → Flask routes: streams frames (evidence: `app.py`)
- Fire-smoke detector → YOLO runtime: runs prediction (evidence: `app.py`)
- Fire-smoke detector → YOLO weights: loads weights (evidence: `app.py`)
- User → Uploaded video: provides video
- Uploaded video → Flask routes: uploads for detection
- Flask routes → Fire-smoke detector: processes frames (evidence: `app.py`)
- Flask routes → Processed video: writes processed video (evidence: `app.py`)
- Flask routes → User: returns video (evidence: `app.py`)
