How thanksmors/os-shell works
1. Overall shape
This repo is a browser-based desktop OS shell. The main runtime is the frontend in index.html, shell/, and modules/, with an optional backend in codehooks/ for auth, workspaces, and persisted data.
2. Frontend shell as the orchestration layer
The shell/ directory is the core OS layer: it owns global app state, window management, keyboard shortcuts, launcher behavior, notifications, theming, and the desktop/workspace frame. The README’s Alpine.store('os') is the single source of truth for window lifecycle and layout.
3. Module system boundary
Each app under modules/ is a Web Component registered via customElements.define(). Modules are isolated with Shadow DOM and load lazily when launched. This creates a hard boundary between “OS shell” concerns and “app” concerns.
4. How shell and modules interact
The shell passes a small API object into each module instance (windowId, mode, theme state, title updates, notifications, close requests, and access to the shared store). That API is the main integration seam; modules should not directly manage global OS state.
5. Built-in app set
The shipped apps are notepad, files, about, and settings, with additional modules for gantt, kanban, list, rocks, and boilerplate. settings/tabs/ suggests settings is itself internally modular, with separate tabs for workspace, appearance, and about.
6. Data-centric module path
modules/data/ stands out because it contains an api.js, which likely bridges the frontend shell to the backend data layer. This is the most likely path for persistent user/workspace content, while the other apps appear mostly client-side UI modules.
7. Backend service boundary
codehooks/ is a separate Node-style service with route handlers for auth, data, invites, members, and workspaces, plus shared libs for DB access, sessions, config, and change tracking. Architecturally, this is a multi-tenant collaboration backend rather than a generic app server.
8. Persistence and collaboration model
The backend route layout implies workspace-scoped data, membership management, and invitation-based access control. lib/changes.js suggests change logs or sync/patch semantics, so persisted state is probably tracked as workspace updates rather than just static CRUD records.
9. Styling and runtime constraints
The UI uses Alpine.js v3, Tailwind CSS, and Constructable Stylesheets/adopted stylesheets (shadow-tailwind.js) to share styling into shadow roots. Because imports are root-absolute ES modules, the app must be served over HTTP, not opened from file://.
10. State and interaction flows
Typical flow is: browser loads index.html → shell initializes global OS store → launcher/window manager opens a module → module renders in its shadow root → module uses the injected API to update window title, request notifications, or close itself. If a module needs persistence, it routes through the backend API, likely via modules/data.
11. Deployment and hosting
netlify.toml suggests the frontend is intended for static hosting, while codehooks/ is deployed separately as the server/API layer. registry.json likely supports module discovery/launch metadata in the shell, and build/ contains Tailwind build inputs for future or optional CSS generation.
Main entry points: registry.json Registry · index.js Backend Entry · workspace.js Workspace UI · api.js Shell API
Components 26
Frontend Shell
Browser-loaded OS shell, windowing, shared state, and UI runtime.
- index.html · Browser entry that boots the shell and loads the frontend runtime.
index.html - OS Store · Single source of truth for windows, layout, theme, and desktop state.
shell/store-os.js - Window Manager · Opens, tracks, and arranges app windows and their lifecycle.
shell/window-manager.js - Shell API · Shared interface passed into modules for title, close, notifications, and state access.
shell/api.js - Workspace UI · Desktop/workspace orchestration and shell-level framing.
shell/workspace.js - Shortcuts · Keyboard shortcuts and global interaction bindings.
shell/shortcuts.js - Auth State · Authentication and user/session state used by the shell.
shell/store-auth.js - Shadow CSS · Constructable stylesheet bridge for sharing Tailwind styles into shadow roots.
shell/shadow-tailwind.js
Modules
Lazy-loaded desktop apps implemented as Web Components.
- Registry · Launch metadata for discovering and registering available modules.
registry.json - Data API · Frontend bridge for persistent workspace and content operations.
modules/data/api.js - Notepad · Text note editor module.
modules/notepad/index.js - Files · File browsing and workspace content module.
modules/files/index.js - Settings · System settings module with internal tabs for workspace, appearance, and about.
modules/settings/index.js - About · Application/about information module.
modules/about/index.js - Boilerplate · Template module used as a starting point for new apps.
modules/boilerplate/index.js
Codehooks Backend
Workspace/auth/data service for multi-tenant persistence and collaboration.
- Backend Entry · Codehooks service bootstrap and route registration.
codehooks/index.js - Auth Route · Authentication endpoints for the collaboration service.
codehooks/routes/auth.js - Data Route · Workspace-scoped data endpoints for persisted content.
codehooks/routes/data.js - Workspaces · Workspace lifecycle and tenancy endpoints.
codehooks/routes/workspaces.js - Members · Workspace membership management endpoints.
codehooks/routes/members.js - Invites · Invitation and access-sharing endpoints.
codehooks/routes/invites.js - DB Layer · Database access layer for stored workspace data.
codehooks/lib/db.js - Session · Session handling and auth persistence helpers.
codehooks/lib/session.js - Change Log · Change tracking and patch semantics for persisted workspace state.
codehooks/lib/changes.js
Build & Deploy
Static hosting and build inputs for the browser shell.
- Tailwind Config · Tailwind build configuration and CSS input for generated styles.
build/tailwind.config.js - Netlify · Static hosting configuration for the frontend shell.
netlify.toml
Connections 31
- index.html → OS Store: boot · Initializes the global OS state when the browser loads.
- index.html → Workspace UI: start · Loads the shell workspace and desktop frame.
- Workspace UI → Window Manager: coordinate · Uses the window manager to create and arrange app windows.
- Window Manager → OS Store: read/write · Consumes the shared OS store for window lifecycle and layout.
- Workspace UI → Shortcuts: bind · Attaches global keyboard shortcuts to shell actions.
- Workspace UI → Auth State: session · Uses auth state to reflect signed-in workspace context.
- Shell API → OS Store: access · Exposes selected shared state to launched modules.
- Shell API → Window Manager: control · Lets modules request window title updates and close actions.
- Shadow CSS → Notepad: style · Shares styles into module shadow roots.
- Registry → Notepad: launches · Describes an available module for the shell launcher.
- Registry → Files: launches · Describes an available module for the shell launcher.
- Registry → Settings: launches · Describes an available module for the shell launcher.
- Registry → About: launches · Describes an available module for the shell launcher.
- Registry → Boilerplate: launches · Describes an available module for the shell launcher.
- Settings → Shell API: uses · Settings uses the injected shell API for title and state interactions.
- Notepad → Shell API: uses · Notepad uses the injected shell API for window and notification actions.
- Files → Data API: persistence · Files routes workspace content operations through the data bridge.
- Data API → Data Route: http · Frontend persistence bridge calls the backend data route.
- Backend Entry → Auth Route: registers · Bootstraps auth endpoints.
- Backend Entry → Data Route: registers · Bootstraps data endpoints.
- Backend Entry → Workspaces: registers · Bootstraps workspace endpoints.
- Backend Entry → Members: registers · Bootstraps membership endpoints.
- Backend Entry → Invites: registers · Bootstraps invitation endpoints.
- Auth Route → Session: session · Uses session helpers for authentication state.
- Data Route → DB Layer: persist · Reads and writes stored workspace data.
- Data Route → Change Log: track · Tracks changes for sync or patch semantics.
- Workspaces → DB Layer: persist · Stores workspace records and tenancy data.
- Members → DB Layer: persist · Stores workspace membership records.
- Invites → DB Layer: persist · Stores invitation records and access links.
- Tailwind Config → Shadow CSS: feeds · Build inputs support the shared shadow DOM styling layer.
- Netlify → index.html: deploys · Static hosting serves the browser entry and frontend assets.