# gralmazan/proyecto-greenlife architecture

> Architecture diagram of the GitHub repository gralmazan/proyecto-greenlife, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gralmazan/proyecto-greenlife
- Repository: https://github.com/gralmazan/proyecto-greenlife

## Overview

##### Project type and purpose
- This is an embedded “smart greenhouse” control system, implemented on an Arduino Mega microcontroller.
- Purpose: continuously monitor environmental variables (soil moisture, air temperature/humidity), automatically drive irrigation, climate conditioning, and lighting to optimize plant growth.

##### File structure
- Top-level:
- ProyectoGreenLife.ino – core Arduino sketch containing setup() and loop() logic.
- assets/img – photos and QR for documentation, no code modules or external web UI.
- No separate frontend/backend folders or services—this is a self-contained firmware project for hardware control.

##### README for additional insights
- Main features: real-time monitoring, auto-irrigation, temperature/humidity regulation, adaptive lighting.
- Hardware note: requires Arduino Mega for adequate I/O (sensors + actuators).
- No mention of networking or cloud integration.

##### Detail
- Threshold logic inside the controller block (e.g., “if soilMoisture < X → start pump”).
- Interdependencies (e.g., lighting may depend on time of day or ambient light sensor if added).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Perception Layer
    subgraph "Perception Layer"
        direction TB
        SoilMoisture["Soil Moisture Sensor"]:::sensors
        TempSensor["Temperature Sensor"]:::sensors
        HumiditySensor["Humidity Sensor"]:::sensors
    end

    %% Decision & Control Layer
    subgraph "Decision & Control"
        direction TB
        ArduinoMega["Arduino Mega Controller\n(init(), loop(), threshold logic)"]:::controller
    end

    %% Action Layer
    subgraph "Action Layer"
        direction TB
        WaterPump["Water Pump (Relay)"]:::actuators
        HeaterFan["Heating Element / Fan (Relay)"]:::actuators
        GrowLights["Grow Lights (LED MOSFET)"]:::actuators
    end

    %% Power Layer
    subgraph "Power Subsystem"
        direction TB
        PowerSupply["12V/5V Power Supply\n(Voltage Regulators)"]:::power
    end

    %% Documentation
    subgraph "Documentation"
        direction TB
        README["Project Documentation\n(README.md)"]:::docs
        Assets["Documentation Images\n(assets/img)"]:::docs
    end

    %% Flows
    SoilMoisture -->|"reads analog values"| ArduinoMega
    TempSensor -->|"reads analog values"| ArduinoMega
    HumiditySensor -->|"reads analog values"| ArduinoMega

    ArduinoMega -->|"drive pump via relay"| WaterPump
    ArduinoMega -->|"drive heater/fan relay"| HeaterFan
    ArduinoMega -->|"drive MOSFET for lights"| GrowLights

    PowerSupply -->|"power"| ArduinoMega
    PowerSupply -->|"power"| WaterPump
    PowerSupply -->|"power"| HeaterFan
    PowerSupply -->|"power"| GrowLights

    %% Click Events
    click ArduinoMega "https://github.com/gralmazan/proyecto-greenlife/blob/main/ProyectoGreenLife/ProyectoGreenLife.ino"
    click README "https://github.com/gralmazan/proyecto-greenlife/blob/main/README.md"
    click Assets "https://github.com/gralmazan/proyecto-greenlife/tree/main/assets/img"

    %% Styles
    classDef sensors fill:#a8e6a3,stroke:#006400;
    classDef controller fill:#a0c4ff,stroke:#00008b;
    classDef actuators fill:#ffbe7d,stroke:#cd6600;
    classDef power fill:#d3d3d3,stroke:#696969;
    classDef docs fill:#f0e68c,stroke:#b8860b;
```
