# racmanmontes09-cyber/proleaf architecture

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

- Interactive diagram: https://gitdiagram.com/racmanmontes09-cyber/proleaf
- Repository: https://github.com/racmanmontes09-cyber/proleaf

## Overview

This is a Laravel greenhouse monitoring and control application: IoT devices report telemetry, while users monitor greenhouse status, alerts and history and can manage devices and issue commands. Its main workflow is device telemetry ingestion, threshold/health evaluation, and dashboard presentation; a separate command workflow lets devices claim and report command results. The tree and source index show the major subsystems, but several key controllers and services were not excerpted, so their runtime connections are shown as unverified rather than asserted. The README is Laravel boilerplate, not product documentation.

Main entry points: [`app/Services/TelemetryService.php`](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Services/TelemetryService.php) (Telemetry processing), [`app/Services/DashboardService.php`](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Services/DashboardService.php) (Greenhouse dashboard), [`app/Services/AlertService.php`](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Services/AlertService.php) (Alert evaluation), [`app/Http/Controllers/Api/DeviceCommandController.php`](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Http/Controllers/Api/DeviceCommandController.php) (Device command API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Device communication"]
  node_telemetry_api["Telemetry API"]
  node_device_auth["Device authentication"]
  node_telemetry_service["Telemetry processing"]
  node_mqtt_subscriber["MQTT subscriber<br/>[MqttSubscribe.php]"]
  node_telemetry_store[("Telemetry records<br/>[Telemetry.php]")]
  node_device_model[("Device registry<br/>[Device.php]")]
end

subgraph group_monitor["Monitoring and alerts"]
  node_dashboard["Greenhouse dashboard"]
  node_device_status["Device status view<br/>[DeviceStatus.php]"]
  node_alert_service["Alert evaluation<br/>[AlertService.php]"]
  node_threshold_service["Threshold settings"]
  node_alert_repository["Alert access"]
  node_alert_store[("Alert records<br/>[Alert.php]")]
  node_email_service["Offline notifications"]
end

subgraph group_control["Device control"]
  node_command_api["Device command API"]
  node_command_service["Command lifecycle"]
  node_command_repository["Command access"]
  node_command_store[("Device commands<br/>[DeviceCommand.php]")]
end

subgraph group_admin["Users and settings"]
  node_user_admin["User administration<br/>[Users.php]"]
  node_user_model[("Users and roles<br/>[User.php]")]
  node_settings_api["System settings API"]
  node_settings_store[("System settings<br/>[SystemSetting.php]")]
end

node_device(("IoT device"))
node_farmer(("Greenhouse user"))
node_mail(("Email service"))

node_device -.->|"submits readings"| node_telemetry_api
node_telemetry_api -.->|"authenticates"| node_device_auth
node_telemetry_api -.->|"processes readings"| node_telemetry_service
node_telemetry_service -.->|"stores readings"| node_telemetry_store
node_telemetry_service -.->|"evaluates alerts"| node_alert_service
node_mqtt_subscriber -.->|"dispatches telemetry"| node_telemetry_service
node_farmer -.->|"views status"| node_dashboard
node_dashboard -->|"renders status"| node_device_status
node_dashboard -->|"reads telemetry"| node_telemetry_service
node_dashboard -->|"reads alerts"| node_alert_service
node_dashboard -->|"uses thresholds"| node_threshold_service
node_alert_service -->|"loads thresholds"| node_threshold_service
node_alert_service -->|"manages alerts"| node_alert_repository
node_alert_repository -->|"queries alerts"| node_alert_store
node_alert_service -->|"sends notification"| node_email_service
node_email_service -.->|"delivers email"| node_mail
node_device -.->|"claims commands"| node_command_api
node_command_api -->|"updates lifecycle"| node_command_service
node_command_api -->|"finds command"| node_command_repository
node_command_service -->|"manages commands"| node_command_repository
node_command_repository -->|"queries commands"| node_command_store
node_command_api -->|"uses device"| node_device_model
node_farmer -.->|"manages users"| node_user_admin
node_user_admin -->|"manages accounts"| node_user_model
node_settings_api -->|"uses thresholds"| node_threshold_service
node_threshold_service -->|"reads settings"| node_settings_store
node_telemetry_service -.->|"updates device"| node_device_model

click node_telemetry_api "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Http/Controllers/Api/TelemetryController.php"
click node_device_auth "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Http/Middleware/AuthenticateDevice.php"
click node_telemetry_service "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Services/TelemetryService.php"
click node_mqtt_subscriber "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Console/Commands/MqttSubscribe.php"
click node_telemetry_store "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Models/Telemetry.php"
click node_device_model "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Models/Device.php"
click node_dashboard "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Services/DashboardService.php"
click node_device_status "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Livewire/Dashboard/DeviceStatus.php"
click node_alert_service "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Services/AlertService.php"
click node_threshold_service "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Services/ThresholdService.php"
click node_alert_repository "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Repositories/AlertRepository.php"
click node_alert_store "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Models/Alert.php"
click node_command_api "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Http/Controllers/Api/DeviceCommandController.php"
click node_command_service "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Services/DeviceCommandService.php"
click node_command_repository "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Repositories/DeviceCommandRepository.php"
click node_command_store "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Models/DeviceCommand.php"
click node_user_admin "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Livewire/Admin/Users.php"
click node_user_model "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Models/User.php"
click node_settings_api "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Http/Controllers/Api/SystemSettingsController.php"
click node_settings_store "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Models/SystemSetting.php"
click node_email_service "https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Mail/GreenhouseOfflineNotification.php"

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_telemetry_api,node_device_auth,node_telemetry_service,node_mqtt_subscriber,node_telemetry_store,node_device_model,node_farmer toneBlue
class node_dashboard,node_device_status,node_alert_service,node_threshold_service,node_alert_repository,node_alert_store,node_email_service toneAmber
class node_command_api,node_command_service,node_command_repository,node_command_store toneMint
class node_user_admin,node_user_model,node_settings_api,node_settings_store toneRose
class node_device,node_mail toneIndigo
```

## Components

### Device communication

- [Telemetry API](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Http/Controllers/Api/TelemetryController.php): `app/Http/Controllers/Api/TelemetryController.php`
- [Device authentication](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Http/Middleware/AuthenticateDevice.php): `app/Http/Middleware/AuthenticateDevice.php`
- [Telemetry processing](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Services/TelemetryService.php): `app/Services/TelemetryService.php`
- [MQTT subscriber](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Console/Commands/MqttSubscribe.php): `app/Console/Commands/MqttSubscribe.php`
- [Telemetry records](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Models/Telemetry.php): `app/Models/Telemetry.php`
- [Device registry](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Models/Device.php): `app/Models/Device.php`

### Monitoring and alerts

- [Greenhouse dashboard](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Services/DashboardService.php): `app/Services/DashboardService.php`
- [Device status view](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Livewire/Dashboard/DeviceStatus.php): `app/Livewire/Dashboard/DeviceStatus.php`
- [Alert evaluation](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Services/AlertService.php): `app/Services/AlertService.php`
- [Threshold settings](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Services/ThresholdService.php): `app/Services/ThresholdService.php`
- [Alert access](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Repositories/AlertRepository.php): `app/Repositories/AlertRepository.php`
- [Alert records](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Models/Alert.php): `app/Models/Alert.php`
- [Offline notifications](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Mail/GreenhouseOfflineNotification.php): `app/Mail/GreenhouseOfflineNotification.php`

### Device control

- [Device command API](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Http/Controllers/Api/DeviceCommandController.php): `app/Http/Controllers/Api/DeviceCommandController.php`
- [Command lifecycle](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Services/DeviceCommandService.php): `app/Services/DeviceCommandService.php`
- [Command access](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Repositories/DeviceCommandRepository.php): `app/Repositories/DeviceCommandRepository.php`
- [Device commands](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Models/DeviceCommand.php): `app/Models/DeviceCommand.php`

### Users and settings

- [User administration](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Livewire/Admin/Users.php): `app/Livewire/Admin/Users.php`
- [Users and roles](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Models/User.php): `app/Models/User.php`
- [System settings API](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Http/Controllers/Api/SystemSettingsController.php): `app/Http/Controllers/Api/SystemSettingsController.php`
- [System settings](https://github.com/racmanmontes09-cyber/proleaf/blob/main/app/Models/SystemSetting.php): `app/Models/SystemSetting.php`

### Other components

- **IoT device**
- **Greenhouse user**
- **Email service**

## Connections

- IoT device → Telemetry API: submits readings
- Telemetry API → Device authentication: authenticates
- Telemetry API → Telemetry processing: processes readings
- Telemetry processing → Telemetry records: stores readings
- Telemetry processing → Alert evaluation: evaluates alerts
- MQTT subscriber → Telemetry processing: dispatches telemetry
- Greenhouse user → Greenhouse dashboard: views status
- Greenhouse dashboard → Device status view: renders status (evidence: `app/Services/DashboardService.php`)
- Greenhouse dashboard → Telemetry processing: reads telemetry (evidence: `app/Services/DashboardService.php`)
- Greenhouse dashboard → Alert evaluation: reads alerts (evidence: `app/Services/DashboardService.php`)
- Greenhouse dashboard → Threshold settings: uses thresholds (evidence: `app/Services/DashboardService.php`)
- Alert evaluation → Threshold settings: loads thresholds (evidence: `app/Services/AlertService.php`)
- Alert evaluation → Alert access: manages alerts (evidence: `app/Services/AlertService.php`)
- Alert access → Alert records: queries alerts (evidence: `app/Repositories/AlertRepository.php`)
- Alert evaluation → Offline notifications: sends notification (evidence: `app/Services/AlertService.php`)
- Offline notifications → Email service: delivers email
- IoT device → Device command API: claims commands
- Device command API → Command lifecycle: updates lifecycle (evidence: `app/Http/Controllers/Api/DeviceCommandController.php`)
- Device command API → Command access: finds command (evidence: `app/Http/Controllers/Api/DeviceCommandController.php`)
- Command lifecycle → Command access: manages commands (evidence: `app/Services/DeviceCommandService.php`)
- Command access → Device commands: queries commands (evidence: `app/Repositories/DeviceCommandRepository.php`)
- Device command API → Device registry: uses device (evidence: `app/Http/Controllers/Api/DeviceCommandController.php`)
- Greenhouse user → User administration: manages users
- User administration → Users and roles: manages accounts (evidence: `app/Livewire/Admin/Users.php`)
- System settings API → Threshold settings: uses thresholds (evidence: `app/Http/Controllers/Api/SystemSettingsController.php`)
- Threshold settings → System settings: reads settings (evidence: `app/Services/ThresholdService.php`)
- Telemetry processing → Device registry: updates device
