# caffeineonice/restproject architecture

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

- Interactive diagram: https://gitdiagram.com/caffeineonice/restproject
- Repository: https://github.com/caffeineonice/restproject

## Overview

This repository contains alternative implementations of a gas and temperature/humidity monitoring system: polling with Supabase, tunneling with Zrok, and a local HTTP variant. The shared domain workflow is to request or schedule sensor readings, collect samples, and expose or store results. The excerpts substantiate the Poll and Tunnel worker/fetch/collection paths and the local HTTP routes; UI behavior and unsampled service wiring are not inferred.

Main entry points: [`Poll/script.py`](https://github.com/caffeineonice/restproject/blob/main/Poll/script.py) (Poll worker), [`Poll/esp/esp.ino`](https://github.com/caffeineonice/restproject/blob/main/Poll/esp/esp.ino) (ESP32 sensor), [`Misc_local HTTP/script.py`](https://github.com/caffeineonice/restproject/blob/main/Misc_local%20HTTP/script.py) (Local HTTP API), [`Tunnel/script.py`](https://github.com/caffeineonice/restproject/blob/main/Tunnel/script.py) (Tunnel API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_poll_ui["Polling UI<br/>[UI.py]"]
  node_tunnel_ui["Tunnel UI<br/>[UI.py]"]
  node_local_ui["Local UI<br/>[UI.py]"]
end

subgraph group_runtime["Runtime services"]
  node_poll_worker["Poll worker<br/>[script.py]"]
  node_tunnel_api["Tunnel API<br/>[script.py]"]
  node_local_api["Local HTTP API<br/>[script.py]"]
  node_poll_config["Poll configuration<br/>[config.py]"]
end

subgraph group_sensing["Sensor acquisition"]
  node_poll_th["Temperature fetch<br/>[fetch_temphum.py]"]
  node_poll_gas["Gas fetch<br/>[fetch_gas.py]"]
  node_poll_collect_th["Temperature collection<br/>[collect_temphum.py]"]
  node_poll_collect_gas["Gas collection<br/>[collect_gas.py]"]
  node_tunnel_th["Temperature fetch<br/>[fetch_temphum.py]"]
  node_tunnel_gas["Gas fetch<br/>[fetch_gas.py]"]
  node_tunnel_collect_th["Temperature collection<br/>[collect_temphum.py]"]
  node_tunnel_collect_gas["Gas collection<br/>[collect_gas.py]"]
  node_local_th["Temperature fetch<br/>[fetch_temphum.py]"]
  node_local_gas["Gas fetch<br/>[fetch_gas.py]"]
  node_local_collect_th["Temperature collection<br/>[collect_temphum.py]"]
  node_local_collect_gas["Gas collection<br/>[collect_gas.py]"]
end

subgraph group_data["Data and infrastructure"]
  node_esp32["ESP32 sensor<br/>[esp.ino]"]
  node_supabase[("Supabase")]
  node_csv[("Local CSV files")]
  node_zrok["Zrok tunnel"]
end

node_user(("User"))

node_user -->|"requests readings"| node_local_api
node_local_api -->|"calls handler"| node_local_th
node_local_api -->|"calls handler"| node_local_gas
node_local_api -->|"starts collection"| node_local_collect_th
node_local_api -->|"starts collection"| node_local_collect_gas
node_local_th -->|"requests reading"| node_esp32
node_local_gas -->|"requests reading"| node_esp32
node_local_th -->|"writes readings"| node_csv
node_local_gas -->|"writes readings"| node_csv
node_poll_worker -->|"calls handler"| node_poll_th
node_poll_worker -->|"calls handler"| node_poll_gas
node_poll_worker -->|"processes jobs"| node_poll_collect_th
node_poll_worker -->|"processes jobs"| node_poll_collect_gas
node_poll_collect_th -->|"calls handler"| node_poll_th
node_poll_collect_gas -->|"calls handler"| node_poll_gas
node_poll_th -->|"requests reading"| node_esp32
node_poll_gas -->|"requests reading"| node_esp32
node_poll_th -->|"inserts readings"| node_supabase
node_poll_gas -->|"inserts readings"| node_supabase
node_poll_worker -->|"polls and updates jobs"| node_supabase
node_tunnel_api -->|"calls handler"| node_tunnel_th
node_tunnel_api -->|"calls handler"| node_tunnel_gas
node_tunnel_api -->|"starts collection"| node_tunnel_collect_th
node_tunnel_api -->|"starts collection"| node_tunnel_collect_gas
node_tunnel_collect_th -->|"calls handler"| node_tunnel_th
node_tunnel_collect_gas -->|"calls handler"| node_tunnel_gas
node_tunnel_th -->|"requests reading"| node_esp32
node_tunnel_gas -->|"requests reading"| node_esp32
node_tunnel_th -->|"inserts readings"| node_supabase
node_tunnel_gas -->|"inserts readings"| node_supabase
node_poll_worker -->|"uses settings"| node_poll_config
node_poll_config -->|"configures client"| node_supabase
node_poll_ui -.->|"uses polling backend"| node_supabase
node_tunnel_ui -.->|"uses tunnel backend"| node_zrok
node_zrok -.->|"routes requests"| node_tunnel_api

click node_poll_ui "https://github.com/caffeineonice/restproject/blob/main/Poll/UI.py"
click node_tunnel_ui "https://github.com/caffeineonice/restproject/blob/main/Tunnel/UI.py"
click node_local_ui "https://github.com/caffeineonice/restproject/blob/main/Misc_local%20HTTP/UI.py"
click node_poll_worker "https://github.com/caffeineonice/restproject/blob/main/Poll/script.py"
click node_tunnel_api "https://github.com/caffeineonice/restproject/blob/main/Tunnel/script.py"
click node_local_api "https://github.com/caffeineonice/restproject/blob/main/Misc_local%20HTTP/script.py"
click node_poll_config "https://github.com/caffeineonice/restproject/blob/main/Poll/config.py"
click node_poll_th "https://github.com/caffeineonice/restproject/blob/main/Poll/fetch_temphum.py"
click node_poll_gas "https://github.com/caffeineonice/restproject/blob/main/Poll/fetch_gas.py"
click node_poll_collect_th "https://github.com/caffeineonice/restproject/blob/main/Poll/collect_temphum.py"
click node_poll_collect_gas "https://github.com/caffeineonice/restproject/blob/main/Poll/collect_gas.py"
click node_tunnel_th "https://github.com/caffeineonice/restproject/blob/main/Tunnel/fetch_temphum.py"
click node_tunnel_gas "https://github.com/caffeineonice/restproject/blob/main/Tunnel/fetch_gas.py"
click node_tunnel_collect_th "https://github.com/caffeineonice/restproject/blob/main/Tunnel/collect_temphum.py"
click node_tunnel_collect_gas "https://github.com/caffeineonice/restproject/blob/main/Tunnel/collect_gas.py"
click node_local_th "https://github.com/caffeineonice/restproject/blob/main/Misc_local%20HTTP/fetch_temphum.py"
click node_local_gas "https://github.com/caffeineonice/restproject/blob/main/Misc_local%20HTTP/fetch_gas.py"
click node_local_collect_th "https://github.com/caffeineonice/restproject/blob/main/Misc_local%20HTTP/collect_temphum.py"
click node_local_collect_gas "https://github.com/caffeineonice/restproject/blob/main/Misc_local%20HTTP/collect_gas.py"
click node_esp32 "https://github.com/caffeineonice/restproject/blob/main/Poll/esp/esp.ino"

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_poll_ui,node_tunnel_ui,node_local_ui,node_user toneBlue
class node_poll_worker,node_tunnel_api,node_local_api,node_poll_config toneAmber
class node_poll_th,node_poll_gas,node_poll_collect_th,node_poll_collect_gas,node_tunnel_th,node_tunnel_gas,node_tunnel_collect_th,node_tunnel_collect_gas,node_local_th,node_local_gas,node_local_collect_th,node_local_collect_gas toneMint
class node_esp32,node_supabase,node_csv,node_zrok toneRose
```

## Components

### User interfaces

- [Polling UI](https://github.com/caffeineonice/restproject/blob/main/Poll/UI.py): `Poll/UI.py`
- [Tunnel UI](https://github.com/caffeineonice/restproject/blob/main/Tunnel/UI.py): `Tunnel/UI.py`
- [Local UI](https://github.com/caffeineonice/restproject/blob/main/Misc_local%20HTTP/UI.py): `Misc_local HTTP/UI.py`

### Runtime services

- [Poll worker](https://github.com/caffeineonice/restproject/blob/main/Poll/script.py): `Poll/script.py`
- [Tunnel API](https://github.com/caffeineonice/restproject/blob/main/Tunnel/script.py): `Tunnel/script.py`
- [Local HTTP API](https://github.com/caffeineonice/restproject/blob/main/Misc_local%20HTTP/script.py): `Misc_local HTTP/script.py`
- [Poll configuration](https://github.com/caffeineonice/restproject/blob/main/Poll/config.py): `Poll/config.py`

### Sensor acquisition

- [Temperature fetch](https://github.com/caffeineonice/restproject/blob/main/Poll/fetch_temphum.py): `Poll/fetch_temphum.py`
- [Gas fetch](https://github.com/caffeineonice/restproject/blob/main/Poll/fetch_gas.py): `Poll/fetch_gas.py`
- [Temperature collection](https://github.com/caffeineonice/restproject/blob/main/Poll/collect_temphum.py): `Poll/collect_temphum.py`
- [Gas collection](https://github.com/caffeineonice/restproject/blob/main/Poll/collect_gas.py): `Poll/collect_gas.py`
- [Temperature fetch](https://github.com/caffeineonice/restproject/blob/main/Tunnel/fetch_temphum.py): `Tunnel/fetch_temphum.py`
- [Gas fetch](https://github.com/caffeineonice/restproject/blob/main/Tunnel/fetch_gas.py): `Tunnel/fetch_gas.py`
- [Temperature collection](https://github.com/caffeineonice/restproject/blob/main/Tunnel/collect_temphum.py): `Tunnel/collect_temphum.py`
- [Gas collection](https://github.com/caffeineonice/restproject/blob/main/Tunnel/collect_gas.py): `Tunnel/collect_gas.py`
- [Temperature fetch](https://github.com/caffeineonice/restproject/blob/main/Misc_local%20HTTP/fetch_temphum.py): `Misc_local HTTP/fetch_temphum.py`
- [Gas fetch](https://github.com/caffeineonice/restproject/blob/main/Misc_local%20HTTP/fetch_gas.py): `Misc_local HTTP/fetch_gas.py`
- [Temperature collection](https://github.com/caffeineonice/restproject/blob/main/Misc_local%20HTTP/collect_temphum.py): `Misc_local HTTP/collect_temphum.py`
- [Gas collection](https://github.com/caffeineonice/restproject/blob/main/Misc_local%20HTTP/collect_gas.py): `Misc_local HTTP/collect_gas.py`

### Data and infrastructure

- [ESP32 sensor](https://github.com/caffeineonice/restproject/blob/main/Poll/esp/esp.ino): `Poll/esp/esp.ino`
- **Supabase**
- **Local CSV files**
- **Zrok tunnel**

### Other components

- **User**

## Connections

- User → Local HTTP API: requests readings (evidence: `Misc_local HTTP/script.py`)
- Local HTTP API → Temperature fetch: calls handler (evidence: `Misc_local HTTP/script.py`)
- Local HTTP API → Gas fetch: calls handler (evidence: `Misc_local HTTP/script.py`)
- Local HTTP API → Temperature collection: starts collection (evidence: `Misc_local HTTP/script.py`)
- Local HTTP API → Gas collection: starts collection (evidence: `Misc_local HTTP/script.py`)
- Temperature fetch → ESP32 sensor: requests reading (evidence: `Misc_local HTTP/fetch_temphum.py`)
- Gas fetch → ESP32 sensor: requests reading (evidence: `Misc_local HTTP/fetch_gas.py`)
- Temperature fetch → Local CSV files: writes readings (evidence: `Misc_local HTTP/fetch_temphum.py`)
- Gas fetch → Local CSV files: writes readings (evidence: `Misc_local HTTP/fetch_gas.py`)
- Poll worker → Temperature fetch: calls handler (evidence: `Poll/script.py`)
- Poll worker → Gas fetch: calls handler (evidence: `Poll/script.py`)
- Poll worker → Temperature collection: processes jobs (evidence: `Poll/script.py`)
- Poll worker → Gas collection: processes jobs (evidence: `Poll/script.py`)
- Temperature collection → Temperature fetch: calls handler (evidence: `Poll/collect_temphum.py`)
- Gas collection → Gas fetch: calls handler (evidence: `Poll/collect_gas.py`)
- Temperature fetch → ESP32 sensor: requests reading (evidence: `Poll/fetch_temphum.py`)
- Gas fetch → ESP32 sensor: requests reading (evidence: `Poll/fetch_gas.py`)
- Temperature fetch → Supabase: inserts readings (evidence: `Poll/fetch_temphum.py`)
- Gas fetch → Supabase: inserts readings (evidence: `Poll/fetch_gas.py`)
- Poll worker → Supabase: polls and updates jobs (evidence: `Poll/script.py`)
- Tunnel API → Temperature fetch: calls handler (evidence: `Tunnel/script.py`)
- Tunnel API → Gas fetch: calls handler (evidence: `Tunnel/script.py`)
- Tunnel API → Temperature collection: starts collection (evidence: `Tunnel/script.py`)
- Tunnel API → Gas collection: starts collection (evidence: `Tunnel/script.py`)
- Temperature collection → Temperature fetch: calls handler
- Gas collection → Gas fetch: calls handler
- Temperature fetch → ESP32 sensor: requests reading (evidence: `Tunnel/fetch_temphum.py`)
- Gas fetch → ESP32 sensor: requests reading (evidence: `Tunnel/fetch_gas.py`)
- Temperature fetch → Supabase: inserts readings (evidence: `Tunnel/fetch_temphum.py`)
- Gas fetch → Supabase: inserts readings (evidence: `Tunnel/fetch_gas.py`)
- Poll worker → Poll configuration: uses settings (evidence: `Poll/script.py`)
- Poll configuration → Supabase: configures client (evidence: `Poll/config.py`)
- Polling UI → Supabase: uses polling backend
- Tunnel UI → Zrok tunnel: uses tunnel backend
- Zrok tunnel → Tunnel API: routes requests
