# horrid-12/agrosorb architecture

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

- Interactive diagram: https://gitdiagram.com/horrid-12/agrosorb
- Repository: https://github.com/horrid-12/agrosorb

## Overview

AgroSorb is an educational runoff-treatment simulator. Users enter the simulation, configure rainfall and filter media, run the treatment sequence, then inspect water-quality results or compare saved experiments; learning content and a 3D farm scene support that workflow. The graph preserves documented scenario, fallback, and visualization capabilities. Relationships are limited to shown imports/calls and README statements; unsampled implementation details are not inferred.

Main entry points: [`src/stores/simulationStore.ts`](https://github.com/horrid-12/agrosorb/blob/main/src/stores/simulationStore.ts) (Simulation state), [`src/pages/SimulationPage.tsx`](https://github.com/horrid-12/agrosorb/blob/main/src/pages/SimulationPage.tsx) (Simulation workspace), [`src/scenes/AgriculturalScene.tsx`](https://github.com/horrid-12/agrosorb/blob/main/src/scenes/AgriculturalScene.tsx) (3D farm scene), [`src/simulation/engine/filtrationEngine.ts`](https://github.com/horrid-12/agrosorb/blob/main/src/simulation/engine/filtrationEngine.ts) (Filtration model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User Experience"]
  node_app["View switcher<br/>[App.tsx]"]
  node_landing["Landing page<br/>[LandingPage.tsx]"]
  node_simpage["Simulation workspace<br/>[SimulationPage.tsx]"]
  node_controls["Weather controls"]
  node_configurator["Filter configurator"]
  node_results["Results dashboard"]
end

subgraph group_simulation["Simulation Core"]
  node_store[("Simulation state<br/>[simulationStore.ts]")]
  node_engine["Filtration model"]
  node_metrics["Results metrics<br/>[metrics.ts]"]
end

subgraph group_experiments["Experiments &amp; Learning"]
  node_experiments["Experiment lab"]
  node_learning["Learning panel<br/>[LearningPanel.tsx]"]
end

subgraph group_visualization["Farm Visualization"]
  node_scene["3D farm scene"]
  node_station["Filter station"]
  node_farm["Farm environment"]
  node_fallback["2D scene fallback<br/>[SceneFallback.tsx]"]
end

subgraph group_domain["Domain Data"]
  node_scenarios["Challenge scenarios<br/>[scenarios.ts]"]
  node_education["Educational content<br/>[educational.ts]"]
  node_materials["Filter materials<br/>[materials.ts]"]
  node_constants["Model constants<br/>[constants.ts]"]
  node_types["Domain types<br/>[index.ts]"]
end

node_user(("Simulator user"))

node_user -->|"opens"| node_app
node_app -->|"shows"| node_landing
node_app -->|"switches to"| node_simpage
node_landing -->|"starts"| node_simpage
node_simpage -->|"renders"| node_controls
node_simpage -->|"renders"| node_configurator
node_simpage -->|"opens"| node_results
node_simpage -->|"opens"| node_experiments
node_simpage -->|"opens"| node_learning
node_simpage -->|"renders"| node_scene
node_simpage -->|"shows on failure"| node_fallback
node_controls -->|"updates"| node_store
node_configurator -->|"updates"| node_store
node_store -->|"validates configuration"| node_engine
node_store -->|"evaluates objectives"| node_metrics
node_results -->|"reads results"| node_store
node_results -->|"runs model"| node_engine
node_experiments -->|"reads and saves"| node_store
node_experiments -->|"reads scenarios"| node_scenarios
node_learning -->|"displays content"| node_education
node_scene -->|"reads state"| node_store
node_scene -->|"renders"| node_station
node_scene -->|"renders"| node_farm
node_scene -->|"advances treatment"| node_store
node_fallback -->|"reads state"| node_store
node_engine -->|"uses parameters"| node_constants
node_engine -->|"uses material data"| node_materials
node_metrics -->|"gets storm baseline"| node_engine
node_store -->|"uses limits and stages"| node_constants
node_store -->|"loads scenario settings"| node_scenarios
node_store -->|"evaluates saved result"| node_metrics

click node_app "https://github.com/horrid-12/agrosorb/blob/main/src/App.tsx"
click node_landing "https://github.com/horrid-12/agrosorb/blob/main/src/pages/LandingPage.tsx"
click node_simpage "https://github.com/horrid-12/agrosorb/blob/main/src/pages/SimulationPage.tsx"
click node_controls "https://github.com/horrid-12/agrosorb/blob/main/src/components/simulation/SimulationControls.tsx"
click node_configurator "https://github.com/horrid-12/agrosorb/blob/main/src/components/simulation/FilterConfigurator.tsx"
click node_store "https://github.com/horrid-12/agrosorb/blob/main/src/stores/simulationStore.ts"
click node_engine "https://github.com/horrid-12/agrosorb/blob/main/src/simulation/engine/filtrationEngine.ts"
click node_metrics "https://github.com/horrid-12/agrosorb/blob/main/src/simulation/calculations/metrics.ts"
click node_results "https://github.com/horrid-12/agrosorb/blob/main/src/components/dashboard/ResultsDashboard.tsx"
click node_experiments "https://github.com/horrid-12/agrosorb/blob/main/src/components/experiments/ExperimentsPanel.tsx"
click node_scenarios "https://github.com/horrid-12/agrosorb/blob/main/src/data/scenarios.ts"
click node_learning "https://github.com/horrid-12/agrosorb/blob/main/src/components/learn/LearningPanel.tsx"
click node_education "https://github.com/horrid-12/agrosorb/blob/main/src/data/educational.ts"
click node_scene "https://github.com/horrid-12/agrosorb/blob/main/src/scenes/AgriculturalScene.tsx"
click node_station "https://github.com/horrid-12/agrosorb/blob/main/src/components/environment/FiltrationStation.tsx"
click node_farm "https://github.com/horrid-12/agrosorb/tree/main/src/components/environment"
click node_fallback "https://github.com/horrid-12/agrosorb/blob/main/src/components/SceneFallback.tsx"
click node_materials "https://github.com/horrid-12/agrosorb/blob/main/src/data/materials.ts"
click node_constants "https://github.com/horrid-12/agrosorb/blob/main/src/simulation/models/constants.ts"
click node_types "https://github.com/horrid-12/agrosorb/blob/main/src/types/index.ts"

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_landing,node_simpage,node_controls,node_configurator,node_results,node_user toneBlue
class node_store,node_engine,node_metrics toneAmber
class node_experiments,node_learning toneMint
class node_scene,node_station,node_farm,node_fallback toneRose
class node_scenarios,node_education,node_materials,node_constants,node_types toneIndigo
```

## Components

### User Experience

- [View switcher](https://github.com/horrid-12/agrosorb/blob/main/src/App.tsx): `src/App.tsx`
- [Landing page](https://github.com/horrid-12/agrosorb/blob/main/src/pages/LandingPage.tsx): `src/pages/LandingPage.tsx`
- [Simulation workspace](https://github.com/horrid-12/agrosorb/blob/main/src/pages/SimulationPage.tsx): `src/pages/SimulationPage.tsx`
- [Weather controls](https://github.com/horrid-12/agrosorb/blob/main/src/components/simulation/SimulationControls.tsx): `src/components/simulation/SimulationControls.tsx`
- [Filter configurator](https://github.com/horrid-12/agrosorb/blob/main/src/components/simulation/FilterConfigurator.tsx): `src/components/simulation/FilterConfigurator.tsx`
- [Results dashboard](https://github.com/horrid-12/agrosorb/blob/main/src/components/dashboard/ResultsDashboard.tsx): `src/components/dashboard/ResultsDashboard.tsx`

### Simulation Core

- [Simulation state](https://github.com/horrid-12/agrosorb/blob/main/src/stores/simulationStore.ts): `src/stores/simulationStore.ts`
- [Filtration model](https://github.com/horrid-12/agrosorb/blob/main/src/simulation/engine/filtrationEngine.ts): `src/simulation/engine/filtrationEngine.ts`
- [Results metrics](https://github.com/horrid-12/agrosorb/blob/main/src/simulation/calculations/metrics.ts): `src/simulation/calculations/metrics.ts`

### Experiments & Learning

- [Experiment lab](https://github.com/horrid-12/agrosorb/blob/main/src/components/experiments/ExperimentsPanel.tsx): `src/components/experiments/ExperimentsPanel.tsx`
- [Learning panel](https://github.com/horrid-12/agrosorb/blob/main/src/components/learn/LearningPanel.tsx): `src/components/learn/LearningPanel.tsx`

### Farm Visualization

- [3D farm scene](https://github.com/horrid-12/agrosorb/blob/main/src/scenes/AgriculturalScene.tsx): `src/scenes/AgriculturalScene.tsx`
- [Filter station](https://github.com/horrid-12/agrosorb/blob/main/src/components/environment/FiltrationStation.tsx): `src/components/environment/FiltrationStation.tsx`
- [Farm environment](https://github.com/horrid-12/agrosorb/tree/main/src/components/environment): `src/components/environment`
- [2D scene fallback](https://github.com/horrid-12/agrosorb/blob/main/src/components/SceneFallback.tsx): `src/components/SceneFallback.tsx`

### Domain Data

- [Challenge scenarios](https://github.com/horrid-12/agrosorb/blob/main/src/data/scenarios.ts): `src/data/scenarios.ts`
- [Educational content](https://github.com/horrid-12/agrosorb/blob/main/src/data/educational.ts): `src/data/educational.ts`
- [Filter materials](https://github.com/horrid-12/agrosorb/blob/main/src/data/materials.ts): `src/data/materials.ts`
- [Model constants](https://github.com/horrid-12/agrosorb/blob/main/src/simulation/models/constants.ts): `src/simulation/models/constants.ts`
- [Domain types](https://github.com/horrid-12/agrosorb/blob/main/src/types/index.ts): `src/types/index.ts`

### Other components

- **Simulator user**

## Connections

- Simulator user → View switcher: opens
- View switcher → Landing page: shows (evidence: `src/App.tsx`)
- View switcher → Simulation workspace: switches to (evidence: `src/App.tsx`)
- Landing page → Simulation workspace: starts (evidence: `src/App.tsx`)
- Simulation workspace → Weather controls: renders (evidence: `src/pages/SimulationPage.tsx`)
- Simulation workspace → Filter configurator: renders (evidence: `src/pages/SimulationPage.tsx`)
- Simulation workspace → Results dashboard: opens (evidence: `src/pages/SimulationPage.tsx`)
- Simulation workspace → Experiment lab: opens (evidence: `src/pages/SimulationPage.tsx`)
- Simulation workspace → Learning panel: opens (evidence: `src/pages/SimulationPage.tsx`)
- Simulation workspace → 3D farm scene: renders (evidence: `src/pages/SimulationPage.tsx`)
- Simulation workspace → 2D scene fallback: shows on failure (evidence: `src/pages/SimulationPage.tsx`)
- Weather controls → Simulation state: updates (evidence: `src/components/simulation/SimulationControls.tsx`)
- Filter configurator → Simulation state: updates (evidence: `src/components/simulation/FilterConfigurator.tsx`)
- Simulation state → Filtration model: validates configuration (evidence: `src/stores/simulationStore.ts`)
- Simulation state → Results metrics: evaluates objectives (evidence: `src/stores/simulationStore.ts`)
- Results dashboard → Simulation state: reads results (evidence: `src/components/dashboard/ResultsDashboard.tsx`)
- Results dashboard → Filtration model: runs model (evidence: `src/components/dashboard/ResultsDashboard.tsx`)
- Experiment lab → Simulation state: reads and saves (evidence: `src/components/experiments/ExperimentsPanel.tsx`)
- Experiment lab → Challenge scenarios: reads scenarios (evidence: `src/components/experiments/ExperimentsPanel.tsx`)
- Learning panel → Educational content: displays content (evidence: `src/components/learn/LearningPanel.tsx`)
- 3D farm scene → Simulation state: reads state (evidence: `src/scenes/AgriculturalScene.tsx`)
- 3D farm scene → Filter station: renders (evidence: `src/scenes/AgriculturalScene.tsx`)
- 3D farm scene → Farm environment: renders (evidence: `src/scenes/AgriculturalScene.tsx`)
- 3D farm scene → Simulation state: advances treatment (evidence: `src/scenes/AgriculturalScene.tsx`)
- 2D scene fallback → Simulation state: reads state (evidence: `src/components/SceneFallback.tsx`)
- Filtration model → Model constants: uses parameters (evidence: `src/simulation/engine/filtrationEngine.ts`)
- Filtration model → Filter materials: uses material data (evidence: `src/simulation/engine/filtrationEngine.ts`)
- Results metrics → Filtration model: gets storm baseline (evidence: `src/simulation/calculations/metrics.ts`)
- Simulation state → Model constants: uses limits and stages (evidence: `src/stores/simulationStore.ts`)
- Simulation state → Challenge scenarios: loads scenario settings (evidence: `src/stores/simulationStore.ts`)
- Simulation state → Results metrics: evaluates saved result (evidence: `src/stores/simulationStore.ts`)
