# davkat1/greenlight architecture

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

- Interactive diagram: https://gitdiagram.com/davkat1/greenlight
- Repository: https://github.com/davkat1/greenlight

## Overview

GreenLight is a Python platform for building and running dynamic greenhouse and crop models. The main workflow is to provide model definitions and input data, load and format them, solve the resulting model, and save simulation outputs. Users can also convert EnergyPlus weather data and use built-in model definitions. The graph includes the documented analysis scripts as a separate branch. Relationships reflect the README and shown source references; unsampled implementation details are not inferred.

Main entry points: [`greenlight/core.py`](https://github.com/davkat1/greenlight/blob/main/greenlight/core.py) (GreenLight API), [`greenlight/_load/core.py`](https://github.com/davkat1/greenlight/blob/main/greenlight/_load/core.py) (Model loading), [`greenlight/main.py`](https://github.com/davkat1/greenlight/blob/main/greenlight/main.py) (Package entry), [`greenlight/_solve/core.py`](https://github.com/davkat1/greenlight/blob/main/greenlight/_solve/core.py) (Solve orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User entry"]
  node_gui["Interactive GUI<br/>[_user_interface.py]"]
  node_entrypoint["Package entry<br/>[main.py]"]
  node_api["GreenLight API<br/>[core.py]"]
end

subgraph group_model["Model inputs"]
  node_model_files["Model definitions"]
  node_input_files["Simulation inputs"]
  node_internal["Model state"]
  node_loader["Model loading<br/>[core.py]"]
  node_parser["Expression parsing<br/>[_parse_model.py]"]
  node_function_expansion["Function expansion"]
  node_load_helpers["Load utilities<br/>[_utils.py]"]
end

subgraph group_runtime["Simulation runtime"]
  node_solver["Solve orchestration<br/>[core.py]"]
  node_ivp_solver["IVP solver<br/>[_solve_ivp.py]"]
  node_string_solver["String solver"]
  node_solver_base["Solver interface<br/>[_solver.py]"]
  node_solution["Simulation results"]
  node_saver["Output saving<br/>[core.py]"]
  node_output_files["CSV and logs"]
end

subgraph group_weather["Weather conversion"]
  node_weather_converter["EnergyPlus conversion<br/>[energy_plus.py]"]
end

subgraph group_analysis["Analysis tools"]
  node_analysis_functions["Analysis functions"]
  node_analysis_figures["Figure generation"]
  node_analysis_tables["Table generation"]
  node_analysis_output["Output analysis<br/>[analyze_output.py]"]
end

node_user(("Python user"))

node_user -->|"uses"| node_api
node_user -->|"starts"| node_entrypoint
node_entrypoint -->|"opens"| node_gui
node_entrypoint -->|"runs"| node_api
node_entrypoint -->|"converts weather"| node_weather_converter
node_model_files -->|"provides definitions"| node_loader
node_input_files -->|"provides inputs"| node_loader
node_api -->|"maintains model"| node_internal
node_api -->|"loads model"| node_loader
node_api -->|"solves model"| node_solver
node_api -->|"saves results"| node_saver
node_loader -->|"updates state"| node_internal
node_loader -->|"parses definitions"| node_parser
node_loader -->|"uses utilities"| node_load_helpers
node_parser -->|"expands functions"| node_function_expansion
node_parser -->|"uses utilities"| node_load_helpers
node_weather_converter -->|"writes converted data"| node_input_files
node_solver -->|"dispatches"| node_ivp_solver
node_solver -->|"dispatches"| node_string_solver
node_ivp_solver -->|"reads and updates"| node_internal
node_string_solver -->|"reads and updates"| node_internal
node_ivp_solver -->|"uses interface"| node_solver_base
node_string_solver -->|"uses interface"| node_solver_base
node_solver -->|"computes results"| node_solution
node_saver -->|"reads results"| node_solution
node_saver -->|"writes files"| node_output_files
node_analysis_tables -->|"uses functions"| node_analysis_functions
node_analysis_output -->|"generates figures"| node_analysis_figures
node_analysis_output -->|"generates tables"| node_analysis_tables
node_analysis_output -.->|"analyzes output"| node_output_files

click node_gui "https://github.com/davkat1/greenlight/blob/main/greenlight/_user_interface.py"
click node_entrypoint "https://github.com/davkat1/greenlight/blob/main/greenlight/main.py"
click node_api "https://github.com/davkat1/greenlight/blob/main/greenlight/core.py"
click node_model_files "https://github.com/davkat1/greenlight/tree/main/greenlight/models"
click node_input_files "https://github.com/davkat1/greenlight/tree/main/greenlight/models"
click node_internal "https://github.com/davkat1/greenlight/blob/main/greenlight/_greenlight_internal.py"
click node_loader "https://github.com/davkat1/greenlight/blob/main/greenlight/_load/core.py"
click node_parser "https://github.com/davkat1/greenlight/blob/main/greenlight/_load/_parse_model.py"
click node_function_expansion "https://github.com/davkat1/greenlight/blob/main/greenlight/_load/_expand_functions.py"
click node_load_helpers "https://github.com/davkat1/greenlight/blob/main/greenlight/_load/_utils.py"
click node_weather_converter "https://github.com/davkat1/greenlight/blob/main/greenlight/energy_plus.py"
click node_solver "https://github.com/davkat1/greenlight/blob/main/greenlight/_solve/core.py"
click node_ivp_solver "https://github.com/davkat1/greenlight/blob/main/greenlight/_solve/_solve_ivp.py"
click node_string_solver "https://github.com/davkat1/greenlight/blob/main/greenlight/_solve/_solve_ivp_from_str.py"
click node_solver_base "https://github.com/davkat1/greenlight/blob/main/greenlight/_solve/_solver.py"
click node_solution "https://github.com/davkat1/greenlight/blob/main/greenlight/_greenlight_internal.py"
click node_saver "https://github.com/davkat1/greenlight/blob/main/greenlight/_save/core.py"
click node_analysis_functions "https://github.com/davkat1/greenlight/blob/main/scripts/katzin_2020/_katzin_2020_analysis_functions.py"
click node_analysis_figures "https://github.com/davkat1/greenlight/blob/main/scripts/katzin_2020/_katzin_2020_generate_figures.py"
click node_analysis_tables "https://github.com/davkat1/greenlight/blob/main/scripts/katzin_2020/_katzin_2020_generate_tables.py"
click node_analysis_output "https://github.com/davkat1/greenlight/blob/main/scripts/analyze_output.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_gui,node_entrypoint,node_api,node_user toneBlue
class node_model_files,node_input_files,node_internal,node_loader,node_parser,node_function_expansion,node_load_helpers toneAmber
class node_solver,node_ivp_solver,node_string_solver,node_solver_base,node_solution,node_saver,node_output_files toneMint
class node_weather_converter toneRose
class node_analysis_functions,node_analysis_figures,node_analysis_tables,node_analysis_output toneIndigo
```

## Components

### User entry

- [Interactive GUI](https://github.com/davkat1/greenlight/blob/main/greenlight/_user_interface.py): `greenlight/_user_interface.py`
- [Package entry](https://github.com/davkat1/greenlight/blob/main/greenlight/main.py): `greenlight/main.py`
- [GreenLight API](https://github.com/davkat1/greenlight/blob/main/greenlight/core.py): `greenlight/core.py`

### Model inputs

- [Model definitions](https://github.com/davkat1/greenlight/tree/main/greenlight/models): `greenlight/models`
- [Simulation inputs](https://github.com/davkat1/greenlight/tree/main/greenlight/models): `greenlight/models`
- [Model state](https://github.com/davkat1/greenlight/blob/main/greenlight/_greenlight_internal.py): `greenlight/_greenlight_internal.py`
- [Model loading](https://github.com/davkat1/greenlight/blob/main/greenlight/_load/core.py): `greenlight/_load/core.py`
- [Expression parsing](https://github.com/davkat1/greenlight/blob/main/greenlight/_load/_parse_model.py): `greenlight/_load/_parse_model.py`
- [Function expansion](https://github.com/davkat1/greenlight/blob/main/greenlight/_load/_expand_functions.py): `greenlight/_load/_expand_functions.py`
- [Load utilities](https://github.com/davkat1/greenlight/blob/main/greenlight/_load/_utils.py): `greenlight/_load/_utils.py`

### Simulation runtime

- [Solve orchestration](https://github.com/davkat1/greenlight/blob/main/greenlight/_solve/core.py): `greenlight/_solve/core.py`
- [IVP solver](https://github.com/davkat1/greenlight/blob/main/greenlight/_solve/_solve_ivp.py): `greenlight/_solve/_solve_ivp.py`
- [String solver](https://github.com/davkat1/greenlight/blob/main/greenlight/_solve/_solve_ivp_from_str.py): `greenlight/_solve/_solve_ivp_from_str.py`
- [Solver interface](https://github.com/davkat1/greenlight/blob/main/greenlight/_solve/_solver.py): `greenlight/_solve/_solver.py`
- [Simulation results](https://github.com/davkat1/greenlight/blob/main/greenlight/_greenlight_internal.py): `greenlight/_greenlight_internal.py`
- [Output saving](https://github.com/davkat1/greenlight/blob/main/greenlight/_save/core.py): `greenlight/_save/core.py`
- **CSV and logs**

### Weather conversion

- [EnergyPlus conversion](https://github.com/davkat1/greenlight/blob/main/greenlight/energy_plus.py): `greenlight/energy_plus.py`

### Analysis tools

- [Analysis functions](https://github.com/davkat1/greenlight/blob/main/scripts/katzin_2020/_katzin_2020_analysis_functions.py): `scripts/katzin_2020/_katzin_2020_analysis_functions.py`
- [Figure generation](https://github.com/davkat1/greenlight/blob/main/scripts/katzin_2020/_katzin_2020_generate_figures.py): `scripts/katzin_2020/_katzin_2020_generate_figures.py`
- [Table generation](https://github.com/davkat1/greenlight/blob/main/scripts/katzin_2020/_katzin_2020_generate_tables.py): `scripts/katzin_2020/_katzin_2020_generate_tables.py`
- [Output analysis](https://github.com/davkat1/greenlight/blob/main/scripts/analyze_output.py): `scripts/analyze_output.py`

### Other components

- **Python user**

## Connections

- Python user → GreenLight API: uses (evidence: `README.md`)
- Python user → Package entry: starts (evidence: `README.md`)
- Package entry → Interactive GUI: opens (evidence: `greenlight/main.py`)
- Package entry → GreenLight API: runs (evidence: `greenlight/main.py`)
- Package entry → EnergyPlus conversion: converts weather (evidence: `greenlight/main.py`)
- Model definitions → Model loading: provides definitions (evidence: `README.md`)
- Simulation inputs → Model loading: provides inputs (evidence: `README.md`)
- GreenLight API → Model state: maintains model (evidence: `greenlight/core.py`)
- GreenLight API → Model loading: loads model (evidence: `greenlight/core.py`)
- GreenLight API → Solve orchestration: solves model (evidence: `greenlight/core.py`)
- GreenLight API → Output saving: saves results (evidence: `greenlight/core.py`)
- Model loading → Model state: updates state (evidence: `greenlight/_load/core.py`)
- Model loading → Expression parsing: parses definitions (evidence: `greenlight/_load/core.py`)
- Model loading → Load utilities: uses utilities (evidence: `greenlight/_load/core.py`)
- Expression parsing → Function expansion: expands functions (evidence: `greenlight/_load/_parse_model.py`)
- Expression parsing → Load utilities: uses utilities (evidence: `greenlight/_load/_parse_model.py`)
- EnergyPlus conversion → Simulation inputs: writes converted data
- Solve orchestration → IVP solver: dispatches (evidence: `greenlight/_solve/core.py`)
- Solve orchestration → String solver: dispatches (evidence: `greenlight/_solve/core.py`)
- IVP solver → Model state: reads and updates (evidence: `greenlight/_solve/_solve_ivp.py`)
- String solver → Model state: reads and updates (evidence: `greenlight/_solve/_solve_ivp_from_str.py`)
- IVP solver → Solver interface: uses interface (evidence: `greenlight/_solve/_solve_ivp.py`)
- String solver → Solver interface: uses interface (evidence: `greenlight/_solve/_solve_ivp_from_str.py`)
- Solve orchestration → Simulation results: computes results (evidence: `greenlight/_solve/core.py`)
- Output saving → Simulation results: reads results (evidence: `greenlight/_save/core.py`)
- Output saving → CSV and logs: writes files (evidence: `greenlight/_save/core.py`)
- Table generation → Analysis functions: uses functions (evidence: `scripts/katzin_2020/_katzin_2020_generate_tables.py`)
- Output analysis → Figure generation: generates figures (evidence: `scripts/katzin_2020/katzin_2020_generate_output.py`)
- Output analysis → Table generation: generates tables (evidence: `scripts/katzin_2020/katzin_2020_generate_output.py`)
- Output analysis → CSV and logs: analyzes output
