# mrgoodgreen/3dferm architecture

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

- Interactive diagram: https://gitdiagram.com/mrgoodgreen/3dferm
- Repository: https://github.com/mrgoodgreen/3dferm

## Overview

Arina’s Farm is a 3D idle-arcade farming game for Yandex Games. The player moves Arina through fields and animal or processing stations, carries products to market stalls, and collects customer coins; progression unlocks further production chains, helpers, upgrades, story chapters, and village orders. The runtime also covers localized UI, saved progress, procedural visuals and sound, and platform features such as ads and rewarded videos. The graph reflects documented capabilities and indexed imports; unsampled implementation details are not inferred.

Main entry points: [`src/game/game.ts`](https://github.com/mrgoodgreen/3dferm/blob/main/src/game/game.ts) (Game runtime), [`src/main.ts`](https://github.com/mrgoodgreen/3dferm/blob/main/src/main.ts) (Startup), [`src/game/helper.ts`](https://github.com/mrgoodgreen/3dferm/blob/main/src/game/helper.ts) (Farm helpers), [`src/render/models.ts`](https://github.com/mrgoodgreen/3dferm/blob/main/src/render/models.ts) (Procedural models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and platform"]
  node_main["Startup<br/>[main.ts]"]
  node_sdk["Platform SDK<br/>[sdk.ts]"]
  node_state["Save state<br/>[state.ts]"]
end

subgraph group_simulation["Farm simulation"]
  node_game["Game runtime<br/>[game.ts]"]
  node_data["Farm content<br/>[data.ts]"]
  node_input["Controls<br/>[input.ts]"]
  node_fields["Fields and gardens<br/>[field.ts]"]
  node_stations["Animal and craft stations<br/>[station.ts]"]
  node_shelves["Market stalls<br/>[shelf.ts]"]
  node_helpers["Farm helpers<br/>[helper.ts]"]
  node_customers["Customers and orders<br/>[customers.ts]"]
  node_effects["Game effects<br/>[effects.ts]"]
end

subgraph group_presentation["World and content"]
  node_world["Farm world<br/>[world.ts]"]
  node_stage["Scene and camera<br/>[stage.ts]"]
  node_models["Procedural models<br/>[models.ts]"]
  node_meshbuilder["Geometry builder<br/>[mb.ts]"]
  node_portraits["Character portraits<br/>[portraits.ts]"]
end

subgraph group_interface["Player interface"]
  node_ui["HUD and dialogs<br/>[ui.ts]"]
  node_i18n["Localization<br/>[i18n.ts]"]
  node_labels["World labels<br/>[labels.ts]"]
  node_audio["Procedural audio<br/>[audio.ts]"]
end

node_player(("Player"))
node_yandex{{"Yandex Games"}}
node_browser[("Browser storage")]

node_player -->|"starts game"| node_main
node_main -->|"initializes"| node_sdk
node_main -->|"sets language"| node_i18n
node_main -->|"loads save"| node_state
node_main -->|"starts runtime"| node_game
node_state -->|"backs up"| node_browser
node_state -->|"saves and loads"| node_yandex
node_game -->|"controls gameplay"| node_sdk
node_game -->|"mutes and plays"| node_audio
node_game -->|"reads definitions"| node_data
node_game -->|"updates farm"| node_fields
node_game -->|"updates production"| node_stations
node_game -->|"updates selling"| node_shelves
node_game -->|"updates helpers"| node_helpers
node_game -.->|"runs market"| node_customers
node_game -.->|"reads controls"| node_input
node_game -->|"builds scene"| node_world
node_game -->|"uses renderer"| node_stage
node_game -->|"builds characters"| node_models
node_game -->|"renders portraits"| node_portraits
node_game -.->|"updates interface"| node_ui
node_world -->|"uses model builders"| node_models
node_models -->|"builds geometry"| node_meshbuilder
node_game -->|"triggers effects"| node_effects
node_effects -->|"uses item geometry"| node_models
node_effects -->|"shows float text"| node_labels
node_ui -->|"translates text"| node_i18n
node_player -->|"provides controls"| node_input
node_player -->|"harvests crops"| node_fields
node_player -->|"feeds and collects"| node_stations
node_player -->|"stocks and sells"| node_shelves
node_customers -.->|"buy products"| node_shelves
node_helpers -->|"collects inputs"| node_fields
node_helpers -->|"delivers goods"| node_stations
node_helpers -->|"delivers goods"| node_shelves

click node_main "https://github.com/mrgoodgreen/3dferm/blob/main/src/main.ts"
click node_sdk "https://github.com/mrgoodgreen/3dferm/blob/main/src/sdk.ts"
click node_state "https://github.com/mrgoodgreen/3dferm/blob/main/src/state.ts"
click node_game "https://github.com/mrgoodgreen/3dferm/blob/main/src/game/game.ts"
click node_data "https://github.com/mrgoodgreen/3dferm/blob/main/src/data.ts"
click node_input "https://github.com/mrgoodgreen/3dferm/blob/main/src/input.ts"
click node_fields "https://github.com/mrgoodgreen/3dferm/blob/main/src/game/field.ts"
click node_stations "https://github.com/mrgoodgreen/3dferm/blob/main/src/game/station.ts"
click node_shelves "https://github.com/mrgoodgreen/3dferm/blob/main/src/game/shelf.ts"
click node_helpers "https://github.com/mrgoodgreen/3dferm/blob/main/src/game/helper.ts"
click node_customers "https://github.com/mrgoodgreen/3dferm/blob/main/src/game/customers.ts"
click node_effects "https://github.com/mrgoodgreen/3dferm/blob/main/src/game/effects.ts"
click node_world "https://github.com/mrgoodgreen/3dferm/blob/main/src/render/world.ts"
click node_stage "https://github.com/mrgoodgreen/3dferm/blob/main/src/render/stage.ts"
click node_models "https://github.com/mrgoodgreen/3dferm/blob/main/src/render/models.ts"
click node_meshbuilder "https://github.com/mrgoodgreen/3dferm/blob/main/src/render/mb.ts"
click node_portraits "https://github.com/mrgoodgreen/3dferm/blob/main/src/render/portraits.ts"
click node_ui "https://github.com/mrgoodgreen/3dferm/blob/main/src/ui/ui.ts"
click node_i18n "https://github.com/mrgoodgreen/3dferm/blob/main/src/i18n.ts"
click node_labels "https://github.com/mrgoodgreen/3dferm/blob/main/src/game/labels.ts"
click node_audio "https://github.com/mrgoodgreen/3dferm/blob/main/src/audio.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_main,node_sdk,node_state toneBlue
class node_game,node_data,node_input,node_fields,node_stations,node_shelves,node_helpers,node_customers,node_effects,node_browser toneAmber
class node_world,node_stage,node_models,node_meshbuilder,node_portraits toneMint
class node_ui,node_i18n,node_labels,node_audio toneRose
class node_player,node_yandex toneIndigo
```

## Components

### Runtime and platform

- [Startup](https://github.com/mrgoodgreen/3dferm/blob/main/src/main.ts): `src/main.ts`
- [Platform SDK](https://github.com/mrgoodgreen/3dferm/blob/main/src/sdk.ts): `src/sdk.ts`
- [Save state](https://github.com/mrgoodgreen/3dferm/blob/main/src/state.ts): `src/state.ts`

### Farm simulation

- [Game runtime](https://github.com/mrgoodgreen/3dferm/blob/main/src/game/game.ts): `src/game/game.ts`
- [Farm content](https://github.com/mrgoodgreen/3dferm/blob/main/src/data.ts): `src/data.ts`
- [Controls](https://github.com/mrgoodgreen/3dferm/blob/main/src/input.ts): `src/input.ts`
- [Fields and gardens](https://github.com/mrgoodgreen/3dferm/blob/main/src/game/field.ts): `src/game/field.ts`
- [Animal and craft stations](https://github.com/mrgoodgreen/3dferm/blob/main/src/game/station.ts): `src/game/station.ts`
- [Market stalls](https://github.com/mrgoodgreen/3dferm/blob/main/src/game/shelf.ts): `src/game/shelf.ts`
- [Farm helpers](https://github.com/mrgoodgreen/3dferm/blob/main/src/game/helper.ts): `src/game/helper.ts`
- [Customers and orders](https://github.com/mrgoodgreen/3dferm/blob/main/src/game/customers.ts): `src/game/customers.ts`
- [Game effects](https://github.com/mrgoodgreen/3dferm/blob/main/src/game/effects.ts): `src/game/effects.ts`

### World and content

- [Farm world](https://github.com/mrgoodgreen/3dferm/blob/main/src/render/world.ts): `src/render/world.ts`
- [Scene and camera](https://github.com/mrgoodgreen/3dferm/blob/main/src/render/stage.ts): `src/render/stage.ts`
- [Procedural models](https://github.com/mrgoodgreen/3dferm/blob/main/src/render/models.ts): `src/render/models.ts`
- [Geometry builder](https://github.com/mrgoodgreen/3dferm/blob/main/src/render/mb.ts): `src/render/mb.ts`
- [Character portraits](https://github.com/mrgoodgreen/3dferm/blob/main/src/render/portraits.ts): `src/render/portraits.ts`

### Player interface

- [HUD and dialogs](https://github.com/mrgoodgreen/3dferm/blob/main/src/ui/ui.ts): `src/ui/ui.ts`
- [Localization](https://github.com/mrgoodgreen/3dferm/blob/main/src/i18n.ts): `src/i18n.ts`
- [World labels](https://github.com/mrgoodgreen/3dferm/blob/main/src/game/labels.ts): `src/game/labels.ts`
- [Procedural audio](https://github.com/mrgoodgreen/3dferm/blob/main/src/audio.ts): `src/audio.ts`

### Other components

- **Player**
- **Yandex Games**
- **Browser storage**

## Connections

- Player → Startup: starts game (evidence: `README.md`)
- Startup → Platform SDK: initializes (evidence: `README.md`)
- Startup → Localization: sets language (evidence: `README.md`)
- Startup → Save state: loads save (evidence: `README.md`)
- Startup → Game runtime: starts runtime (evidence: `README.md`)
- Save state → Browser storage: backs up (evidence: `README.md`)
- Save state → Yandex Games: saves and loads (evidence: `README.md`)
- Game runtime → Platform SDK: controls gameplay (evidence: `src/game/game.ts`)
- Game runtime → Procedural audio: mutes and plays (evidence: `src/game/game.ts`)
- Game runtime → Farm content: reads definitions (evidence: `src/game/game.ts`)
- Game runtime → Fields and gardens: updates farm (evidence: `src/game/game.ts`)
- Game runtime → Animal and craft stations: updates production (evidence: `src/game/game.ts`)
- Game runtime → Market stalls: updates selling (evidence: `src/game/game.ts`)
- Game runtime → Farm helpers: updates helpers (evidence: `src/game/game.ts`)
- Game runtime → Customers and orders: runs market (evidence: `src/game/game.ts`)
- Game runtime → Controls: reads controls (evidence: `src/game/game.ts`)
- Game runtime → Farm world: builds scene (evidence: `src/game/game.ts`)
- Game runtime → Scene and camera: uses renderer (evidence: `src/game/game.ts`)
- Game runtime → Procedural models: builds characters (evidence: `src/game/game.ts`)
- Game runtime → Character portraits: renders portraits (evidence: `src/game/game.ts`)
- Game runtime → HUD and dialogs: updates interface (evidence: `src/game/game.ts`)
- Farm world → Procedural models: uses model builders (evidence: `src/render/world.ts`)
- Procedural models → Geometry builder: builds geometry (evidence: `src/render/models.ts`)
- Game runtime → Game effects: triggers effects (evidence: `src/game/game.ts`)
- Game effects → Procedural models: uses item geometry (evidence: `src/game/effects.ts`)
- Game effects → World labels: shows float text (evidence: `src/game/effects.ts`)
- HUD and dialogs → Localization: translates text (evidence: `README.md`)
- Player → Controls: provides controls (evidence: `README.md`)
- Player → Fields and gardens: harvests crops (evidence: `README.md`)
- Player → Animal and craft stations: feeds and collects (evidence: `README.md`)
- Player → Market stalls: stocks and sells (evidence: `README.md`)
- Customers and orders → Market stalls: buy products (evidence: `src/game/customers.ts`)
- Farm helpers → Fields and gardens: collects inputs (evidence: `src/game/helper.ts`)
- Farm helpers → Animal and craft stations: delivers goods (evidence: `src/game/helper.ts`)
- Farm helpers → Market stalls: delivers goods (evidence: `src/game/helper.ts`)
