# armansiddiqui9/slumberbloom architecture

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

- Interactive diagram: https://gitdiagram.com/armansiddiqui9/slumberbloom
- Repository: https://github.com/armansiddiqui9/slumberbloom

## Overview

SlumberBloom is a local-first sleep-to-garden game: a player tucks in, returns after time away, claims a hashed Night Block, settles it at Dawn, verifies it with a Lantern proof, then tends the garden. The web app uses a local adapter and pure consensus engine; the C# mobile scaffold mirrors that loop with an in-device API. AI is an optional local feature, outside consensus. README documentation establishes further AI and server capabilities, but their runtime wiring is not shown in the excerpts.

Main entry points: [`packages/adapters-local/src/index.ts`](https://github.com/armansiddiqui9/slumberbloom/blob/main/packages/adapters-local/src/index.ts) (Local adapter), [`packages/engine/src/blocks/night-block.ts`](https://github.com/armansiddiqui9/slumberbloom/blob/main/packages/engine/src/blocks/night-block.ts) (Night Block minting), [`mobile-game/src/App.cs`](https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/App.cs) (Mobile flow), [`mobile-game/src/AI/IAiAgent.cs`](https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/AI/IAiAgent.cs) (Agent interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web game"]
  node_webapp["Game screens<br/>[App.tsx]"]
  node_webapi["API composition<br/>[game-api.ts]"]
end

subgraph group_local["Local game API"]
  node_localadapter["Local adapter<br/>[index.ts]"]
  node_contracts["Game contracts<br/>[index.ts]"]
  node_webstate[("Local game state<br/>[index.ts]")]
end

subgraph group_engine["Consensus engine"]
  node_nightblock["Night Block minting<br/>[night-block.ts]"]
  node_canon["Canonical encoding<br/>[canonical-json.ts]"]
  node_hash["SHA-256 hashing<br/>[hash.ts]"]
  node_merkle["Merkle proofs<br/>[merkle.ts]"]
  node_plant["Garden growth<br/>[plant.ts]"]
end

subgraph group_mobile["Mobile scaffold"]
  node_mobileapp["Mobile flow<br/>[App.cs]"]
  node_mobilemodel["Screen model<br/>[AppModel.cs]"]
  node_mobilescreens["Game screens"]
  node_mobileapi["In-device API<br/>[LocalApi.cs]"]
  node_mobilecontract["Mobile API contract<br/>[GameApi.cs]"]
  node_mobilecrypto["Mobile crypto<br/>[Merkle.cs]"]
  node_mobilehash["Mobile hashing<br/>[Hash.cs]"]
end

subgraph group_ai["AI agents"]
  node_aiinterface["Agent interface<br/>[IAiAgent.cs]"]
  node_ondevice["On-device agent<br/>[OnDeviceAgent.cs]"]
  node_serveragent["Server agent<br/>[ServerAgent.cs]"]
end

node_player(("Player"))
node_server["FastAPI server<br/>[main.py]"]

node_player -->|"plays"| node_webapp
node_webapp -->|"calls game API"| node_webapi
node_webapi -->|"creates"| node_localadapter
node_localadapter -.->|"reads and writes"| node_webstate
node_localadapter -.->|"implements"| node_contracts
node_localadapter -.->|"mints blocks"| node_nightblock
node_localadapter -.->|"builds proofs"| node_merkle
node_localadapter -.->|"computes growth"| node_plant
node_nightblock -->|"encodes"| node_canon
node_nightblock -->|"hashes"| node_hash
node_merkle -->|"hashes nodes"| node_hash
node_player -->|"plays"| node_mobileapp
node_mobileapp -->|"creates"| node_mobilemodel
node_mobileapp -->|"routes screens"| node_mobilescreens
node_mobilemodel -->|"calls API"| node_mobilecontract
node_mobileapi -->|"verifies blocks"| node_mobilecrypto
node_mobilecrypto -->|"hashes nodes"| node_mobilehash
node_mobileapi -->|"accepts optional agent"| node_aiinterface
node_ondevice -->|"implements"| node_aiinterface
node_serveragent -->|"implements"| node_aiinterface
node_player -.->|"opens game site"| node_server

click node_webapp "https://github.com/armansiddiqui9/slumberbloom/blob/main/apps/web/src/app/App.tsx"
click node_webapi "https://github.com/armansiddiqui9/slumberbloom/blob/main/apps/web/src/api/game-api.ts"
click node_localadapter "https://github.com/armansiddiqui9/slumberbloom/blob/main/packages/adapters-local/src/index.ts"
click node_contracts "https://github.com/armansiddiqui9/slumberbloom/blob/main/packages/contracts/src/index.ts"
click node_webstate "https://github.com/armansiddiqui9/slumberbloom/blob/main/packages/adapters-local/src/index.ts"
click node_nightblock "https://github.com/armansiddiqui9/slumberbloom/blob/main/packages/engine/src/blocks/night-block.ts"
click node_canon "https://github.com/armansiddiqui9/slumberbloom/blob/main/packages/engine/src/encoding/canonical-json.ts"
click node_hash "https://github.com/armansiddiqui9/slumberbloom/blob/main/packages/engine/src/crypto/hash.ts"
click node_merkle "https://github.com/armansiddiqui9/slumberbloom/blob/main/packages/engine/src/crypto/merkle.ts"
click node_plant "https://github.com/armansiddiqui9/slumberbloom/blob/main/packages/engine/src/garden/plant.ts"
click node_server "https://github.com/armansiddiqui9/slumberbloom/blob/main/server/main.py"
click node_mobileapp "https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/App.cs"
click node_mobilemodel "https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/UI/AppModel.cs"
click node_mobilescreens "https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/UI/MorningDewScreen.cs"
click node_mobileapi "https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/Backend/LocalApi.cs"
click node_mobilecontract "https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/Contracts/GameApi.cs"
click node_mobilecrypto "https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/Engine/Crypto/Merkle.cs"
click node_mobilehash "https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/Engine/Crypto/Hash.cs"
click node_aiinterface "https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/AI/IAiAgent.cs"
click node_ondevice "https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/AI/OnDeviceAgent.cs"
click node_serveragent "https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/AI/ServerAgent.cs"

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_webapp,node_webapi toneBlue
class node_localadapter,node_contracts,node_webstate toneAmber
class node_nightblock,node_canon,node_hash,node_merkle,node_plant,node_server toneMint
class node_mobileapp,node_mobilemodel,node_mobilescreens,node_mobileapi,node_mobilecontract,node_mobilecrypto,node_mobilehash toneRose
class node_aiinterface,node_ondevice,node_serveragent,node_player toneIndigo
```

## Components

### Web game

- [Game screens](https://github.com/armansiddiqui9/slumberbloom/blob/main/apps/web/src/app/App.tsx): `apps/web/src/app/App.tsx`
- [API composition](https://github.com/armansiddiqui9/slumberbloom/blob/main/apps/web/src/api/game-api.ts): `apps/web/src/api/game-api.ts`

### Local game API

- [Local adapter](https://github.com/armansiddiqui9/slumberbloom/blob/main/packages/adapters-local/src/index.ts): `packages/adapters-local/src/index.ts`
- [Game contracts](https://github.com/armansiddiqui9/slumberbloom/blob/main/packages/contracts/src/index.ts): `packages/contracts/src/index.ts`
- [Local game state](https://github.com/armansiddiqui9/slumberbloom/blob/main/packages/adapters-local/src/index.ts): `packages/adapters-local/src/index.ts`

### Consensus engine

- [Night Block minting](https://github.com/armansiddiqui9/slumberbloom/blob/main/packages/engine/src/blocks/night-block.ts): `packages/engine/src/blocks/night-block.ts`
- [Canonical encoding](https://github.com/armansiddiqui9/slumberbloom/blob/main/packages/engine/src/encoding/canonical-json.ts): `packages/engine/src/encoding/canonical-json.ts`
- [SHA-256 hashing](https://github.com/armansiddiqui9/slumberbloom/blob/main/packages/engine/src/crypto/hash.ts): `packages/engine/src/crypto/hash.ts`
- [Merkle proofs](https://github.com/armansiddiqui9/slumberbloom/blob/main/packages/engine/src/crypto/merkle.ts): `packages/engine/src/crypto/merkle.ts`
- [Garden growth](https://github.com/armansiddiqui9/slumberbloom/blob/main/packages/engine/src/garden/plant.ts): `packages/engine/src/garden/plant.ts`

### Mobile scaffold

- [Mobile flow](https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/App.cs): `mobile-game/src/App.cs`
- [Screen model](https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/UI/AppModel.cs): `mobile-game/src/UI/AppModel.cs`
- [Game screens](https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/UI/MorningDewScreen.cs): `mobile-game/src/UI/MorningDewScreen.cs`
- [In-device API](https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/Backend/LocalApi.cs): `mobile-game/src/Backend/LocalApi.cs`
- [Mobile API contract](https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/Contracts/GameApi.cs): `mobile-game/src/Contracts/GameApi.cs`
- [Mobile crypto](https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/Engine/Crypto/Merkle.cs): `mobile-game/src/Engine/Crypto/Merkle.cs`
- [Mobile hashing](https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/Engine/Crypto/Hash.cs): `mobile-game/src/Engine/Crypto/Hash.cs`

### AI agents

- [Agent interface](https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/AI/IAiAgent.cs): `mobile-game/src/AI/IAiAgent.cs`
- [On-device agent](https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/AI/OnDeviceAgent.cs): `mobile-game/src/AI/OnDeviceAgent.cs`
- [Server agent](https://github.com/armansiddiqui9/slumberbloom/blob/main/mobile-game/src/AI/ServerAgent.cs): `mobile-game/src/AI/ServerAgent.cs`

### Other components

- **Player**
- [FastAPI server](https://github.com/armansiddiqui9/slumberbloom/blob/main/server/main.py): `server/main.py`

## Connections

- Player → Game screens: plays
- Game screens → API composition: calls game API (evidence: `apps/web/src/app/App.tsx`)
- API composition → Local adapter: creates (evidence: `apps/web/src/api/game-api.ts`)
- Local adapter → Local game state: reads and writes (evidence: `packages/adapters-local/src/index.ts`)
- Local adapter → Game contracts: implements
- Local adapter → Night Block minting: mints blocks
- Local adapter → Merkle proofs: builds proofs
- Local adapter → Garden growth: computes growth
- Night Block minting → Canonical encoding: encodes (evidence: `packages/engine/src/blocks/night-block.ts`)
- Night Block minting → SHA-256 hashing: hashes (evidence: `packages/engine/src/blocks/night-block.ts`)
- Merkle proofs → SHA-256 hashing: hashes nodes (evidence: `packages/engine/src/crypto/merkle.ts`)
- Player → Mobile flow: plays
- Mobile flow → Screen model: creates (evidence: `mobile-game/src/App.cs`)
- Mobile flow → Game screens: routes screens (evidence: `mobile-game/src/App.cs`)
- Screen model → Mobile API contract: calls API (evidence: `mobile-game/src/UI/AppModel.cs`)
- In-device API → Mobile crypto: verifies blocks (evidence: `mobile-game/src/Backend/LocalApi.cs`)
- Mobile crypto → Mobile hashing: hashes nodes (evidence: `mobile-game/src/Engine/Crypto/Merkle.cs`)
- In-device API → Agent interface: accepts optional agent (evidence: `mobile-game/src/Backend/LocalApi.cs`)
- On-device agent → Agent interface: implements (evidence: `mobile-game/src/AI/OnDeviceAgent.cs`)
- Server agent → Agent interface: implements (evidence: `mobile-game/src/AI/ServerAgent.cs`)
- Player → FastAPI server: opens game site
