# 10xrashed/webos architecture

> Architecture diagram of the GitHub repository 10xrashed/webos, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/10xrashed/webos
- Repository: https://github.com/10xrashed/webos

## Overview

##### Project Type and Purpose
- This is a client-only, browser-based “operating system” environment implemented as a single-page HTML/CSS/JS application (`webOS.html`).
- It simulates a Linux-like desktop: window manager, terminal emulator, virtual file system (VFS), built-in apps, games, and persistent storage via LocalStorage.

##### Key Architectural Components
a. Browser Host Environment
- The web browser is the runtime container (Chromium, Firefox, Safari).
- Provides DOM, CSS rendering, JavaScript engine, LocalStorage API, event loop.
b. UI & Window Management Layer
- Window manager: handles creation, dragging, resizing, minimizing/maximizing, closing.
- Taskbar & system tray: tracks open windows, clock, indicators.
- Start menu & context menus: dynamic menus bound to right-click or start button.
- Theme engine: CSS classes for Dark, Light, Retro, Neon.
c. Core Services Layer
- Virtual File System (VFS) service: in-memory directory tree mirrored to LocalStorage.
- Persistence module: serializes VFS state on each file operation and on shutdown to LocalStorage; restores at boot.
- Settings manager: stores user preferences (theme, wallpaper) in LocalStorage.
d. Terminal & Command Interpreter
- Terminal UI component: text input/output, history buffer, prompt.
- Command parser/executor: maps commands (ls, cd, cat, git, docker, etc.) to JS functions.
- Extensions: tab completion, command history navigation, sudo simulation, neofetch display.
e. Applications Suite
- Built-in apps loaded dynamically in windows—each is a JS module that interfaces with Core Services and UI.
- File Explorer: graphical tree view of VFS.
- Code Editor: text editing, syntax highlighting.
- Web Browser: simulated multi-page environment.
- Music Player, Calculator, Email Client, Calendar, System Monitor, Games (Snake, TTT, Guessing).
f. System Monitor
- Polls browser performance APIs (memory, CPU usage, FPS) and renders charts.

##### Interactions & Data Flows
- User → Browser UI → Window Manager → App Modules
- App Modules ↔ Core Services (VFS, Settings) via service APIs
- Terminal ↔ Core Services & App Modules (e.g., file operations, launching apps)
- Core Services ↔ LocalStorage (persistence)
- System Monitor ← Browser performance APIs

##### Architectural Patterns & Design Principles
- Modular, single-page architecture: discrete JS modules for core services, UI components, applications.
- MVC-like within each app: e.g., File Explorer separates view (tree UI), model (VFS node), controller (user actions).
- Pub/Sub or event bus for inter-module communication (e.g., file system events trigger UI updates).
- Client-side persistence: LocalStorage as durable store.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser Host Environment
    Host["Browser Host Environment\n(HTML5/CSS3/JS)"]:::browser
    click Host "https://github.com/10xrashed/webos/blob/main/webOS.html"

    %% UI & Window Management Layer
    subgraph "UI & Window Management Layer"
        direction TB
        WM["Window Manager"]:::ui
        TBAR["Taskbar & System Tray"]:::ui
        MENU["Start & Context Menus"]:::ui
        THEME["Theme Engine"]:::ui
    end
    click WM "https://github.com/10xrashed/webos/blob/main/webOS.html"
    click TBAR "https://github.com/10xrashed/webos/blob/main/webOS.html"
    click MENU "https://github.com/10xrashed/webos/blob/main/webOS.html"
    click THEME "https://github.com/10xrashed/webos/blob/main/webOS.html"

    %% Core Services Layer
    subgraph "Core Services Layer"
        direction TB
        VFS["VFS Service"]:::core
        PERSIST["Persistence Module"]:::core
        SETTINGS["Settings Manager"]:::core
    end
    click VFS "https://github.com/10xrashed/webos/blob/main/webOS.html"
    click PERSIST "https://github.com/10xrashed/webos/blob/main/webOS.html"
    click SETTINGS "https://github.com/10xrashed/webos/blob/main/webOS.html"

    %% Terminal & Command Interpreter
    Terminal["Terminal & Command Interpreter"]:::ui
    click Terminal "https://github.com/10xrashed/webos/blob/main/webOS.html"

    %% Applications Suite
    subgraph "Applications Suite"
        direction TB
        FE["File Explorer"]:::ui
        CE["Code Editor"]:::ui
        WB["Web Browser App"]:::ui
        MP["Music Player"]:::ui
        CALC["Calculator"]:::ui
        EM["Email Client"]:::ui
        CAL["Calendar"]:::ui
        SM["System Monitor"]:::ui
        GAMES["Games"]:::ui
    end
    click FE "https://github.com/10xrashed/webos/blob/main/webOS.html"
    click CE "https://github.com/10xrashed/webos/blob/main/webOS.html"
    click WB "https://github.com/10xrashed/webos/blob/main/webOS.html"
    click MP "https://github.com/10xrashed/webos/blob/main/webOS.html"
    click CALC "https://github.com/10xrashed/webos/blob/main/webOS.html"
    click EM "https://github.com/10xrashed/webos/blob/main/webOS.html"
    click CAL "https://github.com/10xrashed/webos/blob/main/webOS.html"
    click SM "https://github.com/10xrashed/webos/blob/main/webOS.html"
    click GAMES "https://github.com/10xrashed/webos/blob/main/webOS.html"

    %% Storage
    LocalStorage["LocalStorage\n(cylinder)"]:::storage

    %% Connections
    Host --> UI_Manager([UI & Window Manager Layer])
    Host --> Core_Services([Core Services Layer])
    Host --> Terminal
    Host --> Apps_Suite([Applications Suite])

    WM -->|manages windows| FE
    WM -->|manages windows| CE
    WM -->|manages windows| WB
    WM -->|manages windows| MP

    FE -->|"uses"| VFS
    CE -->|"uses"| VFS
    WB -->|"uses"| Settings
    Terminal -->|"API calls"| VFS
    Terminal -->|"API calls"| SETTINGS
    Terminal -->|"launch apps"| Apps_Suite

    VFS -->|"serialize/restore"| PERSIST
    PERSIST -->|"read/write"| LocalStorage
    SETTINGS -->|"read/write"| LocalStorage
    SM -->|"polls"| Host

    %% Event Bus (pub/sub)
    classDef dashed stroke-dasharray: 5 5;
    UI_Manager -.->|events| VFS:::dashed
    Apps_Suite -.->|events| PERSIST:::dashed
    Terminal -.->|events| SETTINGS:::dashed

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6,stroke-width:1px;
    classDef core fill:#DFFFD0,stroke:#2e7d32,stroke-width:1px;
    classDef storage fill:#FFF7D0,stroke:#f9a825,stroke-width:1px;
    classDef browser fill:#E0E0E0,stroke:#616161,stroke-width:1px;
    classDef dashed stroke-dasharray: 5 5;
```
