# lukasjakobi/nearby-dice architecture

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

- Interactive diagram: https://gitdiagram.com/lukasjakobi/nearby-dice
- Repository: https://github.com/lukasjakobi/nearby-dice

## Overview

Nearby Dice is a local-multiplayer Yatzy-style game for Android and iOS. Players host or join a coded round, play through a host-authoritative session, and see shared results; training supports solo play. The graph preserves documented game modes, reconnect/resume, history, settings, permissions, and feedback capabilities. Several links are documented by the README; source excerpts show the host’s engine and transport responsibilities and the game screen’s session commands. Other feature internals were not sampled, so their detailed calls are omitted.

Main entry points: [`src/session/HostSession.ts`](https://github.com/lukasjakobi/nearby-dice/blob/main/src/session/HostSession.ts) (Host session), [`src/features/game/hooks/useGameScreen.ts`](https://github.com/lukasjakobi/nearby-dice/blob/main/src/features/game/hooks/useGameScreen.ts) (Game screen), [`src/domain/engine.ts`](https://github.com/lukasjakobi/nearby-dice/blob/main/src/domain/engine.ts) (Game engine), [`src/net`](https://github.com/lukasjakobi/nearby-dice/tree/main/src/net) (Nearby transport)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and setup"]
  node_home["Home and resume"]
  node_hostsetup["Host setup"]
  node_hostlobby["Host lobby"]
  node_join["Join flow"]
  node_permission["Permission gate"]
end

subgraph group_play["Sessions and gameplay"]
  node_hostsession["Host session<br/>[HostSession.ts]"]
  node_guestsession["Guest session<br/>[GuestSession.ts]"]
  node_training["Training session<br/>[TrainingSession.ts]"]
  node_engine["Game engine<br/>[engine.ts]"]
  node_rules["Rules and scoring<br/>[scoring.ts]"]
  node_autopick["Automatic scoring<br/>[autopick.ts]"]
  node_gameui["Game screen<br/>[useGameScreen.ts]"]
end

subgraph group_platform["Connectivity and persistence"]
  node_scanner["Round scanner<br/>[RoundScanner.ts]"]
  node_transport["Nearby transport"]
  node_native["Native connections"]
end

subgraph group_experience["Results and experience"]
  node_results["Results and history"]
  node_storage[("Local stores")]
  node_settings["Settings and feedback<br/>[audio.ts]"]
  node_settingsui["Settings screen"]
end

node_players(("Players"))

node_players -->|"open app"| node_home
node_home -->|"choose host"| node_hostsetup
node_hostsetup -.->|"open round"| node_hostlobby
node_players -->|"enter code"| node_join
node_join -.->|"find rounds"| node_scanner
node_permission -->|"authorize access"| node_transport
node_scanner -->|"scan nearby"| node_transport
node_transport -.->|"use native links"| node_native
node_hostlobby -.->|"start session"| node_hostsession
node_hostsession -->|"advertise and send"| node_transport
node_hostsession -->|"reduce moves"| node_engine
node_hostsession -->|"broadcast shared state"| node_guestsession
node_guestsession -->|"request moves"| node_hostsession
node_training -.->|"run solo game"| node_engine
node_engine -->|"score and validate"| node_rules
node_engine -->|"choose automatic score"| node_autopick
node_gameui -->|"send player actions"| node_hostsession
node_gameui -.->|"send player actions"| node_guestsession
node_gameui -.->|"control training"| node_training
node_gameui -->|"navigate when finished"| node_results
node_results -.->|"record game history"| node_storage
node_home -->|"load resume and stats"| node_storage
node_settingsui -.->|"read settings"| node_storage
node_gameui -->|"play configured feedback"| node_settings
node_settings -->|"read sound switches"| node_storage

click node_home "https://github.com/lukasjakobi/nearby-dice/tree/main/src/features/home"
click node_hostsetup "https://github.com/lukasjakobi/nearby-dice/tree/main/src/features/host-setup"
click node_hostlobby "https://github.com/lukasjakobi/nearby-dice/tree/main/src/features/host-lobby"
click node_join "https://github.com/lukasjakobi/nearby-dice/tree/main/src/features/join"
click node_permission "https://github.com/lukasjakobi/nearby-dice/tree/main/src/shared/permissions"
click node_scanner "https://github.com/lukasjakobi/nearby-dice/blob/main/src/session/RoundScanner.ts"
click node_transport "https://github.com/lukasjakobi/nearby-dice/tree/main/src/net"
click node_native "https://github.com/lukasjakobi/nearby-dice/tree/main/modules/nearby-connections"
click node_hostsession "https://github.com/lukasjakobi/nearby-dice/blob/main/src/session/HostSession.ts"
click node_guestsession "https://github.com/lukasjakobi/nearby-dice/blob/main/src/session/GuestSession.ts"
click node_training "https://github.com/lukasjakobi/nearby-dice/blob/main/src/session/TrainingSession.ts"
click node_engine "https://github.com/lukasjakobi/nearby-dice/blob/main/src/domain/engine.ts"
click node_rules "https://github.com/lukasjakobi/nearby-dice/blob/main/src/domain/scoring.ts"
click node_autopick "https://github.com/lukasjakobi/nearby-dice/blob/main/src/domain/autopick.ts"
click node_gameui "https://github.com/lukasjakobi/nearby-dice/blob/main/src/features/game/hooks/useGameScreen.ts"
click node_results "https://github.com/lukasjakobi/nearby-dice/tree/main/src/features/results"
click node_storage "https://github.com/lukasjakobi/nearby-dice/tree/main/src/store"
click node_settings "https://github.com/lukasjakobi/nearby-dice/blob/main/src/shared/audio.ts"
click node_settingsui "https://github.com/lukasjakobi/nearby-dice/tree/main/src/features/settings"

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_home,node_hostsetup,node_hostlobby,node_join,node_permission toneBlue
class node_hostsession,node_guestsession,node_training,node_engine,node_rules,node_autopick,node_gameui toneAmber
class node_scanner,node_transport,node_native toneMint
class node_results,node_storage,node_settings,node_settingsui toneRose
class node_players toneIndigo
```

## Components

### Entry and setup

- [Home and resume](https://github.com/lukasjakobi/nearby-dice/tree/main/src/features/home): `src/features/home`
- [Host setup](https://github.com/lukasjakobi/nearby-dice/tree/main/src/features/host-setup): `src/features/host-setup`
- [Host lobby](https://github.com/lukasjakobi/nearby-dice/tree/main/src/features/host-lobby): `src/features/host-lobby`
- [Join flow](https://github.com/lukasjakobi/nearby-dice/tree/main/src/features/join): `src/features/join`
- [Permission gate](https://github.com/lukasjakobi/nearby-dice/tree/main/src/shared/permissions): `src/shared/permissions`

### Sessions and gameplay

- [Host session](https://github.com/lukasjakobi/nearby-dice/blob/main/src/session/HostSession.ts): `src/session/HostSession.ts`
- [Guest session](https://github.com/lukasjakobi/nearby-dice/blob/main/src/session/GuestSession.ts): `src/session/GuestSession.ts`
- [Training session](https://github.com/lukasjakobi/nearby-dice/blob/main/src/session/TrainingSession.ts): `src/session/TrainingSession.ts`
- [Game engine](https://github.com/lukasjakobi/nearby-dice/blob/main/src/domain/engine.ts): `src/domain/engine.ts`
- [Rules and scoring](https://github.com/lukasjakobi/nearby-dice/blob/main/src/domain/scoring.ts): `src/domain/scoring.ts`
- [Automatic scoring](https://github.com/lukasjakobi/nearby-dice/blob/main/src/domain/autopick.ts): `src/domain/autopick.ts`
- [Game screen](https://github.com/lukasjakobi/nearby-dice/blob/main/src/features/game/hooks/useGameScreen.ts): `src/features/game/hooks/useGameScreen.ts`

### Connectivity and persistence

- [Round scanner](https://github.com/lukasjakobi/nearby-dice/blob/main/src/session/RoundScanner.ts): `src/session/RoundScanner.ts`
- [Nearby transport](https://github.com/lukasjakobi/nearby-dice/tree/main/src/net): `src/net`
- [Native connections](https://github.com/lukasjakobi/nearby-dice/tree/main/modules/nearby-connections): `modules/nearby-connections`

### Results and experience

- [Results and history](https://github.com/lukasjakobi/nearby-dice/tree/main/src/features/results): `src/features/results`
- [Local stores](https://github.com/lukasjakobi/nearby-dice/tree/main/src/store): `src/store`
- [Settings and feedback](https://github.com/lukasjakobi/nearby-dice/blob/main/src/shared/audio.ts): `src/shared/audio.ts`
- [Settings screen](https://github.com/lukasjakobi/nearby-dice/tree/main/src/features/settings): `src/features/settings`

### Other components

- **Players**

## Connections

- Players → Home and resume: open app
- Home and resume → Host setup: choose host
- Host setup → Host lobby: open round
- Players → Join flow: enter code
- Join flow → Round scanner: find rounds
- Permission gate → Nearby transport: authorize access (evidence: `src/shared/permissions/usePermissionGate.ts`)
- Round scanner → Nearby transport: scan nearby (evidence: `src/session/RoundScanner.ts`)
- Nearby transport → Native connections: use native links
- Host lobby → Host session: start session
- Host session → Nearby transport: advertise and send (evidence: `src/session/HostSession.ts`)
- Host session → Game engine: reduce moves
- Host session → Guest session: broadcast shared state
- Guest session → Host session: request moves
- Training session → Game engine: run solo game
- Game engine → Rules and scoring: score and validate (evidence: `src/domain/engine.ts`)
- Game engine → Automatic scoring: choose automatic score (evidence: `src/domain/engine.ts`)
- Game screen → Host session: send player actions (evidence: `src/features/game/hooks/useGameScreen.ts`)
- Game screen → Guest session: send player actions
- Game screen → Training session: control training
- Game screen → Results and history: navigate when finished (evidence: `src/features/game/hooks/useGameScreen.ts`)
- Results and history → Local stores: record game history (evidence: `src/features/results/hooks/useResults.ts`)
- Home and resume → Local stores: load resume and stats (evidence: `src/features/home/hooks/useHome.ts`)
- Settings screen → Local stores: read settings
- Game screen → Settings and feedback: play configured feedback (evidence: `src/features/game/hooks/useGameScreen.ts`)
- Settings and feedback → Local stores: read sound switches (evidence: `src/shared/hooks/useFeedback.ts`)
