# luqman234/floracore architecture

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

## Overview

FloraCore is an ESP32 plant-care device paired with the FloraOS Flask control plane and dashboard. The main workflow runs from local sensing and safety-controlled actuation, through device enrollment and authenticated messaging, to backend telemetry, automation/commands, and user-facing monitoring. The README documents additional product capabilities that are present in the tree but whose implementation was not sampled; those links are shown as documented rather than inferred source calls.

Main entry points: [`firmware/main/main.c`](https://github.com/luqman234/floracore/blob/main/firmware/main/main.c) (Device runtime), [`web/app.py`](https://github.com/luqman234/floracore/blob/main/web/app.py) (Web application), [`web/floraos_commands.py`](https://github.com/luqman234/floracore/blob/main/web/floraos_commands.py) (Command queue), [`web/floraos_device_api.py`](https://github.com/luqman234/floracore/blob/main/web/floraos_device_api.py) (Device API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_device["Device runtime"]
  node_firmware_main["Device runtime<br/>[main.c]"]
  node_wifi["Wi-Fi manager<br/>[wifi_manager.c]"]
  node_setup["Setup portal<br/>[setup_portal.c]"]
  node_ble["BLE terminal<br/>[ble_terminal.c]"]
  node_phase20_fw["Local controls<br/>[floraos_phase20.c]"]
  node_ota_fw["Firmware OTA<br/>[ota_manager.c]"]
end

subgraph group_transport["Secure device channel"]
  node_crypto["Device cryptography<br/>[floraos_crypto.c]"]
  node_client["Device messaging<br/>[floraos_client.c]"]
  node_claim_fw["Claim protocol<br/>[floraos_claim.c]"]
end

subgraph group_backend["FloraOS backend"]
  node_web_app["Web application<br/>[app.py]"]
  node_enrollment["Device enrollment"]
  node_device_api["Device API"]
  node_commands["Command queue"]
  node_database[("Platform database")]
end

subgraph group_capabilities["Plant care services"]
  node_automation["Automation Studio"]
  node_automation_v2["Automation v2"]
  node_plants["Plant profiles<br/>[floraos_plants.py]"]
  node_insights["Care insights"]
  node_notifications["Notifications"]
  node_ota_web["OTA service<br/>[floraos_ota.py]"]
  node_public_api["Developer API"]
end

subgraph group_user["User interfaces"]
  node_security["Account security"]
  node_mfa["MFA<br/>[floraos_mfa.py]"]
  node_dashboard["FloraOS dashboard<br/>[dashboard.js]"]
  node_automations_ui["Automation interface<br/>[automations.js]"]
  node_plant_ui["Plant interface<br/>[plants.js]"]
end

node_owner(("Device owner"))
node_hardware["Plant hardware"]
node_smtp["SMTP service"]

node_owner -.->|"configures device"| node_setup
node_hardware -->|"senses and actuates"| node_firmware_main
node_firmware_main -->|"manages connectivity"| node_wifi
node_firmware_main -->|"starts setup"| node_setup
node_firmware_main -->|"runs controls"| node_phase20_fw
node_firmware_main -->|"initializes channel"| node_client
node_firmware_main -->|"checks OTA state"| node_ota_fw
node_ble -.->|"supports setup"| node_owner
node_client -->|"uses encryption"| node_crypto
node_client -->|"sends authenticated messages"| node_web_app
node_claim_fw -.->|"uses device channel"| node_client
node_web_app -->|"registers enrollment"| node_enrollment
node_web_app -->|"registers device API"| node_device_api
node_device_api -->|"checks ownership"| node_enrollment
node_device_api -->|"dispatches messages"| node_commands
node_device_api -->|"uses OTA service"| node_ota_web
node_enrollment -->|"stores ownership"| node_database
node_commands -->|"stores commands"| node_database
node_automation -->|"reads telemetry"| node_database
node_automation -.->|"queues actions"| node_commands
node_automation_v2 -.->|"supports automation actions"| node_commands
node_plants -.->|"stores plant profiles"| node_database
node_insights -.->|"uses care data"| node_database
node_notifications -.->|"stores notifications"| node_database
node_ota_web -.->|"tracks OTA state"| node_database
node_ota_web -.->|"provides firmware updates"| node_ota_fw
node_public_api -->|"exposes bounded commands"| node_commands
node_public_api -->|"exposes OTA services"| node_ota_web
node_web_app -->|"registers security"| node_security
node_web_app -->|"registers MFA"| node_mfa
node_security -->|"sends security email"| node_smtp
node_mfa -->|"uses account security"| node_security
node_owner -.->|"monitors devices"| node_dashboard
node_dashboard -.->|"uses dashboard services"| node_web_app
node_automations_ui -.->|"manages automations"| node_automation
node_plant_ui -.->|"manages plant profiles"| node_plants

click node_firmware_main "https://github.com/luqman234/floracore/blob/main/firmware/main/main.c"
click node_wifi "https://github.com/luqman234/floracore/blob/main/firmware/main/wifi_manager.c"
click node_setup "https://github.com/luqman234/floracore/blob/main/firmware/main/setup_portal.c"
click node_ble "https://github.com/luqman234/floracore/blob/main/firmware/main/ble_terminal.c"
click node_phase20_fw "https://github.com/luqman234/floracore/blob/main/firmware/main/floraos_phase20.c"
click node_crypto "https://github.com/luqman234/floracore/blob/main/firmware/main/floraos_crypto.c"
click node_client "https://github.com/luqman234/floracore/blob/main/firmware/main/floraos_client.c"
click node_claim_fw "https://github.com/luqman234/floracore/blob/main/firmware/main/floraos_claim.c"
click node_ota_fw "https://github.com/luqman234/floracore/blob/main/firmware/main/ota_manager.c"
click node_web_app "https://github.com/luqman234/floracore/blob/main/web/app.py"
click node_enrollment "https://github.com/luqman234/floracore/blob/main/web/device_enrollment.py"
click node_device_api "https://github.com/luqman234/floracore/blob/main/web/floraos_device_api.py"
click node_commands "https://github.com/luqman234/floracore/blob/main/web/floraos_commands.py"
click node_automation "https://github.com/luqman234/floracore/blob/main/web/floraos_automations.py"
click node_automation_v2 "https://github.com/luqman234/floracore/blob/main/web/floraos_automation_v2.py"
click node_plants "https://github.com/luqman234/floracore/blob/main/web/floraos_plants.py"
click node_insights "https://github.com/luqman234/floracore/blob/main/web/floraos_insights.py"
click node_notifications "https://github.com/luqman234/floracore/blob/main/web/floraos_notifications.py"
click node_ota_web "https://github.com/luqman234/floracore/blob/main/web/floraos_ota.py"
click node_public_api "https://github.com/luqman234/floracore/blob/main/web/floraos_public_api.py"
click node_security "https://github.com/luqman234/floracore/blob/main/web/floraos_account_security.py"
click node_mfa "https://github.com/luqman234/floracore/blob/main/web/floraos_mfa.py"
click node_dashboard "https://github.com/luqman234/floracore/blob/main/web/static/js/dashboard.js"
click node_automations_ui "https://github.com/luqman234/floracore/blob/main/web/static/js/automations.js"
click node_plant_ui "https://github.com/luqman234/floracore/blob/main/web/static/js/plants.js"

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_firmware_main,node_wifi,node_setup,node_ble,node_phase20_fw,node_ota_fw toneBlue
class node_crypto,node_client,node_claim_fw toneAmber
class node_web_app,node_enrollment,node_device_api,node_commands,node_database toneMint
class node_automation,node_automation_v2,node_plants,node_insights,node_notifications,node_ota_web,node_public_api toneRose
class node_security,node_mfa,node_dashboard,node_automations_ui,node_plant_ui,node_owner,node_hardware,node_smtp toneIndigo
```

## Components

### Device runtime

- [Device runtime](https://github.com/luqman234/floracore/blob/main/firmware/main/main.c): `firmware/main/main.c`
- [Wi-Fi manager](https://github.com/luqman234/floracore/blob/main/firmware/main/wifi_manager.c): `firmware/main/wifi_manager.c`
- [Setup portal](https://github.com/luqman234/floracore/blob/main/firmware/main/setup_portal.c): `firmware/main/setup_portal.c`
- [BLE terminal](https://github.com/luqman234/floracore/blob/main/firmware/main/ble_terminal.c): `firmware/main/ble_terminal.c`
- [Local controls](https://github.com/luqman234/floracore/blob/main/firmware/main/floraos_phase20.c): `firmware/main/floraos_phase20.c`
- [Firmware OTA](https://github.com/luqman234/floracore/blob/main/firmware/main/ota_manager.c): `firmware/main/ota_manager.c`

### Secure device channel

- [Device cryptography](https://github.com/luqman234/floracore/blob/main/firmware/main/floraos_crypto.c): `firmware/main/floraos_crypto.c`
- [Device messaging](https://github.com/luqman234/floracore/blob/main/firmware/main/floraos_client.c): `firmware/main/floraos_client.c`
- [Claim protocol](https://github.com/luqman234/floracore/blob/main/firmware/main/floraos_claim.c): `firmware/main/floraos_claim.c`

### FloraOS backend

- [Web application](https://github.com/luqman234/floracore/blob/main/web/app.py): `web/app.py`
- [Device enrollment](https://github.com/luqman234/floracore/blob/main/web/device_enrollment.py): `web/device_enrollment.py`
- [Device API](https://github.com/luqman234/floracore/blob/main/web/floraos_device_api.py): `web/floraos_device_api.py`
- [Command queue](https://github.com/luqman234/floracore/blob/main/web/floraos_commands.py): `web/floraos_commands.py`
- **Platform database**

### Plant care services

- [Automation Studio](https://github.com/luqman234/floracore/blob/main/web/floraos_automations.py): `web/floraos_automations.py`
- [Automation v2](https://github.com/luqman234/floracore/blob/main/web/floraos_automation_v2.py): `web/floraos_automation_v2.py`
- [Plant profiles](https://github.com/luqman234/floracore/blob/main/web/floraos_plants.py): `web/floraos_plants.py`
- [Care insights](https://github.com/luqman234/floracore/blob/main/web/floraos_insights.py): `web/floraos_insights.py`
- [Notifications](https://github.com/luqman234/floracore/blob/main/web/floraos_notifications.py): `web/floraos_notifications.py`
- [OTA service](https://github.com/luqman234/floracore/blob/main/web/floraos_ota.py): `web/floraos_ota.py`
- [Developer API](https://github.com/luqman234/floracore/blob/main/web/floraos_public_api.py): `web/floraos_public_api.py`

### User interfaces

- [Account security](https://github.com/luqman234/floracore/blob/main/web/floraos_account_security.py): `web/floraos_account_security.py`
- [MFA](https://github.com/luqman234/floracore/blob/main/web/floraos_mfa.py): `web/floraos_mfa.py`
- [FloraOS dashboard](https://github.com/luqman234/floracore/blob/main/web/static/js/dashboard.js): `web/static/js/dashboard.js`
- [Automation interface](https://github.com/luqman234/floracore/blob/main/web/static/js/automations.js): `web/static/js/automations.js`
- [Plant interface](https://github.com/luqman234/floracore/blob/main/web/static/js/plants.js): `web/static/js/plants.js`

### Other components

- **Device owner**
- **Plant hardware**
- **SMTP service**

## Connections

- Device owner → Setup portal: configures device
- Plant hardware → Device runtime: senses and actuates
- Device runtime → Wi-Fi manager: manages connectivity (evidence: `firmware/main/main.c`)
- Device runtime → Setup portal: starts setup (evidence: `firmware/main/main.c`)
- Device runtime → Local controls: runs controls (evidence: `firmware/main/main.c`)
- Device runtime → Device messaging: initializes channel (evidence: `firmware/main/main.c`)
- Device runtime → Firmware OTA: checks OTA state (evidence: `firmware/main/main.c`)
- BLE terminal → Device owner: supports setup
- Device messaging → Device cryptography: uses encryption (evidence: `firmware/main/floraos_client.c`)
- Device messaging → Web application: sends authenticated messages
- Claim protocol → Device messaging: uses device channel
- Web application → Device enrollment: registers enrollment (evidence: `web/app.py`)
- Web application → Device API: registers device API (evidence: `web/app.py`)
- Device API → Device enrollment: checks ownership (evidence: `web/floraos_device_api.py`)
- Device API → Command queue: dispatches messages (evidence: `web/floraos_device_api.py`)
- Device API → OTA service: uses OTA service (evidence: `web/floraos_device_api.py`)
- Device enrollment → Platform database: stores ownership (evidence: `web/device_enrollment.py`)
- Command queue → Platform database: stores commands (evidence: `web/floraos_commands.py`)
- Automation Studio → Platform database: reads telemetry (evidence: `web/floraos_automations.py`)
- Automation Studio → Command queue: queues actions (evidence: `web/floraos_automations.py`)
- Automation v2 → Command queue: supports automation actions
- Plant profiles → Platform database: stores plant profiles
- Care insights → Platform database: uses care data
- Notifications → Platform database: stores notifications
- OTA service → Platform database: tracks OTA state
- OTA service → Firmware OTA: provides firmware updates
- Developer API → Command queue: exposes bounded commands (evidence: `web/floraos_public_api.py`)
- Developer API → OTA service: exposes OTA services (evidence: `web/floraos_public_api.py`)
- Web application → Account security: registers security (evidence: `web/app.py`)
- Web application → MFA: registers MFA (evidence: `web/app.py`)
- Account security → SMTP service: sends security email (evidence: `web/floraos_account_security.py`)
- MFA → Account security: uses account security (evidence: `web/floraos_mfa.py`)
- Device owner → FloraOS dashboard: monitors devices
- FloraOS dashboard → Web application: uses dashboard services
- Automation interface → Automation Studio: manages automations
- Plant interface → Plant profiles: manages plant profiles
