# jahangir-alisoy/firewatch architecture

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

- Interactive diagram: https://gitdiagram.com/jahangir-alisoy/firewatch
- Repository: https://github.com/jahangir-alisoy/firewatch

## Overview

FireWatch combines camera-based fire/smoke detection with Arduino sensor readings, fuses them into an alert level, and serves a live dashboard. The main workflow is camera frames → vision scores and sensor readings → fusion/state updates → dashboard streams; mute commands travel back to the sensor link. The firmware and dashboard capabilities are represented from the repository tree, but their source was not sampled, so their internal details and links are limited to documented behavior in the server excerpt.

Main entry points: [`app/server.py`](https://github.com/jahangir-alisoy/firewatch/blob/main/app/server.py) (Web API), [`app/detector.py`](https://github.com/jahangir-alisoy/firewatch/blob/main/app/detector.py) (Vision scoring), [`app/link.py`](https://github.com/jahangir-alisoy/firewatch/blob/main/app/link.py) (Serial link), [`arduino/firewatch/firewatch.ino`](https://github.com/jahangir-alisoy/firewatch/blob/main/arduino/firewatch/firewatch.ino) (Arduino sensors)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sensing["Fire sensing"]
  node_vision["Vision scoring<br/>[detector.py]"]
  node_onnx["ONNX detector<br/>[detector.py]"]
  node_yolo["YOLO detector<br/>[detector.py]"]
  node_heuristic["CV fallback<br/>[detector.py]"]
  node_arduino["Arduino sensors<br/>[firewatch.ino]"]
  node_serial["Serial link<br/>[link.py]"]
  node_sim["Sensor simulator<br/>[link.py]"]
end

subgraph group_fusion["Alert coordination"]
  node_camera["Camera input<br/>[server.py]"]
  node_fusion["Level fusion<br/>[server.py]"]
  node_alert["Alert state<br/>[server.py]"]
  node_history[("History and logs<br/>[server.py]")]
  node_captures["Snapshots<br/>[server.py]"]
end

subgraph group_dashboard["Live dashboard"]
  node_web["Web API<br/>[server.py]"]
  node_dashboard_ui["Dashboard UI<br/>[index.html]"]
end

node_operator(("Operator"))
node_camera_device["Camera or video"]
node_model_files["Model files<br/>[fire_smoke.onnx]"]

node_camera -->|"processes frames"| node_vision
node_vision -.->|"selects backend"| node_onnx
node_vision -.->|"selects backend"| node_yolo
node_vision -.->|"falls back"| node_heuristic
node_model_files -.->|"loads weights"| node_onnx
node_arduino -.->|"sends readings"| node_serial
node_serial -->|"provides readings"| node_fusion
node_sim -->|"provides readings"| node_fusion
node_vision -->|"provides scores"| node_fusion
node_fusion -->|"updates state"| node_alert
node_fusion -->|"sets level"| node_serial
node_alert -->|"records updates"| node_history
node_web -->|"serves state"| node_history
node_web -->|"writes snapshots"| node_captures
node_dashboard_ui -.->|"uses dashboard"| node_web
node_web -.->|"streams updates"| node_operator
node_operator -->|"mutes alarm"| node_web
node_web -->|"forwards mute"| node_serial
node_camera_device -.->|"supplies frames"| node_camera

click node_camera "https://github.com/jahangir-alisoy/firewatch/blob/main/app/server.py"
click node_vision "https://github.com/jahangir-alisoy/firewatch/blob/main/app/detector.py"
click node_onnx "https://github.com/jahangir-alisoy/firewatch/blob/main/app/detector.py"
click node_yolo "https://github.com/jahangir-alisoy/firewatch/blob/main/app/detector.py"
click node_heuristic "https://github.com/jahangir-alisoy/firewatch/blob/main/app/detector.py"
click node_arduino "https://github.com/jahangir-alisoy/firewatch/blob/main/arduino/firewatch/firewatch.ino"
click node_serial "https://github.com/jahangir-alisoy/firewatch/blob/main/app/link.py"
click node_sim "https://github.com/jahangir-alisoy/firewatch/blob/main/app/link.py"
click node_fusion "https://github.com/jahangir-alisoy/firewatch/blob/main/app/server.py"
click node_alert "https://github.com/jahangir-alisoy/firewatch/blob/main/app/server.py"
click node_history "https://github.com/jahangir-alisoy/firewatch/blob/main/app/server.py"
click node_captures "https://github.com/jahangir-alisoy/firewatch/blob/main/app/server.py"
click node_web "https://github.com/jahangir-alisoy/firewatch/blob/main/app/server.py"
click node_dashboard_ui "https://github.com/jahangir-alisoy/firewatch/blob/main/app/static/index.html"
click node_model_files "https://github.com/jahangir-alisoy/firewatch/blob/main/models/fire_smoke.onnx"

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_vision,node_onnx,node_yolo,node_heuristic,node_arduino,node_serial,node_sim toneBlue
class node_camera,node_fusion,node_alert,node_history,node_captures toneAmber
class node_web,node_dashboard_ui toneMint
class node_operator,node_camera_device,node_model_files toneIndigo
```

## Components

### Fire sensing

- [Vision scoring](https://github.com/jahangir-alisoy/firewatch/blob/main/app/detector.py): `app/detector.py`
- [ONNX detector](https://github.com/jahangir-alisoy/firewatch/blob/main/app/detector.py): `app/detector.py`
- [YOLO detector](https://github.com/jahangir-alisoy/firewatch/blob/main/app/detector.py): `app/detector.py`
- [CV fallback](https://github.com/jahangir-alisoy/firewatch/blob/main/app/detector.py): `app/detector.py`
- [Arduino sensors](https://github.com/jahangir-alisoy/firewatch/blob/main/arduino/firewatch/firewatch.ino): `arduino/firewatch/firewatch.ino`
- [Serial link](https://github.com/jahangir-alisoy/firewatch/blob/main/app/link.py): `app/link.py`
- [Sensor simulator](https://github.com/jahangir-alisoy/firewatch/blob/main/app/link.py): `app/link.py`

### Alert coordination

- [Camera input](https://github.com/jahangir-alisoy/firewatch/blob/main/app/server.py): `app/server.py`
- [Level fusion](https://github.com/jahangir-alisoy/firewatch/blob/main/app/server.py): `app/server.py`
- [Alert state](https://github.com/jahangir-alisoy/firewatch/blob/main/app/server.py): `app/server.py`
- [History and logs](https://github.com/jahangir-alisoy/firewatch/blob/main/app/server.py): `app/server.py`
- [Snapshots](https://github.com/jahangir-alisoy/firewatch/blob/main/app/server.py): `app/server.py`

### Live dashboard

- [Web API](https://github.com/jahangir-alisoy/firewatch/blob/main/app/server.py): `app/server.py`
- [Dashboard UI](https://github.com/jahangir-alisoy/firewatch/blob/main/app/static/index.html): `app/static/index.html`

### Other components

- **Operator**
- **Camera or video**
- [Model files](https://github.com/jahangir-alisoy/firewatch/blob/main/models/fire_smoke.onnx): `models/fire_smoke.onnx`

## Connections

- Camera input → Vision scoring: processes frames (evidence: `app/server.py`)
- Vision scoring → ONNX detector: selects backend (evidence: `app/detector.py`)
- Vision scoring → YOLO detector: selects backend (evidence: `app/detector.py`)
- Vision scoring → CV fallback: falls back (evidence: `app/detector.py`)
- Model files → ONNX detector: loads weights
- Arduino sensors → Serial link: sends readings
- Serial link → Level fusion: provides readings (evidence: `app/server.py`)
- Sensor simulator → Level fusion: provides readings (evidence: `app/server.py`)
- Vision scoring → Level fusion: provides scores (evidence: `app/server.py`)
- Level fusion → Alert state: updates state (evidence: `app/server.py`)
- Level fusion → Serial link: sets level (evidence: `app/server.py`)
- Alert state → History and logs: records updates (evidence: `app/server.py`)
- Web API → History and logs: serves state (evidence: `app/server.py`)
- Web API → Snapshots: writes snapshots (evidence: `app/server.py`)
- Dashboard UI → Web API: uses dashboard
- Web API → Operator: streams updates
- Operator → Web API: mutes alarm (evidence: `app/server.py`)
- Web API → Serial link: forwards mute (evidence: `app/server.py`)
- Camera or video → Camera input: supplies frames
