# dev-mk0/project architecture

> Architecture diagram of the GitHub repository dev-mk0/project, 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/dev-mk0/project
- Repository: https://github.com/dev-mk0/project

## Overview

This is a Raspberry Pi dew-point ventilation monitor with a browser dashboard. Its main workflow is to measure temperature and humidity, calculate dew-point values, control a fan relay, and present live readings; measurements can also be saved to SQLite and exported as CSV. The FastAPI application serves the dashboard and its API, while the JavaScript client requests status and settings and receives live WebSocket updates. The README documents both real and demo modes, plus scheduled operation. Some measurement and control implementation is omitted from the excerpts, so those hardware links are shown as unverified.

Main entry points: [`main.py`](https://github.com/dev-mk0/project/blob/main/main.py) (Real service), [`static/js/script.js`](https://github.com/dev-mk0/project/blob/main/static/js/script.js) (Dashboard client), [`main-demo.py`](https://github.com/dev-mk0/project/blob/main/main-demo.py) (Demo service), [`templates/index.html`](https://github.com/dev-mk0/project/blob/main/templates/index.html) (Dashboard template)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application runtime"]
  node_real_app["Real service<br/>[main.py]"]
  node_demo_app["Demo service<br/>[main-demo.py]"]
  node_schedule["Schedule rules<br/>[main.py]"]
  node_system_status["System status<br/>[main.py]"]
end

subgraph group_hardware["Sensing and control"]
  node_sensors["DHT sensors<br/>[main.py]"]
  node_dewpoint_control["Dew point control<br/>[main.py]"]
  node_fan_relay["Fan relay<br/>[main.py]"]
end

subgraph group_storage["Measurement data"]
  node_measurements_db[("Measurements DB<br/>[main.py]")]
  node_csv_export["CSV export<br/>[main.py]"]
end

subgraph group_dashboard["Web dashboard"]
  node_page_template["Dashboard template<br/>[index.html]"]
  node_client["Dashboard client<br/>[script.js]"]
  node_styles["Dashboard styles<br/>[styles.css]"]
end

node_operator(("Operator"))

node_real_app -->|"renders"| node_page_template
node_real_app -->|"reads and writes"| node_measurements_db
node_real_app -->|"exports"| node_csv_export
node_real_app -->|"checks schedule"| node_schedule
node_real_app -->|"provides status"| node_system_status
node_client -->|"requests API"| node_real_app
node_client -->|"opens WebSocket"| node_real_app
node_real_app -->|"sends live data"| node_client
node_client -.->|"uses styles"| node_styles
node_operator -->|"uses dashboard"| node_client
node_real_app -.->|"reads sensors"| node_sensors
node_sensors -.->|"provides readings"| node_dewpoint_control
node_dewpoint_control -.->|"controls fan"| node_fan_relay
node_operator -->|"starts demo mode"| node_demo_app

click node_real_app "https://github.com/dev-mk0/project/blob/main/main.py"
click node_demo_app "https://github.com/dev-mk0/project/blob/main/main-demo.py"
click node_schedule "https://github.com/dev-mk0/project/blob/main/main.py"
click node_system_status "https://github.com/dev-mk0/project/blob/main/main.py"
click node_sensors "https://github.com/dev-mk0/project/blob/main/main.py"
click node_dewpoint_control "https://github.com/dev-mk0/project/blob/main/main.py"
click node_fan_relay "https://github.com/dev-mk0/project/blob/main/main.py"
click node_measurements_db "https://github.com/dev-mk0/project/blob/main/main.py"
click node_csv_export "https://github.com/dev-mk0/project/blob/main/main.py"
click node_page_template "https://github.com/dev-mk0/project/blob/main/templates/index.html"
click node_client "https://github.com/dev-mk0/project/blob/main/static/js/script.js"
click node_styles "https://github.com/dev-mk0/project/blob/main/static/css/styles.css"

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_real_app,node_demo_app,node_schedule,node_system_status toneBlue
class node_sensors,node_dewpoint_control,node_fan_relay toneAmber
class node_measurements_db,node_csv_export toneMint
class node_page_template,node_client,node_styles toneRose
class node_operator toneIndigo
```

## Components

### Application runtime

- [Real service](https://github.com/dev-mk0/project/blob/main/main.py): `main.py`
- [Demo service](https://github.com/dev-mk0/project/blob/main/main-demo.py): `main-demo.py`
- [Schedule rules](https://github.com/dev-mk0/project/blob/main/main.py): `main.py`
- [System status](https://github.com/dev-mk0/project/blob/main/main.py): `main.py`

### Sensing and control

- [DHT sensors](https://github.com/dev-mk0/project/blob/main/main.py): `main.py`
- [Dew point control](https://github.com/dev-mk0/project/blob/main/main.py): `main.py`
- [Fan relay](https://github.com/dev-mk0/project/blob/main/main.py): `main.py`

### Measurement data

- [Measurements DB](https://github.com/dev-mk0/project/blob/main/main.py): `main.py`
- [CSV export](https://github.com/dev-mk0/project/blob/main/main.py): `main.py`

### Web dashboard

- [Dashboard template](https://github.com/dev-mk0/project/blob/main/templates/index.html): `templates/index.html`
- [Dashboard client](https://github.com/dev-mk0/project/blob/main/static/js/script.js): `static/js/script.js`
- [Dashboard styles](https://github.com/dev-mk0/project/blob/main/static/css/styles.css): `static/css/styles.css`

### Other components

- **Operator**

## Connections

- Real service → Dashboard template: renders (evidence: `main.py`)
- Real service → Measurements DB: reads and writes (evidence: `main.py`)
- Real service → CSV export: exports (evidence: `main.py`)
- Real service → Schedule rules: checks schedule (evidence: `main.py`)
- Real service → System status: provides status (evidence: `main.py`)
- Dashboard client → Real service: requests API (evidence: `static/js/script.js`)
- Dashboard client → Real service: opens WebSocket (evidence: `static/js/script.js`)
- Real service → Dashboard client: sends live data (evidence: `main.py`)
- Dashboard client → Dashboard styles: uses styles
- Operator → Dashboard client: uses dashboard (evidence: `README.md`)
- Real service → DHT sensors: reads sensors (evidence: `main.py`)
- DHT sensors → Dew point control: provides readings (evidence: `main.py`)
- Dew point control → Fan relay: controls fan (evidence: `main.py`)
- Operator → Demo service: starts demo mode (evidence: `README.md`)
