# soumyak4/shan-shui-infinite architecture

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

- Interactive diagram: https://gitdiagram.com/soumyak4/shan-shui-infinite
- Repository: https://github.com/soumyak4/shan-shui-infinite

## Overview

Shan Shui is a browser-based, seed-driven landscape generator. Users navigate an endless landscape, adjust or share its seed, and export the current view as SVG. The main flow runs from navigation and seed controls through scene preparation to landscape generation and display; a worker and preview caches support smooth scrolling. The README documents the major capabilities, while source excerpts show the app and renderer boundary. Several internal generation and export details are unsampled, so those relationships are not expanded beyond documented behavior.

Main entry points: [`scripts/app.js`](https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/app.js) (App controller), [`scripts/landscape.js`](https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/landscape.js) (Procedural generator), [`index.html`](https://github.com/soumyak4/shan-shui-infinite/blob/master/index.html) (Navigation controls)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Navigation and settings"]
  node_controls["Navigation controls<br/>[index.html]"]
  node_app["App controller<br/>[app.js]"]
  node_auto["Auto-scroll<br/>[app.js]"]
end

subgraph group_rendering["Scene rendering"]
  node_scene["Scene preparation<br/>[app.js]"]
  node_preview[("Preview cache<br/>[app.js]")]
  node_display["Viewport display<br/>[app.js]"]
end

subgraph group_generation["Landscape generation"]
  node_renderer["Renderer service<br/>[landscape.js]"]
  node_worker["Drawing worker<br/>[landscape.js]"]
  node_generator["Procedural generator<br/>[landscape.js]"]
  node_mountains["Mountains and terrain<br/>[landscape.js]"]
  node_vegetation["Trees and foliage<br/>[landscape.js]"]
  node_structures["Buildings and boats<br/>[landscape.js]"]
end

subgraph group_output["Sharing and export"]
  node_seed["Seed and URL<br/>[app.js]"]
  node_svg["SVG export<br/>[app.js]"]
end

node_visitor(("Visitor"))

node_visitor -->|"navigates and configures"| node_controls
node_controls -->|"provides input"| node_app
node_app -->|"requests scenes"| node_renderer
node_app -->|"prepares scenes"| node_scene
node_scene -->|"caches chunks"| node_preview
node_scene -->|"presents scenes"| node_display
node_app -->|"starts and pauses"| node_auto
node_auto -->|"advances position"| node_app
node_app -->|"reads and updates"| node_seed
node_app -->|"downloads current view"| node_svg
node_renderer -->|"dispatches drawing"| node_worker
node_generator -.->|"generates terrain"| node_mountains
node_generator -.->|"generates vegetation"| node_vegetation
node_generator -.->|"generates structures"| node_structures

click node_controls "https://github.com/soumyak4/shan-shui-infinite/blob/master/index.html"
click node_app "https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/app.js"
click node_auto "https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/app.js"
click node_seed "https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/app.js"
click node_scene "https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/app.js"
click node_preview "https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/app.js"
click node_display "https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/app.js"
click node_renderer "https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/landscape.js"
click node_worker "https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/landscape.js"
click node_generator "https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/landscape.js"
click node_mountains "https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/landscape.js"
click node_vegetation "https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/landscape.js"
click node_structures "https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/landscape.js"
click node_svg "https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/app.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_controls,node_app,node_auto toneBlue
class node_scene,node_preview,node_display toneAmber
class node_renderer,node_worker,node_generator,node_mountains,node_vegetation,node_structures toneMint
class node_seed,node_svg toneRose
class node_visitor toneIndigo
```

## Components

### Navigation and settings

- [Navigation controls](https://github.com/soumyak4/shan-shui-infinite/blob/master/index.html): `index.html`
- [App controller](https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/app.js): `scripts/app.js`
- [Auto-scroll](https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/app.js): `scripts/app.js`

### Scene rendering

- [Scene preparation](https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/app.js): `scripts/app.js`
- [Preview cache](https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/app.js): `scripts/app.js`
- [Viewport display](https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/app.js): `scripts/app.js`

### Landscape generation

- [Renderer service](https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/landscape.js): `scripts/landscape.js`
- [Drawing worker](https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/landscape.js): `scripts/landscape.js`
- [Procedural generator](https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/landscape.js): `scripts/landscape.js`
- [Mountains and terrain](https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/landscape.js): `scripts/landscape.js`
- [Trees and foliage](https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/landscape.js): `scripts/landscape.js`
- [Buildings and boats](https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/landscape.js): `scripts/landscape.js`

### Sharing and export

- [Seed and URL](https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/app.js): `scripts/app.js`
- [SVG export](https://github.com/soumyak4/shan-shui-infinite/blob/master/scripts/app.js): `scripts/app.js`

### Other components

- **Visitor**

## Connections

- Visitor → Navigation controls: navigates and configures (evidence: `README.md`)
- Navigation controls → App controller: provides input (evidence: `scripts/app.js`)
- App controller → Renderer service: requests scenes (evidence: `scripts/app.js`)
- App controller → Scene preparation: prepares scenes (evidence: `scripts/app.js`)
- Scene preparation → Preview cache: caches chunks (evidence: `scripts/app.js`)
- Scene preparation → Viewport display: presents scenes (evidence: `scripts/app.js`)
- App controller → Auto-scroll: starts and pauses (evidence: `scripts/app.js`)
- Auto-scroll → App controller: advances position (evidence: `scripts/app.js`)
- App controller → Seed and URL: reads and updates (evidence: `scripts/app.js`)
- App controller → SVG export: downloads current view (evidence: `README.md`)
- Renderer service → Drawing worker: dispatches drawing (evidence: `scripts/landscape.js`)
- Procedural generator → Mountains and terrain: generates terrain (evidence: `README.md`)
- Procedural generator → Trees and foliage: generates vegetation (evidence: `README.md`)
- Procedural generator → Buildings and boats: generates structures (evidence: `README.md`)
