# ruminantfarmsystems/rufas architecture

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

- Interactive diagram: https://gitdiagram.com/ruminantfarmsystems/rufas
- Repository: https://github.com/ruminantfarmsystems/rufas

## Overview

RuFaS is a whole-farm dairy production and environmental-impact simulator. A user runs a simulation; its engine loads inputs, advances time, and coordinates animal, field/crop, feed, and manure models, with emissions and energy accounting and collected outputs. The graph preserves those major domain stages plus weather and the shared input/output layer. Some subsystems are represented by their exact directory because their implementations were not excerpted; their internal wiring is therefore not asserted.

Main entry points: [`RUFAS/simulation_engine.py`](https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/simulation_engine.py) (Simulation engine), [`RUFAS/biophysical/field/manager/field_manager.py`](https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/biophysical/field/manager/field_manager.py) (Field management), [`RUFAS/biophysical/animal/herd_manager.py`](https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/biophysical/animal/herd_manager.py) (Herd management), [`RUFAS/biophysical/feed_storage`](https://github.com/ruminantfarmsystems/rufas/tree/dev/RUFAS/biophysical/feed_storage) (Feed storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Simulation runtime"]
  node_engine["Simulation engine"]
  node_clock["Simulation time<br/>[rufas_time.py]"]
  node_weather["Weather inputs<br/>[weather.py]"]
end

subgraph group_farm["Farm production"]
  node_animal["Herd management<br/>[herd_manager.py]"]
  node_nutrition["Ration and nutrition"]
  node_feed["Feed storage"]
  node_field["Field management<br/>[field_manager.py]"]
  node_crop["Crop growth"]
end

subgraph group_environment["Environment and impacts"]
  node_soil["Soil processes"]
  node_manure["Manure management<br/>[manure_manager.py]"]
  node_emissions["Emissions and energy<br/>[EEE_manager.py]"]
end

subgraph group_shared["Shared data and I/O"]
  node_input["Input manager<br/>[input_manager.py]"]
  node_output["Output manager<br/>[output_manager.py]"]
  node_manure_link["Animal manure stream"]
  node_crop_feed_link["Harvest feed stream"]
  node_feed_animal_link["Feed supply stream"]
  node_manure_crop_link["Manure nutrient stream"]
  node_post["Output post-processing<br/>[output_manager.py]"]
end

node_user(("Researcher or user"))

node_user -->|"runs"| node_engine
node_engine -->|"loads inputs"| node_input
node_engine -->|"initializes time"| node_clock
node_engine -->|"runs daily routines"| node_animal
node_engine -.->|"uses weather"| node_weather
node_engine -.->|"coordinates fields"| node_field
node_engine -.->|"coordinates feed"| node_feed
node_engine -.->|"coordinates manure"| node_manure
node_engine -.->|"coordinates impacts"| node_emissions
node_engine -->|"records results"| node_output
node_animal -.->|"uses rations"| node_nutrition
node_field -.->|"manages crops"| node_crop
node_field -.->|"uses soil model"| node_soil
node_animal -.->|"produces stream"| node_manure_link
node_manure_link -.->|"supplies manure"| node_manure
node_field -.->|"transfers harvest"| node_crop_feed_link
node_crop_feed_link -.->|"supplies storage"| node_feed
node_feed -.->|"supplies feeds"| node_feed_animal_link
node_feed_animal_link -.->|"provides ration inputs"| node_animal
node_manure -.->|"provides nutrients"| node_manure_crop_link
node_manure_crop_link -.->|"supplies nutrients"| node_field
node_output -.->|"passes results"| node_post

click node_engine "https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/simulation_engine.py"
click node_clock "https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/rufas_time.py"
click node_weather "https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/weather.py"
click node_input "https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/input_manager.py"
click node_output "https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/output_manager.py"
click node_animal "https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/biophysical/animal/herd_manager.py"
click node_nutrition "https://github.com/ruminantfarmsystems/rufas/tree/dev/RUFAS/biophysical/animal/ration"
click node_feed "https://github.com/ruminantfarmsystems/rufas/tree/dev/RUFAS/biophysical/feed_storage"
click node_field "https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/biophysical/field/manager/field_manager.py"
click node_crop "https://github.com/ruminantfarmsystems/rufas/tree/dev/RUFAS/biophysical/field/crop"
click node_soil "https://github.com/ruminantfarmsystems/rufas/tree/dev/RUFAS/biophysical/field/soil"
click node_manure "https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/biophysical/manure/manure_manager.py"
click node_manure_link "https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/data_structures/animal_to_manure_connection.py"
click node_crop_feed_link "https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/data_structures/crop_soil_to_feed_storage_connection.py"
click node_feed_animal_link "https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/data_structures/feed_storage_to_animal_connection.py"
click node_manure_crop_link "https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/data_structures/manure_to_crop_soil_connection.py"
click node_emissions "https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/EEE/EEE_manager.py"
click node_post "https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/post_processing/output_manager.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_engine,node_clock,node_weather,node_user toneBlue
class node_animal,node_nutrition,node_feed,node_field,node_crop toneAmber
class node_soil,node_manure,node_emissions toneMint
class node_input,node_output,node_manure_link,node_crop_feed_link,node_feed_animal_link,node_manure_crop_link,node_post toneRose
```

## Components

### Simulation runtime

- [Simulation engine](https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/simulation_engine.py): `RUFAS/simulation_engine.py`
- [Simulation time](https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/rufas_time.py): `RUFAS/rufas_time.py`
- [Weather inputs](https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/weather.py): `RUFAS/weather.py`

### Farm production

- [Herd management](https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/biophysical/animal/herd_manager.py): `RUFAS/biophysical/animal/herd_manager.py`
- [Ration and nutrition](https://github.com/ruminantfarmsystems/rufas/tree/dev/RUFAS/biophysical/animal/ration): `RUFAS/biophysical/animal/ration`
- [Feed storage](https://github.com/ruminantfarmsystems/rufas/tree/dev/RUFAS/biophysical/feed_storage): `RUFAS/biophysical/feed_storage`
- [Field management](https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/biophysical/field/manager/field_manager.py): `RUFAS/biophysical/field/manager/field_manager.py`
- [Crop growth](https://github.com/ruminantfarmsystems/rufas/tree/dev/RUFAS/biophysical/field/crop): `RUFAS/biophysical/field/crop`

### Environment and impacts

- [Soil processes](https://github.com/ruminantfarmsystems/rufas/tree/dev/RUFAS/biophysical/field/soil): `RUFAS/biophysical/field/soil`
- [Manure management](https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/biophysical/manure/manure_manager.py): `RUFAS/biophysical/manure/manure_manager.py`
- [Emissions and energy](https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/EEE/EEE_manager.py): `RUFAS/EEE/EEE_manager.py`

### Shared data and I/O

- [Input manager](https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/input_manager.py): `RUFAS/input_manager.py`
- [Output manager](https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/output_manager.py): `RUFAS/output_manager.py`
- [Animal manure stream](https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/data_structures/animal_to_manure_connection.py): `RUFAS/data_structures/animal_to_manure_connection.py`
- [Harvest feed stream](https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/data_structures/crop_soil_to_feed_storage_connection.py): `RUFAS/data_structures/crop_soil_to_feed_storage_connection.py`
- [Feed supply stream](https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/data_structures/feed_storage_to_animal_connection.py): `RUFAS/data_structures/feed_storage_to_animal_connection.py`
- [Manure nutrient stream](https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/data_structures/manure_to_crop_soil_connection.py): `RUFAS/data_structures/manure_to_crop_soil_connection.py`
- [Output post-processing](https://github.com/ruminantfarmsystems/rufas/blob/dev/RUFAS/post_processing/output_manager.py): `RUFAS/post_processing/output_manager.py`

### Other components

- **Researcher or user**

## Connections

- Researcher or user → Simulation engine: runs (evidence: `README.md`)
- Simulation engine → Input manager: loads inputs (evidence: `RUFAS/simulation_engine.py`)
- Simulation engine → Simulation time: initializes time (evidence: `RUFAS/simulation_engine.py`)
- Simulation engine → Herd management: runs daily routines (evidence: `RUFAS/simulation_engine.py`)
- Simulation engine → Weather inputs: uses weather (evidence: `RUFAS/simulation_engine.py`)
- Simulation engine → Field management: coordinates fields (evidence: `RUFAS/simulation_engine.py`)
- Simulation engine → Feed storage: coordinates feed (evidence: `RUFAS/simulation_engine.py`)
- Simulation engine → Manure management: coordinates manure (evidence: `RUFAS/simulation_engine.py`)
- Simulation engine → Emissions and energy: coordinates impacts (evidence: `RUFAS/simulation_engine.py`)
- Simulation engine → Output manager: records results (evidence: `RUFAS/simulation_engine.py`)
- Herd management → Ration and nutrition: uses rations (evidence: `RUFAS/biophysical/animal/herd_manager.py`)
- Field management → Crop growth: manages crops (evidence: `RUFAS/biophysical/field/manager/field_manager.py`)
- Field management → Soil processes: uses soil model (evidence: `RUFAS/biophysical/field/manager/field_manager.py`)
- Herd management → Animal manure stream: produces stream (evidence: `RUFAS/biophysical/animal/herd_manager.py`)
- Animal manure stream → Manure management: supplies manure (evidence: `RUFAS/biophysical/manure/manure_manager.py`)
- Field management → Harvest feed stream: transfers harvest (evidence: `RUFAS/biophysical/field/manager/field_manager.py`)
- Harvest feed stream → Feed storage: supplies storage (evidence: `RUFAS/biophysical/feed_storage/storage.py`)
- Feed storage → Feed supply stream: supplies feeds (evidence: `RUFAS/biophysical/feed_storage/purchased_feed_storage.py`)
- Feed supply stream → Herd management: provides ration inputs (evidence: `RUFAS/biophysical/animal/herd_manager.py`)
- Manure management → Manure nutrient stream: provides nutrients (evidence: `RUFAS/biophysical/manure/manure_manager.py`)
- Manure nutrient stream → Field management: supplies nutrients (evidence: `RUFAS/biophysical/field/manager/field_manager.py`)
- Output manager → Output post-processing: passes results
