# netitto0/hydrotwin architecture

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

- Interactive diagram: https://gitdiagram.com/netitto0/hydrotwin
- Repository: https://github.com/netitto0/hydrotwin

## Overview

HydroTwin is a web-based irrigation simulator: users manage zones in a dashboard, inspect weather and history, and trigger manual irrigation or simulation ticks. The FastAPI application validates requests, obtains weather, applies simulation rules, and persists zone state, readings, and events. The README documents the dashboard’s charts, controls, and API capabilities. Some implementation details are unsampled, so edges rely on shown calls or README statements where noted.

Main entry points: [`app/main.py`](https://github.com/netitto0/hydrotwin/blob/main/app/main.py) (REST routes), [`static/app.js`](https://github.com/netitto0/hydrotwin/blob/main/static/app.js) (Dashboard client), [`app/services/simulation.py`](https://github.com/netitto0/hydrotwin/blob/main/app/services/simulation.py) (Simulation rules), [`app/services/weather.py`](https://github.com/netitto0/hydrotwin/blob/main/app/services/weather.py) (Weather client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Dashboard"]
  node_dashboard["Dashboard client<br/>[app.js]"]
  node_dashboard_markup["Dashboard page<br/>[index.html]"]
  node_dashboard_styles["Dashboard styles<br/>[styles.css]"]
end

subgraph group_api["API"]
  node_api_routes["REST routes<br/>[main.py]"]
  node_request_schemas["Request and response schemas<br/>[schemas.py]"]
end

subgraph group_domain["Irrigation"]
  node_simulation["Simulation rules<br/>[simulation.py]"]
  node_weather["Weather client<br/>[weather.py]"]
end

subgraph group_persistence["Persistence"]
  node_domain_models["Zone and event models<br/>[models.py]"]
  node_database[("SQLite session and engine<br/>[database.py]")]
end

node_user(("Irrigation user"))
node_weather_service["Open-Meteo"]

node_user -->|"uses"| node_dashboard
node_dashboard -->|"renders"| node_dashboard_markup
node_dashboard_markup -->|"uses"| node_dashboard_styles
node_dashboard -->|"requests"| node_api_routes
node_api_routes -->|"validates"| node_request_schemas
node_api_routes -->|"runs ticks"| node_simulation
node_api_routes -->|"fetches weather"| node_weather
node_simulation -->|"uses snapshot"| node_weather
node_weather -->|"requests forecast"| node_weather_service
node_api_routes -->|"opens sessions"| node_database
node_api_routes -->|"reads and writes"| node_domain_models
node_simulation -->|"updates and records"| node_domain_models
node_domain_models -->|"maps entities"| node_database
node_dashboard -->|"renders history and charts"| node_dashboard

click node_dashboard "https://github.com/netitto0/hydrotwin/blob/main/static/app.js"
click node_dashboard_markup "https://github.com/netitto0/hydrotwin/blob/main/static/index.html"
click node_dashboard_styles "https://github.com/netitto0/hydrotwin/blob/main/static/styles.css"
click node_api_routes "https://github.com/netitto0/hydrotwin/blob/main/app/main.py"
click node_request_schemas "https://github.com/netitto0/hydrotwin/blob/main/app/schemas.py"
click node_simulation "https://github.com/netitto0/hydrotwin/blob/main/app/services/simulation.py"
click node_weather "https://github.com/netitto0/hydrotwin/blob/main/app/services/weather.py"
click node_domain_models "https://github.com/netitto0/hydrotwin/blob/main/app/models.py"
click node_database "https://github.com/netitto0/hydrotwin/blob/main/app/database.py"

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_dashboard,node_dashboard_markup,node_dashboard_styles,node_user toneBlue
class node_api_routes,node_request_schemas toneAmber
class node_simulation,node_weather toneMint
class node_domain_models,node_database toneRose
class node_weather_service toneIndigo
```

## Components

### Dashboard

- [Dashboard client](https://github.com/netitto0/hydrotwin/blob/main/static/app.js): `static/app.js`
- [Dashboard page](https://github.com/netitto0/hydrotwin/blob/main/static/index.html): `static/index.html`
- [Dashboard styles](https://github.com/netitto0/hydrotwin/blob/main/static/styles.css): `static/styles.css`

### API

- [REST routes](https://github.com/netitto0/hydrotwin/blob/main/app/main.py): `app/main.py`
- [Request and response schemas](https://github.com/netitto0/hydrotwin/blob/main/app/schemas.py): `app/schemas.py`

### Irrigation

- [Simulation rules](https://github.com/netitto0/hydrotwin/blob/main/app/services/simulation.py): `app/services/simulation.py`
- [Weather client](https://github.com/netitto0/hydrotwin/blob/main/app/services/weather.py): `app/services/weather.py`

### Persistence

- [Zone and event models](https://github.com/netitto0/hydrotwin/blob/main/app/models.py): `app/models.py`
- [SQLite session and engine](https://github.com/netitto0/hydrotwin/blob/main/app/database.py): `app/database.py`

### Other components

- **Irrigation user**
- **Open-Meteo**

## Connections

- Irrigation user → Dashboard client: uses (evidence: `README.md`)
- Dashboard client → Dashboard page: renders (evidence: `README.md`)
- Dashboard page → Dashboard styles: uses (evidence: `README.md`)
- Dashboard client → REST routes: requests (evidence: `static/app.js`)
- REST routes → Request and response schemas: validates (evidence: `app/main.py`)
- REST routes → Simulation rules: runs ticks (evidence: `app/main.py`)
- REST routes → Weather client: fetches weather (evidence: `app/main.py`)
- Simulation rules → Weather client: uses snapshot (evidence: `app/services/simulation.py`)
- Weather client → Open-Meteo: requests forecast (evidence: `app/services/weather.py`)
- REST routes → SQLite session and engine: opens sessions (evidence: `app/main.py`)
- REST routes → Zone and event models: reads and writes (evidence: `app/main.py`)
- Simulation rules → Zone and event models: updates and records (evidence: `app/services/simulation.py`)
- Zone and event models → SQLite session and engine: maps entities (evidence: `app/models.py`)
- Dashboard client → Dashboard client: renders history and charts (evidence: `static/app.js`)
