# amemiyakana890/plant-monitoring architecture

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

## Overview

Plant Environment Monitoring is an IoT plant-care system: an ESP32 sensor sends environmental readings to an authenticated API, which stores logs, evaluates plant conditions, and may issue alerts; the Flutter app presents plant status, history, notifications, and settings. The graph includes the documented pairing, species, watering, and push-notification capabilities. App and several server routes/controllers were not sampled, so uncertain internal dispatch links are omitted.

Main entry points: [`server/app.js`](https://github.com/amemiyakana890/plant-monitoring/blob/main/server/app.js) (Express API), [`app/lib/repositories/http_plant_repository.dart`](https://github.com/amemiyakana890/plant-monitoring/blob/main/app/lib/repositories/http_plant_repository.dart) (HTTP repository), [`server/database/db.js`](https://github.com/amemiyakana890/plant-monitoring/blob/main/server/database/db.js) (SQLite state), [`server/controllers/sensorController.js`](https://github.com/amemiyakana890/plant-monitoring/blob/main/server/controllers/sensorController.js) (Sensor evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_device["Sensing device"]
  node_sensors["Environment sensors"]
  node_firmware["ESP32 firmware"]
end

subgraph group_backend["API and evaluation"]
  node_server["Express API<br/>[app.js]"]
  node_sensor_api["Sensor endpoint<br/>[sensor.js]"]
  node_sensor_eval["Sensor evaluation"]
  node_plant_api["Plant management"]
  node_device_api["Device pairing"]
  node_history_api["History queries"]
  node_settings_api["Alert settings"]
  node_status_rules["Status rules<br/>[plantStatus.js]"]
  node_species["Species catalog<br/>[speciesCatalog.js]"]
end

subgraph group_state["Persistent state"]
  node_database[("SQLite state<br/>[db.js]")]
end

subgraph group_mobile["Mobile app"]
  node_mobile["Flutter app<br/>[main.dart]"]
  node_auth_ui["Login flow"]
  node_auth_state["Auth state<br/>[auth_store.dart]"]
  node_plant_state["Plant state<br/>[plant_store.dart]"]
  node_plant_repo["HTTP repository"]
  node_plant_screens["Plant screens"]
  node_history_screen["History screen<br/>[history_page.dart]"]
  node_notification_screen["Notification screen"]
  node_settings_screen["Settings screens"]
  node_push_service["Push service"]
end

subgraph group_integrations["External services"]
  node_firebase_auth["Firebase Auth"]
  node_fcm["Firebase messaging"]
end

node_grower(("Plant grower"))

node_grower -->|"uses"| node_mobile
node_sensors -->|"provides readings"| node_firmware
node_firmware -->|"sends HTTP"| node_sensor_api
node_server -->|"mounts route"| node_sensor_api
node_server -->|"mounts API"| node_plant_api
node_server -->|"mounts API"| node_device_api
node_server -->|"mounts API"| node_history_api
node_server -->|"mounts API"| node_settings_api
node_sensor_api -->|"handles readings"| node_sensor_eval
node_sensor_eval -->|"evaluates status"| node_status_rules
node_sensor_eval -->|"stores logs and alerts"| node_database
node_sensor_eval -.->|"sends push"| node_fcm
node_plant_api -->|"loads care profile"| node_species
node_plant_api -->|"reads and writes plants"| node_database
node_device_api -->|"manages pairing"| node_database
node_history_api -->|"reads sensor logs"| node_database
node_settings_api -->|"stores preferences"| node_database
node_mobile -->|"shows login"| node_auth_ui
node_auth_ui -->|"uses auth state"| node_auth_state
node_auth_state -->|"authenticates"| node_firebase_auth
node_mobile -->|"provides app state"| node_plant_state
node_plant_state -->|"loads plant data"| node_plant_repo
node_plant_repo -->|"calls API"| node_server
node_plant_screens -->|"reads plant state"| node_plant_state
node_history_screen -->|"requests history"| node_plant_repo
node_notification_screen -->|"loads alerts"| node_plant_repo
node_settings_screen -->|"updates settings"| node_plant_repo
node_push_service -->|"registers token"| node_fcm

click node_sensors "https://github.com/amemiyakana890/plant-monitoring/blob/main/esp32/plant_sensor_integrated/plant_sensor_integrated.ino"
click node_firmware "https://github.com/amemiyakana890/plant-monitoring/blob/main/esp32/plant_sensor_integrated/plant_sensor_integrated.ino"
click node_server "https://github.com/amemiyakana890/plant-monitoring/blob/main/server/app.js"
click node_sensor_api "https://github.com/amemiyakana890/plant-monitoring/blob/main/server/routes/sensor.js"
click node_sensor_eval "https://github.com/amemiyakana890/plant-monitoring/blob/main/server/controllers/sensorController.js"
click node_plant_api "https://github.com/amemiyakana890/plant-monitoring/blob/main/server/controllers/plantsController.js"
click node_device_api "https://github.com/amemiyakana890/plant-monitoring/blob/main/server/controllers/devicesController.js"
click node_history_api "https://github.com/amemiyakana890/plant-monitoring/blob/main/server/controllers/historyController.js"
click node_settings_api "https://github.com/amemiyakana890/plant-monitoring/blob/main/server/controllers/settingsController.js"
click node_status_rules "https://github.com/amemiyakana890/plant-monitoring/blob/main/server/utils/plantStatus.js"
click node_species "https://github.com/amemiyakana890/plant-monitoring/blob/main/server/utils/speciesCatalog.js"
click node_database "https://github.com/amemiyakana890/plant-monitoring/blob/main/server/database/db.js"
click node_mobile "https://github.com/amemiyakana890/plant-monitoring/blob/main/app/lib/main.dart"
click node_auth_ui "https://github.com/amemiyakana890/plant-monitoring/tree/main/app/lib/screens/auth"
click node_auth_state "https://github.com/amemiyakana890/plant-monitoring/blob/main/app/lib/state/auth_store.dart"
click node_plant_state "https://github.com/amemiyakana890/plant-monitoring/blob/main/app/lib/state/plant_store.dart"
click node_plant_repo "https://github.com/amemiyakana890/plant-monitoring/blob/main/app/lib/repositories/http_plant_repository.dart"
click node_plant_screens "https://github.com/amemiyakana890/plant-monitoring/tree/main/app/lib/screens"
click node_history_screen "https://github.com/amemiyakana890/plant-monitoring/blob/main/app/lib/screens/history/history_page.dart"
click node_notification_screen "https://github.com/amemiyakana890/plant-monitoring/blob/main/app/lib/screens/notification/notification_page.dart"
click node_settings_screen "https://github.com/amemiyakana890/plant-monitoring/tree/main/app/lib/screens/settings"
click node_push_service "https://github.com/amemiyakana890/plant-monitoring/blob/main/app/lib/services/push_notification_service.dart"

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_sensors,node_firmware toneBlue
class node_server,node_sensor_api,node_sensor_eval,node_plant_api,node_device_api,node_history_api,node_settings_api,node_status_rules,node_species toneAmber
class node_database toneMint
class node_mobile,node_auth_ui,node_auth_state,node_plant_state,node_plant_repo,node_plant_screens,node_history_screen,node_notification_screen,node_settings_screen,node_push_service toneRose
class node_firebase_auth,node_fcm,node_grower toneIndigo
```

## Components

### Sensing device

- [Environment sensors](https://github.com/amemiyakana890/plant-monitoring/blob/main/esp32/plant_sensor_integrated/plant_sensor_integrated.ino): `esp32/plant_sensor_integrated/plant_sensor_integrated.ino`
- [ESP32 firmware](https://github.com/amemiyakana890/plant-monitoring/blob/main/esp32/plant_sensor_integrated/plant_sensor_integrated.ino): `esp32/plant_sensor_integrated/plant_sensor_integrated.ino`

### API and evaluation

- [Express API](https://github.com/amemiyakana890/plant-monitoring/blob/main/server/app.js): `server/app.js`
- [Sensor endpoint](https://github.com/amemiyakana890/plant-monitoring/blob/main/server/routes/sensor.js): `server/routes/sensor.js`
- [Sensor evaluation](https://github.com/amemiyakana890/plant-monitoring/blob/main/server/controllers/sensorController.js): `server/controllers/sensorController.js`
- [Plant management](https://github.com/amemiyakana890/plant-monitoring/blob/main/server/controllers/plantsController.js): `server/controllers/plantsController.js`
- [Device pairing](https://github.com/amemiyakana890/plant-monitoring/blob/main/server/controllers/devicesController.js): `server/controllers/devicesController.js`
- [History queries](https://github.com/amemiyakana890/plant-monitoring/blob/main/server/controllers/historyController.js): `server/controllers/historyController.js`
- [Alert settings](https://github.com/amemiyakana890/plant-monitoring/blob/main/server/controllers/settingsController.js): `server/controllers/settingsController.js`
- [Status rules](https://github.com/amemiyakana890/plant-monitoring/blob/main/server/utils/plantStatus.js): `server/utils/plantStatus.js`
- [Species catalog](https://github.com/amemiyakana890/plant-monitoring/blob/main/server/utils/speciesCatalog.js): `server/utils/speciesCatalog.js`

### Persistent state

- [SQLite state](https://github.com/amemiyakana890/plant-monitoring/blob/main/server/database/db.js): `server/database/db.js`

### Mobile app

- [Flutter app](https://github.com/amemiyakana890/plant-monitoring/blob/main/app/lib/main.dart): `app/lib/main.dart`
- [Login flow](https://github.com/amemiyakana890/plant-monitoring/tree/main/app/lib/screens/auth): `app/lib/screens/auth`
- [Auth state](https://github.com/amemiyakana890/plant-monitoring/blob/main/app/lib/state/auth_store.dart): `app/lib/state/auth_store.dart`
- [Plant state](https://github.com/amemiyakana890/plant-monitoring/blob/main/app/lib/state/plant_store.dart): `app/lib/state/plant_store.dart`
- [HTTP repository](https://github.com/amemiyakana890/plant-monitoring/blob/main/app/lib/repositories/http_plant_repository.dart): `app/lib/repositories/http_plant_repository.dart`
- [Plant screens](https://github.com/amemiyakana890/plant-monitoring/tree/main/app/lib/screens): `app/lib/screens`
- [History screen](https://github.com/amemiyakana890/plant-monitoring/blob/main/app/lib/screens/history/history_page.dart): `app/lib/screens/history/history_page.dart`
- [Notification screen](https://github.com/amemiyakana890/plant-monitoring/blob/main/app/lib/screens/notification/notification_page.dart): `app/lib/screens/notification/notification_page.dart`
- [Settings screens](https://github.com/amemiyakana890/plant-monitoring/tree/main/app/lib/screens/settings): `app/lib/screens/settings`
- [Push service](https://github.com/amemiyakana890/plant-monitoring/blob/main/app/lib/services/push_notification_service.dart): `app/lib/services/push_notification_service.dart`

### External services

- **Firebase Auth**
- **Firebase messaging**

### Other components

- **Plant grower**

## Connections

- Plant grower → Flutter app: uses
- Environment sensors → ESP32 firmware: provides readings
- ESP32 firmware → Sensor endpoint: sends HTTP
- Express API → Sensor endpoint: mounts route
- Express API → Plant management: mounts API
- Express API → Device pairing: mounts API
- Express API → History queries: mounts API
- Express API → Alert settings: mounts API
- Sensor endpoint → Sensor evaluation: handles readings
- Sensor evaluation → Status rules: evaluates status
- Sensor evaluation → SQLite state: stores logs and alerts
- Sensor evaluation → Firebase messaging: sends push
- Plant management → Species catalog: loads care profile
- Plant management → SQLite state: reads and writes plants
- Device pairing → SQLite state: manages pairing
- History queries → SQLite state: reads sensor logs
- Alert settings → SQLite state: stores preferences
- Flutter app → Login flow: shows login
- Login flow → Auth state: uses auth state
- Auth state → Firebase Auth: authenticates
- Flutter app → Plant state: provides app state
- Plant state → HTTP repository: loads plant data
- HTTP repository → Express API: calls API
- Plant screens → Plant state: reads plant state
- History screen → HTTP repository: requests history
- Notification screen → HTTP repository: loads alerts
- Settings screens → HTTP repository: updates settings
- Push service → Firebase messaging: registers token
