# kaeruct/desk.glitchy.website architecture

> Architecture diagram of the GitHub repository kaeruct/desk.glitchy.website, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kaeruct/desk.glitchy.website
- Repository: https://github.com/kaeruct/desk.glitchy.website

## Overview

##### Main Components

A. Core System Layer
- Window Management System (based on programs.js)
- Event Handler System (util.js)
- File System Simulation (filesystem.js)

B. Application Layer
- Multiple Desktop Applications:
- File Explorer (explorer.js)
- Media Player (winamp.js, videoplayer.js)
- Terminal (terminal.js)
- Games (asteroids.js, lettershooter.js, sandtoy.js)
- Utilities (clock.js, notepad.js)

C. Resource Management
- Asset Manager for:
- Audio Files (/audio)
- Video Files (/vid)
- Styles (multiple .css files)

D. UI Components
- Desktop Environment
- Window Controls
- Task Bar
- Start Menu

- [User Interface Layer]
- ↑↓
- [Application Layer]
- ↑↓
- [Core Systems Layer]
- ↑↓
- [Resource Layer]

##### Key Architectural Elements to Highlight

a. Window Management System
- How it manages multiple application windows
- Event handling for window operations
- Z-index management for window stacking

b. Application Integration
- How individual applications integrate with the core system
- Demonstrate resource loading paths
- Inter-application communication if any

c. File System Simulation
- Relationship between the file explorer and filesystem.js
- How the js-fileexplorer component integrates

##### Implementation Details

- Event propagation system
- Resource loading and caching mechanisms
- Window state management
- Application lifecycle management

##### Notes

- Keep the main desktop UI as the central focus
- Related applications together
- Clear boundaries between system and application code
- Entry points and initialization flow

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI
        Desktop["Desktop Environment"]
        TaskBar["Task Bar"]
        StartMenu["Start Menu"]
        WinControls["Window Controls"]
    end

    subgraph CoreSystem
        WMS["Window Management System"]:::core
        EHS["Event Handler System"]:::core
        FSS["File System Simulation"]:::core
    end

    subgraph Apps
        direction TB
        subgraph MediaApps
            Winamp["Media Player (Winamp)"]:::app
            VideoPlayer["Video Player"]:::app
        end

        subgraph Utilities
            Clock["Clock"]:::app
            Notepad["Notepad"]:::app
            Terminal["Terminal"]:::app
            Browser["Browser"]:::app
            Explorer["File Explorer"]:::app
            Messenger["Messenger"]:::app
        end

        subgraph Games
            Asteroids["Asteroids"]:::app
            LetterShooter["Letter Shooter"]:::app
            SandToy["Sand Toy"]:::app
        end
    end

    subgraph Resources
        AssetMgr["Asset Manager"]
        subgraph Assets
            Audio["Audio Files"]:::resource
            Video["Video Files"]:::resource
            Styles["Style Sheets"]:::resource
        end
    end

    %% Core System Relationships
    Desktop --> WMS
    WMS --> EHS
    WMS --> FSS
    
    %% UI Relationships
    Desktop --> TaskBar
    Desktop --> StartMenu
    Desktop --> WinControls
    
    %% App Relationships
    WMS --> Apps
    Apps --> AssetMgr
    AssetMgr --> Assets
    
    %% Resource Relationships
    FSS --> Explorer
    
    %% Styling
    classDef core fill:#a8d1f0,stroke:#333
    classDef app fill:#90EE90,stroke:#333
    classDef resource fill:#DDA0DD,stroke:#333
    
    %% Click Events
    click WMS "https://github.com/KaeruCT/desk.glitchy.website/blob/master/src/programs.js"
    click EHS "https://github.com/KaeruCT/desk.glitchy.website/blob/master/src/util.js"
    click FSS "https://github.com/KaeruCT/desk.glitchy.website/blob/master/src/filesystem.js"
    click Explorer "https://github.com/KaeruCT/desk.glitchy.website/blob/master/src/explorer.js"
    click Winamp "https://github.com/KaeruCT/desk.glitchy.website/blob/master/src/winamp.js"
    click VideoPlayer "https://github.com/KaeruCT/desk.glitchy.website/blob/master/src/videoplayer.js"
    click Terminal "https://github.com/KaeruCT/desk.glitchy.website/blob/master/src/terminal.js"
    click Asteroids "https://github.com/KaeruCT/desk.glitchy.website/blob/master/src/asteroids.js"
    click LetterShooter "https://github.com/KaeruCT/desk.glitchy.website/blob/master/src/lettershooter.js"
    click SandToy "https://github.com/KaeruCT/desk.glitchy.website/blob/master/src/sandtoy.js"
    click Clock "https://github.com/KaeruCT/desk.glitchy.website/blob/master/src/clock.js"
    click Notepad "https://github.com/KaeruCT/desk.glitchy.website/blob/master/src/notepad.js"
    click Audio "https://github.com/KaeruCT/desk.glitchy.website/tree/master/src/audio/"
    click Video "https://github.com/KaeruCT/desk.glitchy.website/tree/master/src/vid/"
    click Styles "https://github.com/KaeruCT/desk.glitchy.website/blob/master/src/styles.css"
    click Browser "https://github.com/KaeruCT/desk.glitchy.website/blob/master/src/browser.js"
    click Messenger "https://github.com/KaeruCT/desk.glitchy.website/blob/master/src/messenger.js"

    %% Legend
    subgraph Legend
        L1["Core System"]:::core
        L2["Applications"]:::app
        L3["Resources"]:::resource
    end
```
