# atik0603/smart-greenhouse architecture

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

- Interactive diagram: https://gitdiagram.com/atik0603/smart-greenhouse
- Repository: https://github.com/atik0603/smart-greenhouse

## Overview

Smart Greenhouse is a web application for managing greenhouse locations, zones, devices, sensor readings, actuator states, and automation. Users configure locations and zones, provision and assign devices, inspect readings and overviews, and manage automation and actuator execution through the dashboard. The backend exposes these capabilities through FastAPI and persists application data in PostgreSQL; a background sampler is started when enabled. Edges reflect only relationships shown in the excerpts or SOURCE INDEX; unsampled route and integration details are not inferred.

Main entry points: [`frontend/src/services/api.ts`](https://github.com/atik0603/smart-greenhouse/blob/main/frontend/src/services/api.ts) (API client), [`frontend/src/App.tsx`](https://github.com/atik0603/smart-greenhouse/blob/main/frontend/src/App.tsx) (Dashboard shell), [`backend/src/infrastructure/persistence/models.py`](https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/infrastructure/persistence/models.py) (PostgreSQL data model), [`backend/src/main.py`](https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/main.py) (FastAPI application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Dashboard"]
  node_app["Dashboard shell<br/>[App.tsx]"]
  node_dashboard["Overview dashboard<br/>[OverviewPanel.tsx]"]
  node_device_ui["Device management<br/>[DeviceList.tsx]"]
  node_config_ui["Location configuration"]
  node_automation_ui["Automation panel<br/>[StrategyPanel.tsx]"]
  node_sensor_ui["Sensor readings"]
  node_execution_ui["Execution log<br/>[ExecutionLog.tsx]"]
  node_client["API client<br/>[api.ts]"]
end

subgraph group_api["API and orchestration"]
  node_api_server["FastAPI application<br/>[main.py]"]
  node_location_routes["Location endpoints<br/>[locations.py]"]
  node_device_routes["Device endpoints<br/>[devices.py]"]
  node_sampler["Sampler runner<br/>[sampler_runner.py]"]
end

subgraph group_domain["Greenhouse capabilities"]
  node_location_service["Location and zone configuration<br/>[zone_service.py]"]
  node_readings["Reading ingestion<br/>[service.py]"]
  node_actuator_state["Actuator state transitions"]
  node_automation["Automation evaluation<br/>[service.py]"]
  node_overview["Overview assembly<br/>[facade.py]"]
end

subgraph group_infra["Persistence and adapters"]
  node_device_repo["Device repository"]
  node_location_repo["Location repository"]
  node_reading_repo["Reading repository"]
  node_automation_repo["Automation repository"]
  node_actuator_repo["Actuator state repository"]
  node_db_models[("PostgreSQL data model<br/>[models.py]")]
  node_sensor_adapters["Sensor adapters"]
  node_actuator_adapters["Actuator adapters"]
end

node_user(("Greenhouse user"))

node_user -->|"uses"| node_app
node_app -->|"renders"| node_dashboard
node_app -->|"renders"| node_device_ui
node_app -->|"renders"| node_config_ui
node_app -->|"renders"| node_automation_ui
node_app -->|"renders"| node_execution_ui
node_device_ui -->|"requests data"| node_client
node_dashboard -->|"requests overview"| node_client
node_config_ui -->|"requests configuration"| node_client
node_sensor_ui -->|"requests readings"| node_client
node_automation_ui -->|"requests automation"| node_client
node_execution_ui -->|"requests history"| node_client
node_client -->|"HTTP requests"| node_api_server
node_api_server -->|"registers router"| node_location_routes
node_api_server -->|"registers router"| node_device_routes
node_api_server -->|"starts when enabled"| node_sampler
node_location_routes -->|"uses configuration services"| node_location_service
node_location_routes -->|"uses repository"| node_location_repo
node_location_service -->|"validates and writes zones"| node_location_repo
node_device_routes -->|"uses device storage"| node_device_repo
node_readings -->|"loads device"| node_device_repo
node_readings -->|"selects adapter"| node_sensor_adapters
node_readings -->|"saves readings"| node_reading_repo
node_actuator_state -->|"loads actuator"| node_device_repo
node_actuator_state -->|"reads and saves state"| node_actuator_repo
node_automation -->|"loads and stores strategy"| node_automation_repo
node_device_repo -->|"maps device rows"| node_db_models
node_location_repo -->|"reads and writes rows"| node_db_models
node_reading_repo -->|"persists readings"| node_db_models
node_automation_repo -->|"persists strategy"| node_db_models
node_actuator_repo -->|"persists state"| node_db_models

click node_app "https://github.com/atik0603/smart-greenhouse/blob/main/frontend/src/App.tsx"
click node_dashboard "https://github.com/atik0603/smart-greenhouse/blob/main/frontend/src/features/overview/OverviewPanel.tsx"
click node_device_ui "https://github.com/atik0603/smart-greenhouse/blob/main/frontend/src/components/devices/DeviceList.tsx"
click node_config_ui "https://github.com/atik0603/smart-greenhouse/blob/main/frontend/src/components/config/LocationConfigWizard.tsx"
click node_automation_ui "https://github.com/atik0603/smart-greenhouse/blob/main/frontend/src/features/automation/StrategyPanel.tsx"
click node_sensor_ui "https://github.com/atik0603/smart-greenhouse/blob/main/frontend/src/features/sensors/SensorReadingPanel.tsx"
click node_execution_ui "https://github.com/atik0603/smart-greenhouse/blob/main/frontend/src/features/actuators/ExecutionLog.tsx"
click node_client "https://github.com/atik0603/smart-greenhouse/blob/main/frontend/src/services/api.ts"
click node_api_server "https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/main.py"
click node_location_routes "https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/interfaces/api/locations.py"
click node_device_routes "https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/interfaces/api/devices.py"
click node_sampler "https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/interfaces/sampler_runner.py"
click node_location_service "https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/application/locations/zone_service.py"
click node_readings "https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/application/readings/service.py"
click node_actuator_state "https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/application/devices/actuator_state_service.py"
click node_automation "https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/application/automation/service.py"
click node_overview "https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/application/overview/facade.py"
click node_device_repo "https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/infrastructure/persistence/device_repository.py"
click node_location_repo "https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/infrastructure/persistence/location_repository.py"
click node_reading_repo "https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/infrastructure/persistence/reading_repository.py"
click node_automation_repo "https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/infrastructure/persistence/automation_repository.py"
click node_actuator_repo "https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/infrastructure/persistence/actuator_state_repository.py"
click node_db_models "https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/infrastructure/persistence/models.py"
click node_sensor_adapters "https://github.com/atik0603/smart-greenhouse/tree/main/backend/src/infrastructure/adapters/sensors"
click node_actuator_adapters "https://github.com/atik0603/smart-greenhouse/tree/main/backend/src/infrastructure/adapters/actuators"

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_app,node_dashboard,node_device_ui,node_config_ui,node_automation_ui,node_sensor_ui,node_execution_ui,node_client,node_user toneBlue
class node_api_server,node_location_routes,node_device_routes,node_sampler toneAmber
class node_location_service,node_readings,node_actuator_state,node_automation,node_overview toneMint
class node_device_repo,node_location_repo,node_reading_repo,node_automation_repo,node_actuator_repo,node_db_models,node_sensor_adapters,node_actuator_adapters toneRose
```

## Components

### Dashboard

- [Dashboard shell](https://github.com/atik0603/smart-greenhouse/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Overview dashboard](https://github.com/atik0603/smart-greenhouse/blob/main/frontend/src/features/overview/OverviewPanel.tsx): `frontend/src/features/overview/OverviewPanel.tsx`
- [Device management](https://github.com/atik0603/smart-greenhouse/blob/main/frontend/src/components/devices/DeviceList.tsx): `frontend/src/components/devices/DeviceList.tsx`
- [Location configuration](https://github.com/atik0603/smart-greenhouse/blob/main/frontend/src/components/config/LocationConfigWizard.tsx): `frontend/src/components/config/LocationConfigWizard.tsx`
- [Automation panel](https://github.com/atik0603/smart-greenhouse/blob/main/frontend/src/features/automation/StrategyPanel.tsx): `frontend/src/features/automation/StrategyPanel.tsx`
- [Sensor readings](https://github.com/atik0603/smart-greenhouse/blob/main/frontend/src/features/sensors/SensorReadingPanel.tsx): `frontend/src/features/sensors/SensorReadingPanel.tsx`
- [Execution log](https://github.com/atik0603/smart-greenhouse/blob/main/frontend/src/features/actuators/ExecutionLog.tsx): `frontend/src/features/actuators/ExecutionLog.tsx`
- [API client](https://github.com/atik0603/smart-greenhouse/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`

### API and orchestration

- [FastAPI application](https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/main.py): `backend/src/main.py`
- [Location endpoints](https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/interfaces/api/locations.py): `backend/src/interfaces/api/locations.py`
- [Device endpoints](https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/interfaces/api/devices.py): `backend/src/interfaces/api/devices.py`
- [Sampler runner](https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/interfaces/sampler_runner.py): `backend/src/interfaces/sampler_runner.py`

### Greenhouse capabilities

- [Location and zone configuration](https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/application/locations/zone_service.py): `backend/src/application/locations/zone_service.py`
- [Reading ingestion](https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/application/readings/service.py): `backend/src/application/readings/service.py`
- [Actuator state transitions](https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/application/devices/actuator_state_service.py): `backend/src/application/devices/actuator_state_service.py`
- [Automation evaluation](https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/application/automation/service.py): `backend/src/application/automation/service.py`
- [Overview assembly](https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/application/overview/facade.py): `backend/src/application/overview/facade.py`

### Persistence and adapters

- [Device repository](https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/infrastructure/persistence/device_repository.py): `backend/src/infrastructure/persistence/device_repository.py`
- [Location repository](https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/infrastructure/persistence/location_repository.py): `backend/src/infrastructure/persistence/location_repository.py`
- [Reading repository](https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/infrastructure/persistence/reading_repository.py): `backend/src/infrastructure/persistence/reading_repository.py`
- [Automation repository](https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/infrastructure/persistence/automation_repository.py): `backend/src/infrastructure/persistence/automation_repository.py`
- [Actuator state repository](https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/infrastructure/persistence/actuator_state_repository.py): `backend/src/infrastructure/persistence/actuator_state_repository.py`
- [PostgreSQL data model](https://github.com/atik0603/smart-greenhouse/blob/main/backend/src/infrastructure/persistence/models.py): `backend/src/infrastructure/persistence/models.py`
- [Sensor adapters](https://github.com/atik0603/smart-greenhouse/tree/main/backend/src/infrastructure/adapters/sensors): `backend/src/infrastructure/adapters/sensors`
- [Actuator adapters](https://github.com/atik0603/smart-greenhouse/tree/main/backend/src/infrastructure/adapters/actuators): `backend/src/infrastructure/adapters/actuators`

### Other components

- **Greenhouse user**

## Connections

- Greenhouse user → Dashboard shell: uses (evidence: `frontend/src/App.tsx`)
- Dashboard shell → Overview dashboard: renders (evidence: `frontend/src/App.tsx`)
- Dashboard shell → Device management: renders (evidence: `frontend/src/App.tsx`)
- Dashboard shell → Location configuration: renders (evidence: `frontend/src/App.tsx`)
- Dashboard shell → Automation panel: renders (evidence: `frontend/src/App.tsx`)
- Dashboard shell → Execution log: renders (evidence: `frontend/src/App.tsx`)
- Device management → API client: requests data (evidence: `frontend/src/components/devices/DeviceList.tsx`)
- Overview dashboard → API client: requests overview (evidence: `frontend/src/features/overview/OverviewPanel.tsx`)
- Location configuration → API client: requests configuration
- Sensor readings → API client: requests readings (evidence: `frontend/src/features/sensors/SensorReadingPanel.tsx`)
- Automation panel → API client: requests automation (evidence: `frontend/src/features/automation/StrategyPanel.tsx`)
- Execution log → API client: requests history (evidence: `frontend/src/features/actuators/ExecutionLog.tsx`)
- API client → FastAPI application: HTTP requests (evidence: `frontend/src/services/api.ts`)
- FastAPI application → Location endpoints: registers router (evidence: `backend/src/main.py`)
- FastAPI application → Device endpoints: registers router (evidence: `backend/src/main.py`)
- FastAPI application → Sampler runner: starts when enabled (evidence: `backend/src/main.py`)
- Location endpoints → Location and zone configuration: uses configuration services (evidence: `backend/src/interfaces/api/locations.py`)
- Location endpoints → Location repository: uses repository (evidence: `backend/src/interfaces/api/locations.py`)
- Location and zone configuration → Location repository: validates and writes zones (evidence: `backend/src/application/locations/zone_service.py`)
- Device endpoints → Device repository: uses device storage
- Reading ingestion → Device repository: loads device (evidence: `backend/src/application/readings/service.py`)
- Reading ingestion → Sensor adapters: selects adapter (evidence: `backend/src/application/readings/service.py`)
- Reading ingestion → Reading repository: saves readings (evidence: `backend/src/application/readings/service.py`)
- Actuator state transitions → Device repository: loads actuator (evidence: `backend/src/application/devices/actuator_state_service.py`)
- Actuator state transitions → Actuator state repository: reads and saves state (evidence: `backend/src/application/devices/actuator_state_service.py`)
- Automation evaluation → Automation repository: loads and stores strategy (evidence: `backend/src/application/automation/service.py`)
- Device repository → PostgreSQL data model: maps device rows (evidence: `backend/src/infrastructure/persistence/device_repository.py`)
- Location repository → PostgreSQL data model: reads and writes rows (evidence: `backend/src/infrastructure/persistence/location_repository.py`)
- Reading repository → PostgreSQL data model: persists readings (evidence: `backend/src/infrastructure/persistence/reading_repository.py`)
- Automation repository → PostgreSQL data model: persists strategy (evidence: `backend/src/infrastructure/persistence/automation_repository.py`)
- Actuator state repository → PostgreSQL data model: persists state (evidence: `backend/src/infrastructure/persistence/actuator_state_repository.py`)
