# mariuszostrowski/rain architecture

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

- Interactive diagram: https://gitdiagram.com/mariuszostrowski/rain
- Repository: https://github.com/mariuszostrowski/rain

## Overview

Rain is a native macOS screen saver that procedurally renders a rainy night in real time with Metal. The screen-saver host activates RainView, which creates a RainRenderer; the renderer combines a selected world with glass-drop simulation, atmospheric effects and compositing to produce each frame. Users can configure the scene, clock and rain intensity through the options sheet. The README documents six distinct worlds, photo backgrounds for Street, multi-display operation and visual effects. Some renderer-to-world wiring and shader calls are not visible in the excerpts, so those links are marked unverified.

Main entry points: [`rain/RainRenderer.swift`](https://github.com/mariuszostrowski/rain/blob/main/rain/RainRenderer.swift) (Frame renderer), [`rain/RainView.swift`](https://github.com/mariuszostrowski/rain/blob/main/rain/RainView.swift) (Saver view), [`rain/RainOptions.swift`](https://github.com/mariuszostrowski/rain/blob/main/rain/RainOptions.swift) (Options sheet), [`rain/BokehField.swift`](https://github.com/mariuszostrowski/rain/blob/main/rain/BokehField.swift) (Street world)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Screen saver"]
  node_hostapp["Screen saver host"]
  node_view["Saver view<br/>[RainView.swift]"]
end

subgraph group_settings["Options"]
  node_options["Options sheet<br/>[RainOptions.swift]"]
  node_preferences[("ScreenSaverDefaults")]
end

subgraph group_worlds["Night worlds"]
  node_bokeh["Street bokeh<br/>[BokehField.swift]"]
  node_sceneprotocol["Scene interface<br/>[SceneWorld.swift]"]
  node_street["Street world<br/>[BokehField.swift]"]
  node_river["River world<br/>[RiverWorld.swift]"]
  node_tokyo["Tokyo world<br/>[TokyoWorld.swift]"]
  node_towers["Skyscraper world<br/>[TowersWorld.swift]"]
  node_landing["Landing world<br/>[LandingWorld.swift]"]
  node_airport["Airport world<br/>[AirportWorld.swift]"]
end

subgraph group_rendering["Rendering effects"]
  node_renderer["Frame renderer<br/>[RainRenderer.swift]"]
  node_drops["Glass drop simulation"]
  node_clock["Neon clock<br/>[NeonClock.swift]"]
  node_shaders["Metal shaders<br/>[Shaders.metal]"]
end

node_user(("User"))

node_hostapp -->|"hosts"| node_view
node_user -->|"starts saver"| node_view
node_user -->|"chooses settings"| node_options
node_view -->|"creates and drives"| node_renderer
node_view -->|"opens sheet"| node_options
node_options -->|"reads and stores"| node_preferences
node_options -->|"notifies changes"| node_view
node_renderer -.->|"updates simulation"| node_drops
node_renderer -.->|"uses scene contract"| node_sceneprotocol
node_renderer -.->|"updates clock"| node_clock
node_renderer -.->|"renders with"| node_shaders
node_renderer -.->|"selects world"| node_street
node_renderer -.->|"selects world"| node_river
node_renderer -.->|"selects world"| node_tokyo
node_renderer -.->|"selects world"| node_towers
node_renderer -.->|"selects world"| node_landing
node_renderer -.->|"selects world"| node_airport
node_street -.->|"produces lights"| node_bokeh

click node_view "https://github.com/mariuszostrowski/rain/blob/main/rain/RainView.swift"
click node_options "https://github.com/mariuszostrowski/rain/blob/main/rain/RainOptions.swift"
click node_renderer "https://github.com/mariuszostrowski/rain/blob/main/rain/RainRenderer.swift"
click node_drops "https://github.com/mariuszostrowski/rain/blob/main/rain/DropSimulation.swift"
click node_bokeh "https://github.com/mariuszostrowski/rain/blob/main/rain/BokehField.swift"
click node_sceneprotocol "https://github.com/mariuszostrowski/rain/blob/main/rain/SceneWorld.swift"
click node_street "https://github.com/mariuszostrowski/rain/blob/main/rain/BokehField.swift"
click node_river "https://github.com/mariuszostrowski/rain/blob/main/rain/RiverWorld.swift"
click node_tokyo "https://github.com/mariuszostrowski/rain/blob/main/rain/TokyoWorld.swift"
click node_towers "https://github.com/mariuszostrowski/rain/blob/main/rain/TowersWorld.swift"
click node_landing "https://github.com/mariuszostrowski/rain/blob/main/rain/LandingWorld.swift"
click node_airport "https://github.com/mariuszostrowski/rain/blob/main/rain/AirportWorld.swift"
click node_clock "https://github.com/mariuszostrowski/rain/blob/main/rain/NeonClock.swift"
click node_shaders "https://github.com/mariuszostrowski/rain/blob/main/rain/Shaders.metal"

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_hostapp,node_view,node_user toneBlue
class node_options,node_preferences toneAmber
class node_bokeh,node_sceneprotocol,node_street,node_river,node_tokyo,node_towers,node_landing,node_airport toneMint
class node_renderer,node_drops,node_clock,node_shaders toneRose
```

## Components

### Screen saver

- **Screen saver host**
- [Saver view](https://github.com/mariuszostrowski/rain/blob/main/rain/RainView.swift): `rain/RainView.swift`

### Options

- [Options sheet](https://github.com/mariuszostrowski/rain/blob/main/rain/RainOptions.swift): `rain/RainOptions.swift`
- **ScreenSaverDefaults**

### Night worlds

- [Street bokeh](https://github.com/mariuszostrowski/rain/blob/main/rain/BokehField.swift): `rain/BokehField.swift`
- [Scene interface](https://github.com/mariuszostrowski/rain/blob/main/rain/SceneWorld.swift): `rain/SceneWorld.swift`
- [Street world](https://github.com/mariuszostrowski/rain/blob/main/rain/BokehField.swift): `rain/BokehField.swift`
- [River world](https://github.com/mariuszostrowski/rain/blob/main/rain/RiverWorld.swift): `rain/RiverWorld.swift`
- [Tokyo world](https://github.com/mariuszostrowski/rain/blob/main/rain/TokyoWorld.swift): `rain/TokyoWorld.swift`
- [Skyscraper world](https://github.com/mariuszostrowski/rain/blob/main/rain/TowersWorld.swift): `rain/TowersWorld.swift`
- [Landing world](https://github.com/mariuszostrowski/rain/blob/main/rain/LandingWorld.swift): `rain/LandingWorld.swift`
- [Airport world](https://github.com/mariuszostrowski/rain/blob/main/rain/AirportWorld.swift): `rain/AirportWorld.swift`

### Rendering effects

- [Frame renderer](https://github.com/mariuszostrowski/rain/blob/main/rain/RainRenderer.swift): `rain/RainRenderer.swift`
- [Glass drop simulation](https://github.com/mariuszostrowski/rain/blob/main/rain/DropSimulation.swift): `rain/DropSimulation.swift`
- [Neon clock](https://github.com/mariuszostrowski/rain/blob/main/rain/NeonClock.swift): `rain/NeonClock.swift`
- [Metal shaders](https://github.com/mariuszostrowski/rain/blob/main/rain/Shaders.metal): `rain/Shaders.metal`

### Other components

- **User**

## Connections

- Screen saver host → Saver view: hosts (evidence: `rain/RainView.swift`)
- User → Saver view: starts saver (evidence: `README.md`)
- User → Options sheet: chooses settings (evidence: `README.md`)
- Saver view → Frame renderer: creates and drives (evidence: `rain/RainView.swift`)
- Saver view → Options sheet: opens sheet (evidence: `rain/RainView.swift`)
- Options sheet → ScreenSaverDefaults: reads and stores (evidence: `rain/RainOptions.swift`)
- Options sheet → Saver view: notifies changes (evidence: `rain/RainOptions.swift`)
- Frame renderer → Glass drop simulation: updates simulation (evidence: `rain/RainRenderer.swift`)
- Frame renderer → Scene interface: uses scene contract (evidence: `rain/RainRenderer.swift`)
- Frame renderer → Neon clock: updates clock (evidence: `rain/RainRenderer.swift`)
- Frame renderer → Metal shaders: renders with
- Frame renderer → Street world: selects world (evidence: `rain/RainRenderer.swift`)
- Frame renderer → River world: selects world (evidence: `rain/RainRenderer.swift`)
- Frame renderer → Tokyo world: selects world (evidence: `rain/RainRenderer.swift`)
- Frame renderer → Skyscraper world: selects world (evidence: `rain/RainRenderer.swift`)
- Frame renderer → Landing world: selects world (evidence: `rain/RainRenderer.swift`)
- Frame renderer → Airport world: selects world (evidence: `rain/RainRenderer.swift`)
- Street world → Street bokeh: produces lights (evidence: `rain/BokehField.swift`)
