# erenelagz/farm-simulator-game architecture

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

- Interactive diagram: https://gitdiagram.com/erenelagz/farm-simulator-game
- Repository: https://github.com/erenelagz/farm-simulator-game

## Overview

This is a browser-based, turn-based farm-management game. The player manages livestock, crops, products, and supplies; each week prices fluctuate, production and consumption update the farm, and the interface displays inventory, prices, and statistics. The marketplace supports buying and selling farm goods and supplies. The supplied source shows these responsibilities, but not the HTML wiring that binds page controls to JavaScript functions; that connection is therefore left unverified.

Main entry points: [`src/js/functions.js`](https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/functions.js) (Week controller), [`src/js/objects.js`](https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/objects.js) (Farm and assets), [`src/js/ui.js`](https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/ui.js) (DOM bindings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_farm_state["Farm state"]
  node_farm_model["Farm and assets<br/>[objects.js]"]
end

subgraph group_weekly_turn["Weekly turn"]
  node_weekly_pricing["Price updates<br/>[functions.js]"]
  node_weekly_production["Goods production<br/>[functions.js]"]
  node_weekly_consumption["Resource consumption<br/>[functions.js]"]
  node_week_controller["Week controller<br/>[functions.js]"]
end

subgraph group_market["Marketplace"]
  node_farm_market["Farm marketplace<br/>[functions.js]"]
  node_supply_market["Supply supermarket<br/>[functions.js]"]
end

subgraph group_presentation["Game interface"]
  node_display["Farm display<br/>[functions.js]"]
  node_display_reset["Display reset<br/>[functions.js]"]
  node_dom_bindings["DOM bindings<br/>[ui.js]"]
end

node_player(("Player"))

node_player -.->|"uses controls"| node_dom_bindings
node_dom_bindings -.->|"triggers next week"| node_week_controller
node_week_controller -->|"updates prices"| node_weekly_pricing
node_week_controller -->|"produces goods"| node_weekly_production
node_week_controller -->|"consumes supplies"| node_weekly_consumption
node_week_controller -->|"clears display"| node_display_reset
node_week_controller -->|"renders farm"| node_display
node_weekly_pricing -->|"updates prices"| node_farm_model
node_weekly_production -->|"adds goods"| node_farm_model
node_weekly_consumption -->|"deducts supplies"| node_farm_model
node_farm_market -->|"trades farm goods"| node_farm_model
node_supply_market -->|"trades supplies"| node_farm_model
node_farm_market -->|"clears display"| node_display_reset
node_farm_market -->|"refreshes display"| node_display
node_supply_market -->|"clears display"| node_display_reset
node_supply_market -->|"refreshes display"| node_display
node_display -->|"reads farm state"| node_farm_model
node_display -->|"updates page"| node_dom_bindings

click node_farm_model "https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/objects.js"
click node_weekly_pricing "https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/functions.js"
click node_weekly_production "https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/functions.js"
click node_weekly_consumption "https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/functions.js"
click node_week_controller "https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/functions.js"
click node_farm_market "https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/functions.js"
click node_supply_market "https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/functions.js"
click node_display "https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/functions.js"
click node_display_reset "https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/functions.js"
click node_dom_bindings "https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/ui.js"

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_farm_model toneBlue
class node_weekly_pricing,node_weekly_production,node_weekly_consumption,node_week_controller toneAmber
class node_farm_market,node_supply_market toneMint
class node_display,node_display_reset,node_dom_bindings toneRose
class node_player toneIndigo
```

## Components

### Farm state

- [Farm and assets](https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/objects.js): `src/js/objects.js`

### Weekly turn

- [Price updates](https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/functions.js): `src/js/functions.js`
- [Goods production](https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/functions.js): `src/js/functions.js`
- [Resource consumption](https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/functions.js): `src/js/functions.js`
- [Week controller](https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/functions.js): `src/js/functions.js`

### Marketplace

- [Farm marketplace](https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/functions.js): `src/js/functions.js`
- [Supply supermarket](https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/functions.js): `src/js/functions.js`

### Game interface

- [Farm display](https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/functions.js): `src/js/functions.js`
- [Display reset](https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/functions.js): `src/js/functions.js`
- [DOM bindings](https://github.com/erenelagz/farm-simulator-game/blob/main/src/js/ui.js): `src/js/ui.js`

### Other components

- **Player**

## Connections

- Player → DOM bindings: uses controls (evidence: `README.md`)
- DOM bindings → Week controller: triggers next week
- Week controller → Price updates: updates prices (evidence: `src/js/functions.js`)
- Week controller → Goods production: produces goods (evidence: `src/js/functions.js`)
- Week controller → Resource consumption: consumes supplies (evidence: `src/js/functions.js`)
- Week controller → Display reset: clears display (evidence: `src/js/functions.js`)
- Week controller → Farm display: renders farm (evidence: `src/js/functions.js`)
- Price updates → Farm and assets: updates prices (evidence: `src/js/functions.js`)
- Goods production → Farm and assets: adds goods (evidence: `src/js/functions.js`)
- Resource consumption → Farm and assets: deducts supplies (evidence: `src/js/functions.js`)
- Farm marketplace → Farm and assets: trades farm goods (evidence: `src/js/functions.js`)
- Supply supermarket → Farm and assets: trades supplies (evidence: `src/js/functions.js`)
- Farm marketplace → Display reset: clears display (evidence: `src/js/functions.js`)
- Farm marketplace → Farm display: refreshes display (evidence: `src/js/functions.js`)
- Supply supermarket → Display reset: clears display (evidence: `src/js/functions.js`)
- Supply supermarket → Farm display: refreshes display (evidence: `src/js/functions.js`)
- Farm display → Farm and assets: reads farm state (evidence: `src/js/functions.js`)
- Farm display → DOM bindings: updates page (evidence: `src/js/functions.js`)
