# nathan-samms/iot_thermo architecture

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

- Interactive diagram: https://gitdiagram.com/nathan-samms/iot_thermo
- Repository: https://github.com/nathan-samms/iot_thermo

## Overview

This is a small web interface for setting a servo angle and switching a fan relay, with status refreshes in the browser. The sampled frontend shows requests to status, angle, and fan endpoints, but the app excerpt does not show their route handlers, so the browser-to-server link is marked unverified and no handler-to-hardware flow is inferred. State persistence and the relay’s state updates are visible; the README is empty.

Main entry points: [`settings.py`](https://github.com/nathan-samms/iot_thermo/blob/main/settings.py) (Hardware settings), [`control/relaytools.py`](https://github.com/nathan-samms/iot_thermo/blob/main/control/relaytools.py) (Fan relay), [`control/state.py`](https://github.com/nathan-samms/iot_thermo/blob/main/control/state.py) (State manager), [`control/servotools.py`](https://github.com/nathan-samms/iot_thermo/blob/main/control/servotools.py) (Servo controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_browser["Control UI<br/>[main.js]"]
  node_server["Flask app<br/>[app.py]"]
end

subgraph group_control["Hardware control"]
  node_servo["Servo controller<br/>[servotools.py]"]
  node_relay["Fan relay<br/>[relaytools.py]"]
end

subgraph group_configuration["Configuration and state"]
  node_settings["Hardware settings<br/>[settings.py]"]
  node_state["State manager<br/>[state.py]"]
  node_statefile[("JSON state file<br/>[state.json]")]
end

node_operator(("Operator"))
node_gpio{{"GPIO hardware"}}

node_operator -->|"uses"| node_browser
node_browser -.->|"requests API"| node_server
node_server -->|"imports auth setting"| node_settings
node_servo -->|"imports pin limits"| node_settings
node_relay -->|"imports relay pin"| node_settings
node_state -->|"imports state path"| node_settings
node_relay -->|"updates fan state"| node_state
node_servo -->|"controls servo"| node_gpio
node_relay -->|"switches relay"| node_gpio
node_state -->|"loads and saves"| node_statefile

click node_browser "https://github.com/nathan-samms/iot_thermo/blob/main/static/main.js"
click node_server "https://github.com/nathan-samms/iot_thermo/blob/main/control/app.py"
click node_servo "https://github.com/nathan-samms/iot_thermo/blob/main/control/servotools.py"
click node_relay "https://github.com/nathan-samms/iot_thermo/blob/main/control/relaytools.py"
click node_settings "https://github.com/nathan-samms/iot_thermo/blob/main/settings.py"
click node_state "https://github.com/nathan-samms/iot_thermo/blob/main/control/state.py"
click node_statefile "https://github.com/nathan-samms/iot_thermo/blob/main/data/state.json"

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_browser,node_server toneBlue
class node_servo,node_relay toneAmber
class node_settings,node_state,node_statefile toneMint
class node_operator,node_gpio toneIndigo
```

## Components

### Web interface

- [Control UI](https://github.com/nathan-samms/iot_thermo/blob/main/static/main.js): `static/main.js`
- [Flask app](https://github.com/nathan-samms/iot_thermo/blob/main/control/app.py): `control/app.py`

### Hardware control

- [Servo controller](https://github.com/nathan-samms/iot_thermo/blob/main/control/servotools.py): `control/servotools.py`
- [Fan relay](https://github.com/nathan-samms/iot_thermo/blob/main/control/relaytools.py): `control/relaytools.py`

### Configuration and state

- [Hardware settings](https://github.com/nathan-samms/iot_thermo/blob/main/settings.py): `settings.py`
- [State manager](https://github.com/nathan-samms/iot_thermo/blob/main/control/state.py): `control/state.py`
- [JSON state file](https://github.com/nathan-samms/iot_thermo/blob/main/data/state.json): `data/state.json`

### Other components

- **Operator**
- **GPIO hardware**

## Connections

- Operator → Control UI: uses
- Control UI → Flask app: requests API
- Flask app → Hardware settings: imports auth setting (evidence: `control/app.py`)
- Servo controller → Hardware settings: imports pin limits (evidence: `control/servotools.py`)
- Fan relay → Hardware settings: imports relay pin (evidence: `control/relaytools.py`)
- State manager → Hardware settings: imports state path (evidence: `control/state.py`)
- Fan relay → State manager: updates fan state (evidence: `control/relaytools.py`)
- Servo controller → GPIO hardware: controls servo (evidence: `control/servotools.py`)
- Fan relay → GPIO hardware: switches relay (evidence: `control/relaytools.py`)
- State manager → JSON state file: loads and saves (evidence: `control/state.py`)
