# mobsaikouu/btime architecture

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

- Interactive diagram: https://gitdiagram.com/mobsaikouu/btime
- Repository: https://github.com/mobsaikouu/btime

## Overview

BTime is a browser-based speedcubing timer. Its principal workflow selects an event and generates a scramble, times a solve, saves the result, then presents history and statistics. The README documents browser UI, storage, workers, and PWA behavior, but those application source files are not in the supplied tree, so their paths are null. The Java TNoodle bridge, puzzle implementations, solver families, and SVG primitives are represented from the tree and source index; links not directly shown are documented only where the README establishes them.

Main entry points: [`scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/puzzle`](https://github.com/mobsaikouu/btime/tree/main/scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/puzzle) (Puzzle adapters), [`scripts/tnoodle/src/main/java/btime/TNoodleBridge.java`](https://github.com/mobsaikouu/btime/blob/main/scripts/tnoodle/src/main/java/btime/TNoodleBridge.java) (TNoodle bridge), [`scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/svglite/Svg.java`](https://github.com/mobsaikouu/btime/blob/main/scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/svglite/Svg.java) (SVG drawing), [`sw.js`](https://github.com/mobsaikouu/btime/blob/main/sw.js) (Service worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Timer experience"]
  node_timer["Timer controls"]
  node_event["Event selection"]
  node_settings["Timer settings"]
end

subgraph group_records["Solve records"]
  node_history["History and actions"]
  node_statistics["Solve statistics"]
  node_indexeddb[("Solve archive")]
  node_browserprefs[("Preferences")]
end

subgraph group_scrambles["Scramble generation"]
  node_scrambleui["Scramble panel"]
  node_worker["Scramble worker"]
  node_bridge["TNoodle bridge<br/>[TNoodleBridge.java]"]
  node_puzzles["Puzzle adapters"]
  node_scramblecore["Puzzle state and algorithms<br/>[Puzzle.java]"]
end

subgraph group_solvers["Solver engines"]
  node_cubeengine["Cube search<br/>[Search.java]"]
  node_squareengine["Square-1 search<br/>[Search.java]"]
  node_threephase["Three-phase search<br/>[Search.java]"]
  node_specialsolvers["Puzzle-specific solvers"]
end

subgraph group_rendering["Scramble drawings"]
  node_svgdraw["SVG drawing<br/>[Svg.java]"]
  node_svgelements["SVG elements<br/>[Element.java]"]
  node_svgpath["SVG paths<br/>[Path.java]"]
end

subgraph group_offline["Offline delivery"]
  node_serviceworker["Service worker<br/>[sw.js]"]
  node_offlineassets["Offline engine assets"]
end

node_cubers(("Cubers"))

node_cubers -->|"choose event"| node_event
node_cubers -->|"operate timer"| node_timer
node_cubers -->|"configure"| node_settings
node_event -->|"selects scramble"| node_scrambleui
node_scrambleui -->|"requests scramble"| node_worker
node_worker -.->|"uses engine"| node_bridge
node_bridge -->|"dispatches events"| node_puzzles
node_puzzles -->|"uses puzzle API"| node_scramblecore
node_puzzles -.->|"invokes search"| node_cubeengine
node_puzzles -.->|"invokes search"| node_squareengine
node_puzzles -.->|"invokes search"| node_threephase
node_puzzles -.->|"uses solvers"| node_specialsolvers
node_bridge -.->|"returns scramble"| node_scrambleui
node_scrambleui -->|"shows drawing"| node_svgdraw
node_svgdraw -->|"builds SVG"| node_svgelements
node_svgdraw -->|"uses paths"| node_svgpath
node_timer -->|"records solve"| node_history
node_history -->|"stores solves"| node_indexeddb
node_history -->|"updates metrics"| node_statistics
node_history -->|"saves scrambles"| node_browserprefs
node_settings -->|"saves preferences"| node_browserprefs
node_serviceworker -->|"supports offline"| node_offlineassets
node_worker -->|"loads locally"| node_offlineassets
node_serviceworker -->|"preserves data"| node_indexeddb

click node_bridge "https://github.com/mobsaikouu/btime/blob/main/scripts/tnoodle/src/main/java/btime/TNoodleBridge.java"
click node_puzzles "https://github.com/mobsaikouu/btime/tree/main/scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/puzzle"
click node_scramblecore "https://github.com/mobsaikouu/btime/blob/main/scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/scrambles/Puzzle.java"
click node_cubeengine "https://github.com/mobsaikouu/btime/blob/main/scripts/tnoodle/src/main/java/cs/min2phase/Search.java"
click node_squareengine "https://github.com/mobsaikouu/btime/blob/main/scripts/tnoodle/src/main/java/cs/sq12phase/Search.java"
click node_threephase "https://github.com/mobsaikouu/btime/blob/main/scripts/tnoodle/src/main/java/cs/threephase/Search.java"
click node_specialsolvers "https://github.com/mobsaikouu/btime/tree/main/scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/puzzle"
click node_svgdraw "https://github.com/mobsaikouu/btime/blob/main/scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/svglite/Svg.java"
click node_svgelements "https://github.com/mobsaikouu/btime/blob/main/scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/svglite/Element.java"
click node_svgpath "https://github.com/mobsaikouu/btime/blob/main/scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/svglite/Path.java"
click node_serviceworker "https://github.com/mobsaikouu/btime/blob/main/sw.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_timer,node_event,node_settings toneBlue
class node_history,node_statistics,node_indexeddb,node_browserprefs toneAmber
class node_scrambleui,node_worker,node_bridge,node_puzzles,node_scramblecore toneMint
class node_cubeengine,node_squareengine,node_threephase,node_specialsolvers toneRose
class node_svgdraw,node_svgelements,node_svgpath,node_cubers toneIndigo
class node_serviceworker,node_offlineassets toneTeal
```

## Components

### Timer experience

- **Timer controls**
- **Event selection**
- **Timer settings**

### Solve records

- **History and actions**
- **Solve statistics**
- **Solve archive**
- **Preferences**

### Scramble generation

- **Scramble panel**
- **Scramble worker**
- [TNoodle bridge](https://github.com/mobsaikouu/btime/blob/main/scripts/tnoodle/src/main/java/btime/TNoodleBridge.java): `scripts/tnoodle/src/main/java/btime/TNoodleBridge.java`
- [Puzzle adapters](https://github.com/mobsaikouu/btime/tree/main/scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/puzzle): `scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/puzzle`
- [Puzzle state and algorithms](https://github.com/mobsaikouu/btime/blob/main/scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/scrambles/Puzzle.java): `scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/scrambles/Puzzle.java`

### Solver engines

- [Cube search](https://github.com/mobsaikouu/btime/blob/main/scripts/tnoodle/src/main/java/cs/min2phase/Search.java): `scripts/tnoodle/src/main/java/cs/min2phase/Search.java`
- [Square-1 search](https://github.com/mobsaikouu/btime/blob/main/scripts/tnoodle/src/main/java/cs/sq12phase/Search.java): `scripts/tnoodle/src/main/java/cs/sq12phase/Search.java`
- [Three-phase search](https://github.com/mobsaikouu/btime/blob/main/scripts/tnoodle/src/main/java/cs/threephase/Search.java): `scripts/tnoodle/src/main/java/cs/threephase/Search.java`
- [Puzzle-specific solvers](https://github.com/mobsaikouu/btime/tree/main/scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/puzzle): `scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/puzzle`

### Scramble drawings

- [SVG drawing](https://github.com/mobsaikouu/btime/blob/main/scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/svglite/Svg.java): `scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/svglite/Svg.java`
- [SVG elements](https://github.com/mobsaikouu/btime/blob/main/scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/svglite/Element.java): `scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/svglite/Element.java`
- [SVG paths](https://github.com/mobsaikouu/btime/blob/main/scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/svglite/Path.java): `scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/svglite/Path.java`

### Offline delivery

- [Service worker](https://github.com/mobsaikouu/btime/blob/main/sw.js): `sw.js`
- **Offline engine assets**

### Other components

- **Cubers**

## Connections

- Cubers → Event selection: choose event
- Cubers → Timer controls: operate timer
- Cubers → Timer settings: configure
- Event selection → Scramble panel: selects scramble
- Scramble panel → Scramble worker: requests scramble
- Scramble worker → TNoodle bridge: uses engine
- TNoodle bridge → Puzzle adapters: dispatches events (evidence: `scripts/tnoodle/src/main/java/btime/TNoodleBridge.java`)
- Puzzle adapters → Puzzle state and algorithms: uses puzzle API (evidence: `scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/scrambles/Puzzle.java`)
- Puzzle adapters → Cube search: invokes search
- Puzzle adapters → Square-1 search: invokes search
- Puzzle adapters → Three-phase search: invokes search
- Puzzle adapters → Puzzle-specific solvers: uses solvers
- TNoodle bridge → Scramble panel: returns scramble
- Scramble panel → SVG drawing: shows drawing
- SVG drawing → SVG elements: builds SVG (evidence: `scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/svglite/Element.java`)
- SVG drawing → SVG paths: uses paths (evidence: `scripts/tnoodle/src/main/java/org/worldcubeassociation/tnoodle/svglite/Path.java`)
- Timer controls → History and actions: records solve
- History and actions → Solve archive: stores solves
- History and actions → Solve statistics: updates metrics
- History and actions → Preferences: saves scrambles
- Timer settings → Preferences: saves preferences
- Service worker → Offline engine assets: supports offline
- Scramble worker → Offline engine assets: loads locally
- Service worker → Solve archive: preserves data
