# dhlee-gif/fireextinguisher architecture

> Architecture diagram of the GitHub repository dhlee-gif/fireextinguisher, 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/dhlee-gif/fireextinguisher
- Repository: https://github.com/dhlee-gif/fireextinguisher

## Overview

FireExtinguisher is a Flask/MariaDB control dashboard for an autonomous fire-response RC car. Operators view live status and fire, water, and device logs, then issue sortie, stop, return, or resume commands. The car reports heartbeats, fire events and images, spray results, status, and water readings through the API; the dashboard combines persisted records with in-memory live state. The simulator exercises that device-facing API. The excerpts show these main routes and data dependencies; other template behavior and unsampled modules are represented only where the README or tree supports them.

Main entry points: [`web/api.py`](https://github.com/dhlee-gif/fireextinguisher/blob/master/web/api.py) (Device API), [`web/app.py`](https://github.com/dhlee-gif/fireextinguisher/blob/master/web/app.py) (Dashboard routes), [`web/static/js/live.js`](https://github.com/dhlee-gif/fireextinguisher/blob/master/web/static/js/live.js) (Live dashboard), [`web/db.py`](https://github.com/dhlee-gif/fireextinguisher/blob/master/web/db.py) (Database sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Operator interface"]
  node_dashboard["Dashboard routes<br/>[app.py]"]
  node_browser["Live dashboard<br/>[live.js]"]
  node_views["Dashboard views"]
end

subgraph group_control["Control and telemetry"]
  node_simulator["Car simulator<br/>[simulator.py]"]
  node_device_api["Device API<br/>[api.py]"]
  node_live_state["Live command state<br/>[state.py]"]
  node_labels["Display labels<br/>[labels.py]"]
end

subgraph group_records["Domain records"]
  node_fire_records["Fire events and images<br/>[models.py]"]
  node_device_records["Device and admin records<br/>[models.py]"]
  node_telemetry_records["Status and water logs<br/>[models.py]"]
end

subgraph group_runtime["Runtime support"]
  node_database_session["Database sessions<br/>[db.py]"]
  node_configuration["Runtime configuration<br/>[config.py]"]
end

node_operator(("Operator"))
node_device(("RC car"))
node_mariadb[("MariaDB")]
node_camera_stream(("Camera stream"))

node_operator -->|"uses"| node_browser
node_browser -->|"loads pages"| node_dashboard
node_dashboard -->|"renders"| node_views
node_browser -->|"polls and commands"| node_device_api
node_browser -.->|"displays stream"| node_camera_stream
node_device -.->|"reports telemetry"| node_device_api
node_simulator -->|"sends API requests"| node_device_api
node_device_api -->|"opens sessions"| node_database_session
node_dashboard -->|"opens sessions"| node_database_session
node_database_session -->|"connects"| node_mariadb
node_device_api -->|"updates and reads"| node_live_state
node_dashboard -->|"reads and queues"| node_live_state
node_device_api -->|"writes fire data"| node_fire_records
node_device_api -->|"writes telemetry"| node_telemetry_records
node_device_api -->|"updates device"| node_device_records
node_dashboard -->|"queries fire history"| node_fire_records
node_dashboard -->|"queries logs"| node_telemetry_records
node_dashboard -->|"queries admin and device"| node_device_records
node_dashboard -->|"uses labels"| node_labels
node_device_api -->|"validates actions"| node_labels
node_dashboard -->|"loads settings"| node_configuration
node_device_api -->|"loads settings"| node_configuration
node_database_session -->|"configures engine"| node_configuration

click node_dashboard "https://github.com/dhlee-gif/fireextinguisher/blob/master/web/app.py"
click node_browser "https://github.com/dhlee-gif/fireextinguisher/blob/master/web/static/js/live.js"
click node_views "https://github.com/dhlee-gif/fireextinguisher/tree/master/web/templates"
click node_simulator "https://github.com/dhlee-gif/fireextinguisher/blob/master/web/simulator.py"
click node_device_api "https://github.com/dhlee-gif/fireextinguisher/blob/master/web/api.py"
click node_live_state "https://github.com/dhlee-gif/fireextinguisher/blob/master/web/state.py"
click node_labels "https://github.com/dhlee-gif/fireextinguisher/blob/master/web/labels.py"
click node_fire_records "https://github.com/dhlee-gif/fireextinguisher/blob/master/web/models.py"
click node_device_records "https://github.com/dhlee-gif/fireextinguisher/blob/master/web/models.py"
click node_telemetry_records "https://github.com/dhlee-gif/fireextinguisher/blob/master/web/models.py"
click node_database_session "https://github.com/dhlee-gif/fireextinguisher/blob/master/web/db.py"
click node_configuration "https://github.com/dhlee-gif/fireextinguisher/blob/master/web/config.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_dashboard,node_browser,node_views toneBlue
class node_simulator,node_device_api,node_live_state,node_labels,node_mariadb toneAmber
class node_fire_records,node_device_records,node_telemetry_records toneMint
class node_database_session,node_configuration toneRose
class node_operator,node_device,node_camera_stream toneIndigo
```

## Components

### Operator interface

- [Dashboard routes](https://github.com/dhlee-gif/fireextinguisher/blob/master/web/app.py): `web/app.py`
- [Live dashboard](https://github.com/dhlee-gif/fireextinguisher/blob/master/web/static/js/live.js): `web/static/js/live.js`
- [Dashboard views](https://github.com/dhlee-gif/fireextinguisher/tree/master/web/templates): `web/templates`

### Control and telemetry

- [Car simulator](https://github.com/dhlee-gif/fireextinguisher/blob/master/web/simulator.py): `web/simulator.py`
- [Device API](https://github.com/dhlee-gif/fireextinguisher/blob/master/web/api.py): `web/api.py`
- [Live command state](https://github.com/dhlee-gif/fireextinguisher/blob/master/web/state.py): `web/state.py`
- [Display labels](https://github.com/dhlee-gif/fireextinguisher/blob/master/web/labels.py): `web/labels.py`

### Domain records

- [Fire events and images](https://github.com/dhlee-gif/fireextinguisher/blob/master/web/models.py): `web/models.py`
- [Device and admin records](https://github.com/dhlee-gif/fireextinguisher/blob/master/web/models.py): `web/models.py`
- [Status and water logs](https://github.com/dhlee-gif/fireextinguisher/blob/master/web/models.py): `web/models.py`

### Runtime support

- [Database sessions](https://github.com/dhlee-gif/fireextinguisher/blob/master/web/db.py): `web/db.py`
- [Runtime configuration](https://github.com/dhlee-gif/fireextinguisher/blob/master/web/config.py): `web/config.py`

### Other components

- **Operator**
- **RC car**
- **MariaDB**
- **Camera stream**

## Connections

- Operator → Live dashboard: uses (evidence: `web/static/js/live.js`)
- Live dashboard → Dashboard routes: loads pages (evidence: `web/app.py`)
- Dashboard routes → Dashboard views: renders (evidence: `web/app.py`)
- Live dashboard → Device API: polls and commands (evidence: `web/static/js/live.js`)
- Live dashboard → Camera stream: displays stream
- RC car → Device API: reports telemetry
- Car simulator → Device API: sends API requests (evidence: `web/simulator.py`)
- Device API → Database sessions: opens sessions (evidence: `web/api.py`)
- Dashboard routes → Database sessions: opens sessions (evidence: `web/app.py`)
- Database sessions → MariaDB: connects (evidence: `web/db.py`)
- Device API → Live command state: updates and reads (evidence: `web/api.py`)
- Dashboard routes → Live command state: reads and queues (evidence: `web/app.py`)
- Device API → Fire events and images: writes fire data (evidence: `web/api.py`)
- Device API → Status and water logs: writes telemetry (evidence: `web/api.py`)
- Device API → Device and admin records: updates device (evidence: `web/api.py`)
- Dashboard routes → Fire events and images: queries fire history (evidence: `web/app.py`)
- Dashboard routes → Status and water logs: queries logs (evidence: `web/app.py`)
- Dashboard routes → Device and admin records: queries admin and device (evidence: `web/app.py`)
- Dashboard routes → Display labels: uses labels (evidence: `web/app.py`)
- Device API → Display labels: validates actions (evidence: `web/api.py`)
- Dashboard routes → Runtime configuration: loads settings (evidence: `web/app.py`)
- Device API → Runtime configuration: loads settings (evidence: `web/api.py`)
- Database sessions → Runtime configuration: configures engine (evidence: `web/db.py`)
