Skip to main content

Project Structure Overview

Web XP is organized into a clear directory structure:
src/
├── App.jsx                 # Root component, manages boot/login/desktop screens
├── index.css               # Global styles
├── WinXP/                  # Core desktop environment
│   ├── index.jsx           # Main WinXP desktop component
│   ├── reducer.js          # State management reducer
│   ├── apps/               # Application registry and definitions
│   │   └── index.jsx       # App settings and default states
│   ├── constants/          # Action types and constants
│   │   ├── actions.js      # Action type constants
│   │   └── index.js        # Other constants (FOCUSING, POWER_STATE)
│   ├── Footer/             # Taskbar component
│   ├── Icons/              # Desktop icons component
│   ├── Modal/              # Power off/log off modals
│   └── Windows/            # Window manager component
├── components/             # Reusable UI components
│   ├── BSOD/               # Blue Screen of Death
│   ├── BootScreen/         # Boot animation
│   ├── LoginScreen/        # Login interface
│   ├── WelcomeScreen/      # Welcome animation
│   ├── ShutdownScreen/     # Shutdown animation
│   ├── DashedBox/          # Drag selection box
│   ├── Balloon/            # System tray notifications
│   ├── VolumeSlider/       # Volume control
│   ├── WindowDropDowns/    # Window menu dropdowns
│   └── SubMenu/            # Start menu submenus
├── context/                # React context providers
│   └── VolumeContext.jsx   # Global volume state
├── hooks/                  # Custom React hooks
└── assets/                 # Static assets
    ├── sounds/             # System sounds
    ├── windowsIcons/       # XP icons and images
    ├── userIcons/          # User avatars
    └── minesweeper/        # Minesweeper assets

Component Hierarchy

The application follows a clear component hierarchy:
App (Root)
├── VolumeProvider (Context)
│   └── AppLogic
│       ├── BootScreen
│       ├── LoginScreen
│       ├── WelcomeScreen
│       ├── BSOD
│       ├── ShutdownScreen
│       └── WinXP (Desktop Environment)
│           ├── Icons (Desktop Icons)
│           ├── DashedBox (Selection Box)
│           ├── Windows (Window Manager)
│           │   └── [Multiple Window instances]
│           ├── Footer (Taskbar)
│           │   ├── Start Button
│           │   ├── SubMenu (Start Menu)
│           │   ├── App Buttons
│           │   ├── System Tray
│           │   ├── VolumeSlider
│           │   └── Clock
│           └── Modal (Power Options)

App Component (Root)

The root App.jsx component manages the overall application flow: Responsibilities:
  • Screen state management (boot → login → welcome → desktop → shutdown)
  • User session tracking (logged out, logged in, active on desktop)
  • Sound playback (startup, logon, logoff, shutdown sounds)
  • Global error handling (catches errors and displays BSOD)
  • Volume context provider wrapper
Key States:
  • screen: Current screen to display ('boot', 'login', 'welcome', 'desktop', 'shuttingDown', 'restarting', 'bsod')
  • skillzSessionStatus: User session status tracking
  • shutdownMessages: Messages displayed during shutdown
  • crashError: Error message for BSOD
File: src/App.jsx:1

WinXP Component (Desktop)

The main desktop environment component at src/WinXP/index.jsx:1: Responsibilities:
  • Desktop state management using useReducer
  • Window operations (add, close, focus, minimize, maximize)
  • Icon selection and interaction
  • Drag-to-select functionality
  • Start menu item handling
  • Power state management (log off, shutdown, restart)
Key Features:
  • Uses useMouse from react-use for mouse tracking
  • Implements mobile device detection and warnings
  • Manages z-index ordering for windows
  • Handles desktop click events for deselecting icons

Windows Manager

Manages all open application windows: Features:
  • Window dragging and resizing
  • Minimize, maximize, restore, close operations
  • Z-index management for window stacking
  • Window focus handling
  • Per-window header with title and icon
Location: src/WinXP/Windows/

Icons Component

Manages desktop icons: Features:
  • Click to select/focus icons
  • Double-click to open applications
  • Drag-to-select (rubber band) support
  • Focus state visualization
  • Icon positioning and layout
Location: src/WinXP/Icons/ The taskbar at the bottom of the screen: Components:
  • Start Button: Opens the start menu
  • SubMenu: Nested start menu with application shortcuts
  • App Buttons: Show running applications, click to minimize/restore
  • System Tray: Volume control and clock
  • VolumeSlider: Global volume control with mute
  • Clock: Displays current time
Location: src/WinXP/Footer/ Displays power operation dialogs: Modes:
  • Log Off: Log off or switch user
  • Turn Off: Shutdown, restart, or cancel
Location: src/WinXP/Modal/

File Organization Principles

WinXP Directory

Contains all core desktop functionality:
  • Main desktop component (index.jsx)
  • State management (reducer.js)
  • Application registry (apps/)
  • Desktop UI components (Footer/, Icons/, Windows/, Modal/)
  • Constants and action types (constants/)

Components Directory

Reusable UI components used across the application:
  • Screen components (Boot, Login, Welcome, Shutdown, BSOD)
  • UI utilities (DashedBox, Balloon, VolumeSlider)
  • Dropdown menus (WindowDropDowns, SubMenu)

Assets Directory

Static files organized by type:
  • sounds/: System sound effects (WAV format)
  • windowsIcons/: XP-style icons and images
  • userIcons/: User avatar images
  • minesweeper/: Game-specific assets

Tech Stack

Core Technologies

  • React 18.3.1 - UI framework with hooks
  • styled-components 6.1.14 - CSS-in-JS styling solution
  • Vite 6.2.0 - Build tool and dev server

Key Libraries

  • webamp 1.3.2-beta.2 - Winamp player implementation
  • react-use 17.6.0 - Collection of React hooks (useMouse, etc.)
  • lodash.samplesize 4.2.0 - Random sampling utility

Development Tools

  • ESLint 8.0.0 - Code linting
  • Prettier 1.18.2 - Code formatting
  • @vitejs/plugin-react 4.3.4 - Vite React plugin

Design Patterns

State Management

Uses React’s useReducer hook for centralized state management (see State Management for details).

Component Composition

Components are composed hierarchically with clear responsibilities:
  • Container components manage state and logic
  • Presentational components handle UI rendering
  • Context providers manage global state (volume)

Event Handling

Event handlers are passed down through props:
  • onMouseDown for focus/selection
  • onDoubleClick for opening apps
  • onClick for menu items and buttons

Styling

All styling uses styled-components:
  • Component-scoped styles
  • Dynamic styling based on props
  • Keyframe animations for transitions
  • No global CSS except index.css for resets

Mobile Support

The application detects mobile devices using user agent detection:
const isMobile = () => {
  const userAgent = navigator.userAgent || navigator.vendor || window.opera;
  return (
    /android/i.test(userAgent) ||
    (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream)
  );
};
On mobile devices:
  • Shows compatibility warning dialog
  • Blocks certain apps (Minesweeper, Pinball)
  • Adjusts window sizing for smaller screens
Implementation: src/WinXP/index.jsx:46 and src/WinXP/apps/index.jsx:41

Build docs developers (and LLMs) love