# rafatahmed/flahax architecture

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

- Interactive diagram: https://gitdiagram.com/rafatahmed/flahax
- Repository: https://github.com/rafatahmed/flahax

## Overview

FlahaX is a standalone Python plant-nutrient chemistry engine. Its main workflow accepts water analysis and crop targets, formulates fertilizer doses, evaluates solution chemistry and pH, then produces reviewable delivery plans rather than controlling equipment. Separate capabilities cover conductivity screening, stock and injector planning, and traceable material and input records. The graph uses README statements and SOURCE INDEX references for relationships; some CLI wiring and unsampled implementation details remain unverified.

Main entry points: [`src/flahax/fertilizer_workflow.py`](https://github.com/rafatahmed/flahax/blob/main/src/flahax/fertilizer_workflow.py) (Fertilizer Workflow), [`src/flahax/aqueous_model.py`](https://github.com/rafatahmed/flahax/blob/main/src/flahax/aqueous_model.py) (Aqueous Model), [`src/flahax/product_conversion.py`](https://github.com/rafatahmed/flahax/blob/main/src/flahax/product_conversion.py) (Product Conversion), [`src/flahax/equilibrium_delivery.py`](https://github.com/rafatahmed/flahax/blob/main/src/flahax/equilibrium_delivery.py) (Equilibrium Delivery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_formulation["Formulation"]
  node_solver["Salt Formulation<br/>[engine.py]"]
  node_composition["Formula Validation<br/>[composition.py]"]
end

subgraph group_chemistry["Solution Chemistry"]
  node_water["Measured Water<br/>[measured_water.py]"]
  node_aqueous["Aqueous Model<br/>[aqueous_model.py]"]
  node_fertilizer_eq["Fertilizer Equilibrium"]
  node_mixed_eq["Mixed Equilibrium"]
  node_ph["Calculated pH<br/>[calculated_ph.py]"]
  node_conversion["Product Conversion"]
  node_ec["Irrigation EC<br/>[irrigation_ec.py]"]
  node_conductivity["EC Screening<br/>[conductivity.py]"]
end

subgraph group_planning["Planning and Delivery"]
  node_workflow["Fertilizer Workflow"]
  node_acid["Acid Selection<br/>[acid_selection.py]"]
  node_phplan["pH Planning<br/>[ph_planning.py]"]
  node_delivery["Equilibrium Delivery"]
  node_stocks["Stock Planning<br/>[stock_planning.py]"]
  node_pump["Pump Sizing<br/>[pump_planning.py]"]
  node_quantities["Unit Quantities"]
end

subgraph group_records["Inputs and Provenance"]
  node_contracts["Delivery Contracts"]
  node_materials["Material Catalogue<br/>[materials.py]"]
end

subgraph group_interface["User Interface"]
  node_cli["Command Line<br/>[planning_cli.py]"]
  node_api["Python API<br/>[__init__.py]"]
end

node_grower(("Grower or Developer"))

node_grower -->|"calls"| node_api
node_grower -->|"runs"| node_cli
node_api -->|"exposes"| node_solver
node_cli -.->|"plans"| node_workflow
node_workflow -->|"formulates"| node_solver
node_workflow -->|"balances"| node_water
node_workflow -->|"calculates pH"| node_ph
node_workflow -->|"converts doses"| node_conversion
node_workflow -->|"selects acid"| node_acid
node_workflow -->|"plans pH"| node_phplan
node_workflow -->|"plans stocks"| node_stocks
node_solver -->|"validates formula"| node_composition
node_water -->|"speciates"| node_aqueous
node_ph -->|"solves"| node_aqueous
node_conversion -->|"resolves profiles"| node_materials
node_conversion -->|"builds totals"| node_aqueous
node_mixed_eq -->|"uses solver"| node_aqueous
node_fertilizer_eq -->|"supports model"| node_mixed_eq
node_acid -->|"evaluates dose"| node_aqueous
node_delivery -->|"converts recipe"| node_conversion
node_delivery -->|"uses units"| node_quantities
node_delivery -->|"validates records"| node_contracts
node_stocks -->|"uses quantities"| node_quantities
node_workflow -->|"composes plan"| node_delivery
node_ec -->|"uses speciation"| node_aqueous
node_ec -->|"converts doses"| node_conversion
node_conductivity -->|"screens products"| node_stocks
node_conductivity -->|"uses units"| node_quantities
node_conductivity -->|"uses sizing"| node_pump
node_workflow -->|"validates inputs"| node_contracts

click node_cli "https://github.com/rafatahmed/flahax/blob/main/src/flahax/planning_cli.py"
click node_api "https://github.com/rafatahmed/flahax/blob/main/src/flahax/__init__.py"
click node_workflow "https://github.com/rafatahmed/flahax/blob/main/src/flahax/fertilizer_workflow.py"
click node_solver "https://github.com/rafatahmed/flahax/blob/main/src/flahax/engine.py"
click node_composition "https://github.com/rafatahmed/flahax/blob/main/src/flahax/composition.py"
click node_water "https://github.com/rafatahmed/flahax/blob/main/src/flahax/measured_water.py"
click node_aqueous "https://github.com/rafatahmed/flahax/blob/main/src/flahax/aqueous_model.py"
click node_fertilizer_eq "https://github.com/rafatahmed/flahax/blob/main/src/flahax/fertilizer_equilibrium.py"
click node_mixed_eq "https://github.com/rafatahmed/flahax/blob/main/src/flahax/mixed_equilibrium.py"
click node_ph "https://github.com/rafatahmed/flahax/blob/main/src/flahax/calculated_ph.py"
click node_acid "https://github.com/rafatahmed/flahax/blob/main/src/flahax/acid_selection.py"
click node_phplan "https://github.com/rafatahmed/flahax/blob/main/src/flahax/ph_planning.py"
click node_conversion "https://github.com/rafatahmed/flahax/blob/main/src/flahax/product_conversion.py"
click node_ec "https://github.com/rafatahmed/flahax/blob/main/src/flahax/irrigation_ec.py"
click node_delivery "https://github.com/rafatahmed/flahax/blob/main/src/flahax/equilibrium_delivery.py"
click node_stocks "https://github.com/rafatahmed/flahax/blob/main/src/flahax/stock_planning.py"
click node_pump "https://github.com/rafatahmed/flahax/blob/main/src/flahax/pump_planning.py"
click node_quantities "https://github.com/rafatahmed/flahax/blob/main/src/flahax/delivery_quantities.py"
click node_contracts "https://github.com/rafatahmed/flahax/blob/main/src/flahax/delivery_contracts.py"
click node_materials "https://github.com/rafatahmed/flahax/blob/main/src/flahax/materials.py"
click node_conductivity "https://github.com/rafatahmed/flahax/blob/main/src/flahax/conductivity.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_solver,node_composition toneBlue
class node_water,node_aqueous,node_fertilizer_eq,node_mixed_eq,node_ph,node_conversion,node_ec,node_conductivity toneAmber
class node_workflow,node_acid,node_phplan,node_delivery,node_stocks,node_pump,node_quantities toneMint
class node_contracts,node_materials toneRose
class node_cli,node_api,node_grower toneIndigo
```

## Components

### Formulation

- [Salt Formulation](https://github.com/rafatahmed/flahax/blob/main/src/flahax/engine.py): `src/flahax/engine.py`
- [Formula Validation](https://github.com/rafatahmed/flahax/blob/main/src/flahax/composition.py): `src/flahax/composition.py`

### Solution Chemistry

- [Measured Water](https://github.com/rafatahmed/flahax/blob/main/src/flahax/measured_water.py): `src/flahax/measured_water.py`
- [Aqueous Model](https://github.com/rafatahmed/flahax/blob/main/src/flahax/aqueous_model.py): `src/flahax/aqueous_model.py`
- [Fertilizer Equilibrium](https://github.com/rafatahmed/flahax/blob/main/src/flahax/fertilizer_equilibrium.py): `src/flahax/fertilizer_equilibrium.py`
- [Mixed Equilibrium](https://github.com/rafatahmed/flahax/blob/main/src/flahax/mixed_equilibrium.py): `src/flahax/mixed_equilibrium.py`
- [Calculated pH](https://github.com/rafatahmed/flahax/blob/main/src/flahax/calculated_ph.py): `src/flahax/calculated_ph.py`
- [Product Conversion](https://github.com/rafatahmed/flahax/blob/main/src/flahax/product_conversion.py): `src/flahax/product_conversion.py`
- [Irrigation EC](https://github.com/rafatahmed/flahax/blob/main/src/flahax/irrigation_ec.py): `src/flahax/irrigation_ec.py`
- [EC Screening](https://github.com/rafatahmed/flahax/blob/main/src/flahax/conductivity.py): `src/flahax/conductivity.py`

### Planning and Delivery

- [Fertilizer Workflow](https://github.com/rafatahmed/flahax/blob/main/src/flahax/fertilizer_workflow.py): `src/flahax/fertilizer_workflow.py`
- [Acid Selection](https://github.com/rafatahmed/flahax/blob/main/src/flahax/acid_selection.py): `src/flahax/acid_selection.py`
- [pH Planning](https://github.com/rafatahmed/flahax/blob/main/src/flahax/ph_planning.py): `src/flahax/ph_planning.py`
- [Equilibrium Delivery](https://github.com/rafatahmed/flahax/blob/main/src/flahax/equilibrium_delivery.py): `src/flahax/equilibrium_delivery.py`
- [Stock Planning](https://github.com/rafatahmed/flahax/blob/main/src/flahax/stock_planning.py): `src/flahax/stock_planning.py`
- [Pump Sizing](https://github.com/rafatahmed/flahax/blob/main/src/flahax/pump_planning.py): `src/flahax/pump_planning.py`
- [Unit Quantities](https://github.com/rafatahmed/flahax/blob/main/src/flahax/delivery_quantities.py): `src/flahax/delivery_quantities.py`

### Inputs and Provenance

- [Delivery Contracts](https://github.com/rafatahmed/flahax/blob/main/src/flahax/delivery_contracts.py): `src/flahax/delivery_contracts.py`
- [Material Catalogue](https://github.com/rafatahmed/flahax/blob/main/src/flahax/materials.py): `src/flahax/materials.py`

### User Interface

- [Command Line](https://github.com/rafatahmed/flahax/blob/main/src/flahax/planning_cli.py): `src/flahax/planning_cli.py`
- [Python API](https://github.com/rafatahmed/flahax/blob/main/src/flahax/__init__.py): `src/flahax/__init__.py`

### Other components

- **Grower or Developer**

## Connections

- Grower or Developer → Python API: calls (evidence: `README.md`)
- Grower or Developer → Command Line: runs (evidence: `README.md`)
- Python API → Salt Formulation: exposes (evidence: `src/flahax/__init__.py`)
- Command Line → Fertilizer Workflow: plans
- Fertilizer Workflow → Salt Formulation: formulates (evidence: `src/flahax/fertilizer_workflow.py`)
- Fertilizer Workflow → Measured Water: balances (evidence: `src/flahax/fertilizer_workflow.py`)
- Fertilizer Workflow → Calculated pH: calculates pH (evidence: `src/flahax/fertilizer_workflow.py`)
- Fertilizer Workflow → Product Conversion: converts doses (evidence: `src/flahax/fertilizer_workflow.py`)
- Fertilizer Workflow → Acid Selection: selects acid (evidence: `src/flahax/fertilizer_workflow.py`)
- Fertilizer Workflow → pH Planning: plans pH (evidence: `src/flahax/fertilizer_workflow.py`)
- Fertilizer Workflow → Stock Planning: plans stocks (evidence: `src/flahax/fertilizer_workflow.py`)
- Salt Formulation → Formula Validation: validates formula (evidence: `src/flahax/engine.py`)
- Measured Water → Aqueous Model: speciates (evidence: `src/flahax/measured_water.py`)
- Calculated pH → Aqueous Model: solves (evidence: `src/flahax/calculated_ph.py`)
- Product Conversion → Material Catalogue: resolves profiles (evidence: `src/flahax/product_conversion.py`)
- Product Conversion → Aqueous Model: builds totals (evidence: `src/flahax/product_conversion.py`)
- Mixed Equilibrium → Aqueous Model: uses solver (evidence: `src/flahax/mixed_equilibrium.py`)
- Fertilizer Equilibrium → Mixed Equilibrium: supports model (evidence: `src/flahax/fertilizer_equilibrium.py`)
- Acid Selection → Aqueous Model: evaluates dose (evidence: `src/flahax/acid_selection.py`)
- Equilibrium Delivery → Product Conversion: converts recipe (evidence: `src/flahax/equilibrium_delivery.py`)
- Equilibrium Delivery → Unit Quantities: uses units (evidence: `src/flahax/equilibrium_delivery.py`)
- Equilibrium Delivery → Delivery Contracts: validates records (evidence: `src/flahax/equilibrium_delivery.py`)
- Stock Planning → Unit Quantities: uses quantities (evidence: `src/flahax/stock_planning.py`)
- Fertilizer Workflow → Equilibrium Delivery: composes plan (evidence: `src/flahax/fertilizer_workflow.py`)
- Irrigation EC → Aqueous Model: uses speciation (evidence: `src/flahax/irrigation_ec.py`)
- Irrigation EC → Product Conversion: converts doses (evidence: `src/flahax/irrigation_ec.py`)
- EC Screening → Stock Planning: screens products (evidence: `src/flahax/conductivity.py`)
- EC Screening → Unit Quantities: uses units (evidence: `src/flahax/conductivity.py`)
- EC Screening → Pump Sizing: uses sizing (evidence: `src/flahax/conductivity.py`)
- Fertilizer Workflow → Delivery Contracts: validates inputs (evidence: `src/flahax/fertilizer_workflow.py`)
