# lewdry/homehome architecture

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

- Interactive diagram: https://gitdiagram.com/lewdry/homehome
- Repository: https://github.com/lewdry/homehome

## Overview

1. **Overall shape**
   - This is a single-page “web OS” built with plain HTML/CSS/JavaScript, not a framework app.
   - The architecture is centered on one document shell (`index.html`) plus a set of feature modules for each tab/app.

2. **UI shell and app switching**
   - `index.html` provides the persistent chrome: menu bar, tab strip, footer, and the shared workspace where apps appear.
   - `main.js` is the orchestration layer that likely wires the shell together, switches tabs, handles deeplinks from URL query parameters, and coordinates global UI state like theme, sound, and reset.

3. **Feature modules as isolated “apps”**
   - Each tab is implemented in its own top-level module: `bonk.js`, `blok.js`, `calc.js`, `draw.js`, `note.js`, and `book.js`.
   - These modules are the main functional boundaries of the repo; each owns its own interaction model, rendering, and state for one mini-application.

4. **Shared runtime and utilities**
   - `utils.js` is the cross-cutting support layer for functionality used by multiple apps.
   - From the README, this includes shared sound handling and likely common helpers for DOM, input, and responsive behavior.
   - This file is the main dependency boundary between the shell and the feature modules.

5. **Game and tool subsystems**
   - `bonk.js` is a physics toy/game with draggable bouncing balls.
   - `blok.js` is a breakout-style arcade game with paddle movement, bricks, and win state.
   - `calc.js` is a calculator with persistent state.
   - `draw.js` is a pixel-art canvas editor.
   - `note.js` is a notepad with an on-screen keyboard and text cursor management.
   - `book.js` is a reader for plain-text books with paging, search, and text sizing.

6. **Data sources and content flow**
   - The `books/` directory is a content library of plain-text public-domain books.
   - `book.js` reads from this local asset set and turns text files into paginated reading content.
   - This is a file-backed content model rather than remote API-driven data.

7. **Persistence and local state**
   - The app stores some state locally in the browser rather than on a server.
   - The README explicitly calls out persistent calculator state and saved book progress, implying `localStorage` or equivalent browser storage.
   - This makes several subsystems stateful across reloads without any backend.

8. **Audio subsystem**
   - `sounds/` contains small MP3 assets for UI/game feedback.
   - Sound playback is likely routed through shared logic in `utils.js`, with a global mute toggle in the shell.
   - The architecture treats sound as a cross-app service rather than duplicating it inside each module.

9. **PWA and offline boundary**
   - `manifest.json` and `sw.js` add progressive web app behavior.
   - The service worker provides offline availability for the shell, scripts, and local assets, which matters because books and sounds are all shipped with the app.

10. **Styling and presentation**
   - `styles.css` defines the whole visual system: Solarized palette, pixel-art styling, layout, and responsive behavior.
   - The visual design is part of the core architecture because the “OS” metaphor depends on a persistent desktop-like frame and theme switching.

11. **Input and interaction model**
   - The app supports mouse, touch, keyboard, and accessibility-friendly interaction.
   - Each module owns its own controls, but the shell exposes common actions like tab switching, theme toggle, sound toggle, and reset.
   - Double-tap gestures and other “easter egg” behaviors are implemented at the app level rather than as global browser features.

12. **Deployment model**
   - There is no build pipeline, package manager, or server dependency in the repo.
   - The application is meant to run directly by opening `index.html` in a browser, with all logic and assets loaded statically from the repository.

13. **External dependencies**
   - There are no runtime libraries or third-party frameworks.
   - The only meaningful external dependency is the content provenance: Project Gutenberg for the text library, and the Web Audio API for sound playback in supported browsers.

14. **How to draw the architecture**
   - Treat `index.html` as the host container, `main.js` as the central controller, `utils.js` as the shared service layer, the six feature files as independent app modules, and `books/`, `sounds/`, `manifest.json`, and `sw.js` as static asset/support subsystems.
   - The dominant flow is: user input → shell/app module → shared utilities/assets → rendered UI and persisted state.

Main entry points: [`main.js`](https://github.com/lewdry/homehome/blob/main/main.js) (main.js), [`utils.js`](https://github.com/lewdry/homehome/blob/main/utils.js) (utils.js), [`book.js`](https://github.com/lewdry/homehome/blob/main/book.js) (book.js), [`index.html`](https://github.com/lewdry/homehome/blob/main/index.html) (index.html)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["Shell"]
  node_index_html["index.html<br/>document shell<br/>[index.html]"]
  node_main_js["main.js<br/>orchestrator<br/>[main.js]"]
  node_utils_js["utils.js<br/>shared runtime<br/>[utils.js]"]
  node_styles_css["styles.css<br/>presentation system<br/>[styles.css]"]
end

subgraph group_apps["Apps"]
  node_bonk_js["bonk.js<br/>physics toy<br/>[bonk.js]"]
  node_blok_js["blok.js<br/>arcade game<br/>[blok.js]"]
  node_calc_js["calc.js<br/>calculator<br/>[calc.js]"]
  node_draw_js["draw.js<br/>pixel editor<br/>[draw.js]"]
  node_note_js["note.js<br/>notepad<br/>[note.js]"]
  node_book_js["book.js<br/>reader<br/>[book.js]"]
end

subgraph group_assets["Assets"]
  node_books_dir[("books/<br/>content library")]
  node_sounds_dir[("sounds/<br/>audio assets")]
  node_manifest_json["manifest.json<br/>pwa manifest<br/>[manifest.json]"]
  node_sw_js["sw.js<br/>service worker<br/>[sw.js]"]
end

node_index_html -->|"loads"| node_main_js
node_index_html -->|"styles"| node_styles_css
node_main_js -->|"uses"| node_utils_js
node_main_js -->|"mounts"| node_bonk_js
node_main_js -->|"mounts"| node_blok_js
node_main_js -->|"mounts"| node_calc_js
node_main_js -->|"mounts"| node_draw_js
node_main_js -->|"mounts"| node_note_js
node_main_js -->|"mounts"| node_book_js
node_bonk_js -->|"shared"| node_utils_js
node_blok_js -->|"shared"| node_utils_js
node_calc_js -->|"shared"| node_utils_js
node_draw_js -->|"shared"| node_utils_js
node_note_js -->|"shared"| node_utils_js
node_book_js -->|"shared"| node_utils_js
node_book_js -->|"reads"| node_books_dir
node_main_js -->|"registers"| node_manifest_json
node_main_js -->|"hooks"| node_sw_js
node_utils_js -->|"plays"| node_sounds_dir
node_main_js -->|"toggles"| node_styles_css

click node_index_html "https://github.com/lewdry/homehome/blob/main/index.html"
click node_main_js "https://github.com/lewdry/homehome/blob/main/main.js"
click node_utils_js "https://github.com/lewdry/homehome/blob/main/utils.js"
click node_styles_css "https://github.com/lewdry/homehome/blob/main/styles.css"
click node_bonk_js "https://github.com/lewdry/homehome/blob/main/bonk.js"
click node_blok_js "https://github.com/lewdry/homehome/blob/main/blok.js"
click node_calc_js "https://github.com/lewdry/homehome/blob/main/calc.js"
click node_draw_js "https://github.com/lewdry/homehome/blob/main/draw.js"
click node_note_js "https://github.com/lewdry/homehome/blob/main/note.js"
click node_book_js "https://github.com/lewdry/homehome/blob/main/book.js"
click node_books_dir "https://github.com/lewdry/homehome/tree/main/books"
click node_sounds_dir "https://github.com/lewdry/homehome/tree/main/sounds"
click node_manifest_json "https://github.com/lewdry/homehome/blob/main/manifest.json"
click node_sw_js "https://github.com/lewdry/homehome/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_index_html,node_main_js,node_utils_js,node_styles_css toneBlue
class node_bonk_js,node_blok_js,node_calc_js,node_draw_js,node_note_js,node_book_js toneAmber
class node_books_dir,node_sounds_dir,node_manifest_json,node_sw_js toneMint
```

## Components

### Shell

Persistent document chrome and global orchestration

- [index.html](https://github.com/lewdry/homehome/blob/main/index.html): document shell · Single-page host document with menu, tabs, footer, and workspace · `index.html`
- [main.js](https://github.com/lewdry/homehome/blob/main/main.js): orchestrator · Coordinates tab switching, deep links, theme, sound, and reset · `main.js`
- [utils.js](https://github.com/lewdry/homehome/blob/main/utils.js): shared runtime · Cross-app helpers for sound, DOM/input support, and common behavior · `utils.js`
- [styles.css](https://github.com/lewdry/homehome/blob/main/styles.css): presentation system · Global visual design, layout, responsive behavior, and theming · `styles.css`

### Apps

Standalone feature modules mounted into the shared workspace

- [bonk.js](https://github.com/lewdry/homehome/blob/main/bonk.js): physics toy · Draggable bouncing-ball interaction and game logic · `bonk.js`
- [blok.js](https://github.com/lewdry/homehome/blob/main/blok.js): arcade game · Breakout-style game with paddle, bricks, and win state · `blok.js`
- [calc.js](https://github.com/lewdry/homehome/blob/main/calc.js): calculator · Persistent calculator app with stored state · `calc.js`
- [draw.js](https://github.com/lewdry/homehome/blob/main/draw.js): pixel editor · Pixel-art canvas editor and drawing interactions · `draw.js`
- [note.js](https://github.com/lewdry/homehome/blob/main/note.js): notepad · Text editor with on-screen keyboard and cursor handling · `note.js`
- [book.js](https://github.com/lewdry/homehome/blob/main/book.js): reader · Plain-text book reader with paging, search, and text sizing · `book.js`

### Assets

Local content, media, and PWA support files

- [books/](https://github.com/lewdry/homehome/tree/main/books): content library · Local plain-text book collection used by the reader · `books`
- [sounds/](https://github.com/lewdry/homehome/tree/main/sounds): audio assets · MP3 feedback sounds shared across the UI and mini-apps · `sounds`
- [manifest.json](https://github.com/lewdry/homehome/blob/main/manifest.json): pwa manifest · Install metadata for progressive web app behavior · `manifest.json`
- [sw.js](https://github.com/lewdry/homehome/blob/main/sw.js): service worker · Offline caching and asset availability boundary · `sw.js`

## Connections

- index.html → main.js: loads · Bootstraps the orchestration script
- index.html → styles.css: styles · Applies the shared UI chrome and theme
- main.js → utils.js: uses · Delegates shared helpers and global services
- main.js → bonk.js: mounts · Activates the bonk app in the workspace
- main.js → blok.js: mounts · Activates the blok app in the workspace
- main.js → calc.js: mounts · Activates the calculator app
- main.js → draw.js: mounts · Activates the drawing app
- main.js → note.js: mounts · Activates the note app
- main.js → book.js: mounts · Activates the reader app
- bonk.js → utils.js: shared · Uses shared sound and interaction helpers
- blok.js → utils.js: shared · Uses shared sound and interaction helpers
- calc.js → utils.js: shared · Uses shared sound and interaction helpers
- draw.js → utils.js: shared · Uses shared sound and interaction helpers
- note.js → utils.js: shared · Uses shared sound and interaction helpers
- book.js → utils.js: shared · Uses shared sound and interaction helpers
- book.js → books/: reads · Loads local text content for paging and search
- main.js → manifest.json: registers · Exposes install metadata through the shell
- main.js → sw.js: hooks · Enables offline caching and local asset serving
- utils.js → sounds/: plays · Routes UI and game feedback audio
- main.js → styles.css: toggles · Switches global theme and visual state
