# chriswycoff/smart_greenhouse architecture

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

- Interactive diagram: https://gitdiagram.com/chriswycoff/smart_greenhouse
- Repository: https://github.com/chriswycoff/smart_greenhouse
- Video tour (about a minute): https://gitdiagram.com/chriswycoff/smart_greenhouse/video

## Overview

smart_greenhouse links a greenhouse’s ESP8266 to a PHP website and SQL-backed device state. A user views the greenhouse interface, which reads device state and submits fan, heater, water, or door changes to the update handler. The ESP8266 exchanges data with the device endpoint: it reports temperature and humidity, and receives actuator states. The endpoint also maintains the fan timer and device state in the database. The README documents the two-way device connection, but firmware details were not sampled, so its internal behavior is not expanded here.

Main entry points: [`device_interact.php`](https://github.com/chriswycoff/smart_greenhouse/blob/master/device_interact.php) (Device endpoint), [`greenhouse_interface.php`](https://github.com/chriswycoff/smart_greenhouse/blob/master/greenhouse_interface.php) (Control interface), [`for_esp8266/for_esp8266.ino`](https://github.com/chriswycoff/smart_greenhouse/blob/master/for_esp8266/for_esp8266.ino) (ESP8266 firmware), [`change_data.php`](https://github.com/chriswycoff/smart_greenhouse/blob/master/change_data.php) (State updater)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_interface["Control interface"]
end

subgraph group_server["Server logic"]
  node_change["State updater<br/>[change_data.php]"]
  node_interact["Device endpoint"]
  node_database[("Device database")]
end

subgraph group_device["Greenhouse device"]
  node_firmware["ESP8266 firmware<br/>[for_esp8266.ino]"]
end

node_user(("Greenhouse user"))
node_greenhouse["Greenhouse hardware"]

node_user -->|"views controls"| node_interface
node_interface -->|"reads state"| node_database
node_interface -->|"submits changes"| node_change
node_change -->|"updates state"| node_database
node_firmware -->|"reports readings"| node_interact
node_interact -->|"updates readings"| node_database
node_interact -->|"reads actuator state"| node_database
node_interact -->|"updates fan timer"| node_database
node_interact -->|"returns actuator states"| node_firmware
node_firmware -->|"communicates with"| node_greenhouse

click node_interface "https://github.com/chriswycoff/smart_greenhouse/blob/master/greenhouse_interface.php"
click node_change "https://github.com/chriswycoff/smart_greenhouse/blob/master/change_data.php"
click node_interact "https://github.com/chriswycoff/smart_greenhouse/blob/master/device_interact.php"
click node_firmware "https://github.com/chriswycoff/smart_greenhouse/blob/master/for_esp8266/for_esp8266.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_interface,node_user toneBlue
class node_change,node_interact,node_database toneAmber
class node_firmware toneMint
class node_greenhouse toneIndigo
```

## Components

### Web interface

- [Control interface](https://github.com/chriswycoff/smart_greenhouse/blob/master/greenhouse_interface.php): `greenhouse_interface.php`

### Server logic

- [State updater](https://github.com/chriswycoff/smart_greenhouse/blob/master/change_data.php): `change_data.php`
- [Device endpoint](https://github.com/chriswycoff/smart_greenhouse/blob/master/device_interact.php): `device_interact.php`
- **Device database**

### Greenhouse device

- [ESP8266 firmware](https://github.com/chriswycoff/smart_greenhouse/blob/master/for_esp8266/for_esp8266.ino): `for_esp8266/for_esp8266.ino`

### Other components

- **Greenhouse user**
- **Greenhouse hardware**

## Connections

- Greenhouse user → Control interface: views controls
- Control interface → Device database: reads state
- Control interface → State updater: submits changes
- State updater → Device database: updates state
- ESP8266 firmware → Device endpoint: reports readings
- Device endpoint → Device database: updates readings
- Device endpoint → Device database: reads actuator state
- Device endpoint → Device database: updates fan timer
- Device endpoint → ESP8266 firmware: returns actuator states
- ESP8266 firmware → Greenhouse hardware: communicates with
