# f1uke/senior-project architecture

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

- Interactive diagram: https://gitdiagram.com/f1uke/senior-project
- Repository: https://github.com/f1uke/senior-project

## Overview

This is an IoT incubator monitor and controller: the ESP8266 samples temperature and humidity, applies automatic lamp/fan and egg-turning control, and reports readings for remote monitoring. The server exposes DHT write/read routes and persists records in MongoDB; the repository also includes a web dashboard and Blynk notifications/control. The README documents web-based real-time viewing, but the dashboard’s data-fetching code was not sampled, so its connection to the server is shown as unverified.

Main entry points: [`controller/171209-184003-nodemcuv2/src/main.cpp`](https://github.com/f1uke/senior-project/blob/master/controller/171209-184003-nodemcuv2/src/main.cpp) (ESP8266 Controller), [`server/app.js`](https://github.com/f1uke/senior-project/blob/master/server/app.js) (IoT HTTP Server), [`dashboard/html/dht.html`](https://github.com/f1uke/senior-project/blob/master/dashboard/html/dht.html) (Incubator Dashboard), [`controller/171209-184003-nodemcuv2/lib/myprotocol/myprotocol.cpp`](https://github.com/f1uke/senior-project/blob/master/controller/171209-184003-nodemcuv2/lib/myprotocol/myprotocol.cpp) (IoT Protocol Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_controller["Incubator Controller"]
  node_esp["ESP8266 Controller<br/>[main.cpp]"]
  node_actuators["Lamp, Fan, Servo"]
end

subgraph group_telemetry["Telemetry Service"]
  node_server["IoT HTTP Server<br/>[app.js]"]
  node_dht_routes["DHT Routes<br/>[app.js]"]
  node_dht_store[("DHT MongoDB Collection<br/>[app.js]")]
  node_generic_routes["Generic Data Routes<br/>[app.js]"]
  node_generic_store[("Generic MongoDB Collection<br/>[app.js]")]
end

subgraph group_dashboard["Web Dashboard"]
  node_web["Incubator Dashboard<br/>[dht.html]"]
end

subgraph group_support["Controller Libraries"]
  node_dht["DHT Sensor Driver<br/>[DHT.cpp]"]
  node_protocol["IoT Protocol Client<br/>[myprotocol.cpp]"]
  node_blink["LED Blink Library<br/>[mylibrary.cpp]"]
end

node_farmer(("Farmer"))
node_blynk["Blynk Service"]

node_esp -->|"reads sensor"| node_dht
node_esp -->|"sends readings"| node_protocol
node_protocol -->|"writes DHT"| node_server
node_server -->|"routes requests"| node_dht_routes
node_dht_routes -->|"reads and writes"| node_dht_store
node_server -->|"routes requests"| node_generic_routes
node_generic_routes -->|"reads and writes"| node_generic_store
node_esp -->|"controls outputs"| node_actuators
node_esp -->|"reports and notifies"| node_blynk
node_farmer -->|"views readings"| node_web
node_web -.->|"retrieves readings"| node_server

click node_esp "https://github.com/f1uke/senior-project/blob/master/controller/171209-184003-nodemcuv2/src/main.cpp"
click node_dht "https://github.com/f1uke/senior-project/blob/master/controller/171209-184003-nodemcuv2/lib/DHT/DHT.cpp"
click node_protocol "https://github.com/f1uke/senior-project/blob/master/controller/171209-184003-nodemcuv2/lib/myprotocol/myprotocol.cpp"
click node_blink "https://github.com/f1uke/senior-project/blob/master/controller/171209-184003-nodemcuv2/lib/myprotocol/mylibrary.cpp"
click node_server "https://github.com/f1uke/senior-project/blob/master/server/app.js"
click node_dht_routes "https://github.com/f1uke/senior-project/blob/master/server/app.js"
click node_dht_store "https://github.com/f1uke/senior-project/blob/master/server/app.js"
click node_generic_routes "https://github.com/f1uke/senior-project/blob/master/server/app.js"
click node_generic_store "https://github.com/f1uke/senior-project/blob/master/server/app.js"
click node_web "https://github.com/f1uke/senior-project/blob/master/dashboard/html/dht.html"

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_esp,node_actuators toneBlue
class node_server,node_dht_routes,node_dht_store,node_generic_routes,node_generic_store toneAmber
class node_web toneMint
class node_dht,node_protocol,node_blink toneRose
class node_farmer,node_blynk toneIndigo
```

## Components

### Incubator Controller

- [ESP8266 Controller](https://github.com/f1uke/senior-project/blob/master/controller/171209-184003-nodemcuv2/src/main.cpp): `controller/171209-184003-nodemcuv2/src/main.cpp`
- **Lamp, Fan, Servo**

### Telemetry Service

- [IoT HTTP Server](https://github.com/f1uke/senior-project/blob/master/server/app.js): `server/app.js`
- [DHT Routes](https://github.com/f1uke/senior-project/blob/master/server/app.js): `server/app.js`
- [DHT MongoDB Collection](https://github.com/f1uke/senior-project/blob/master/server/app.js): `server/app.js`
- [Generic Data Routes](https://github.com/f1uke/senior-project/blob/master/server/app.js): `server/app.js`
- [Generic MongoDB Collection](https://github.com/f1uke/senior-project/blob/master/server/app.js): `server/app.js`

### Web Dashboard

- [Incubator Dashboard](https://github.com/f1uke/senior-project/blob/master/dashboard/html/dht.html): `dashboard/html/dht.html`

### Controller Libraries

- [DHT Sensor Driver](https://github.com/f1uke/senior-project/blob/master/controller/171209-184003-nodemcuv2/lib/DHT/DHT.cpp): `controller/171209-184003-nodemcuv2/lib/DHT/DHT.cpp`
- [IoT Protocol Client](https://github.com/f1uke/senior-project/blob/master/controller/171209-184003-nodemcuv2/lib/myprotocol/myprotocol.cpp): `controller/171209-184003-nodemcuv2/lib/myprotocol/myprotocol.cpp`
- [LED Blink Library](https://github.com/f1uke/senior-project/blob/master/controller/171209-184003-nodemcuv2/lib/myprotocol/mylibrary.cpp): `controller/171209-184003-nodemcuv2/lib/myprotocol/mylibrary.cpp`

### Other components

- **Farmer**
- **Blynk Service**

## Connections

- ESP8266 Controller → DHT Sensor Driver: reads sensor (evidence: `controller/171209-184003-nodemcuv2/src/main.cpp`)
- ESP8266 Controller → IoT Protocol Client: sends readings (evidence: `controller/171209-184003-nodemcuv2/src/main.cpp`)
- IoT Protocol Client → IoT HTTP Server: writes DHT (evidence: `controller/171209-184003-nodemcuv2/lib/myprotocol/myprotocol.cpp`)
- IoT HTTP Server → DHT Routes: routes requests (evidence: `server/app.js`)
- DHT Routes → DHT MongoDB Collection: reads and writes (evidence: `server/app.js`)
- IoT HTTP Server → Generic Data Routes: routes requests (evidence: `server/app.js`)
- Generic Data Routes → Generic MongoDB Collection: reads and writes (evidence: `server/app.js`)
- ESP8266 Controller → Lamp, Fan, Servo: controls outputs (evidence: `controller/171209-184003-nodemcuv2/src/main.cpp`)
- ESP8266 Controller → Blynk Service: reports and notifies (evidence: `controller/171209-184003-nodemcuv2/src/main.cpp`)
- Farmer → Incubator Dashboard: views readings (evidence: `README.md`)
- Incubator Dashboard → IoT HTTP Server: retrieves readings
