Architecture Overview
Time Capsule is a Progressive Web App that recreates the 1990s Unix CDE (Common Desktop Environment) desktop experience. The architecture follows a modular, event-driven design pattern built on modern web technologies.System Design
The application follows a layered architecture with clear separation of concerns:Core Principles
1. Modular Architecture
Each core system is implemented as an independent module with a well-defined interface. This promotes code reusability and maintainability.2. Event-Driven Communication
Components communicate through custom events dispatched on the window object, promoting loose coupling:3. Singleton Pattern for Core Systems
Core systems use the singleton pattern to ensure single instances throughout the application lifecycle:4. Progressive Enhancement
The application provides a functional experience even with limited JavaScript, with enhanced features loading progressively.Core Components
WindowManager
Handles all window lifecycle operations including creation, positioning, focus management, and z-index ordering. Key Responsibilities:- Window registration and lifecycle management
- Drag and drop functionality
- Z-index management (base: 10000 for windows, 90000 for modals)
- Focus management with click and point-to-focus modes
- Window state persistence (position, maximized state)
- Workspace management (4 virtual desktops)
- Mobile-specific centering and constraints
Virtual Filesystem (VFS)
Provides a POSIX-like filesystem abstraction in browser memory with O(1) path lookups. Key Features:- Hierarchical folder structure
- File metadata (size, mtime, owner, permissions)
- CRUD operations (touch, mkdir, rm, rename, move, copy)
- Trash functionality
- Search with recursive option
- Event notifications on changes
SettingsManager
Centralized configuration management with persistent storage. Features:- Unified settings storage
- Version-aware cache management
- Migration from legacy localStorage keys
- Section-based organization (theme, mouse, keyboard, beep, session, desktop)
- Window session persistence
AudioManager
Retro audio system using Web Audio API for classic CDE system sounds. Capabilities:- Lazy AudioContext initialization (on first user gesture)
- System beeps with configurable frequency/duration
- UI feedback sounds (click, error, success)
- Window operation sounds (open, close, minimize, maximize, shade)
- Melody playback for startup chimes
- Volume control
StyleManager
Orchestrates multiple style modules for system customization. Modules:- ThemeModule: Color palette management (CDE palettes)
- FontModule: Font family and sizing controls
- MouseModule: Cursor settings and acceleration
- KeyboardModule: Keyboard repeat and shortcuts
- BeepModule: Audio feedback settings
- BackdropModule: Wallpaper/backdrop management with XPM parsing
- WindowModule: Window behavior (focus mode, opaque dragging)
- ScreenModule: Screen settings
- StartupModule: Boot sequence customization
Configuration System
Centralized configuration inconfig.ts provides type-safe access to all system constants:

