How lewdry/homehome works
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 main.js · utils.js utils.js · book.js book.js · index.html index.html
Components 14
Shell
Persistent document chrome and global orchestration
- index.html · Single-page host document with menu, tabs, footer, and workspace
index.html - main.js · Coordinates tab switching, deep links, theme, sound, and reset
main.js - utils.js · Cross-app helpers for sound, DOM/input support, and common behavior
utils.js - styles.css · Global visual design, layout, responsive behavior, and theming
styles.css
Apps
Standalone feature modules mounted into the shared workspace
- bonk.js · Draggable bouncing-ball interaction and game logic
bonk.js - blok.js · Breakout-style game with paddle, bricks, and win state
blok.js - calc.js · Persistent calculator app with stored state
calc.js - draw.js · Pixel-art canvas editor and drawing interactions
draw.js - note.js · Text editor with on-screen keyboard and cursor handling
note.js - book.js · Plain-text book reader with paging, search, and text sizing
book.js
Assets
Local content, media, and PWA support files
- books/ · Local plain-text book collection used by the reader
books - sounds/ · MP3 feedback sounds shared across the UI and mini-apps
sounds - manifest.json · Install metadata for progressive web app behavior
manifest.json - sw.js · Offline caching and asset availability boundary
sw.js
Connections 20
- 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