Project Structure Overview
Web XP is organized into a clear directory structure:Component Hierarchy
The application follows a clear component hierarchy:App Component (Root)
The rootApp.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
screen: Current screen to display ('boot','login','welcome','desktop','shuttingDown','restarting','bsod')skillzSessionStatus: User session status trackingshutdownMessages: Messages displayed during shutdowncrashError: Error message for BSOD
src/App.jsx:1
WinXP Component (Desktop)
The main desktop environment component atsrc/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)
- Uses
useMousefromreact-usefor 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
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
src/WinXP/Icons/
Footer (Taskbar)
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
src/WinXP/Footer/
Modal Component
Displays power operation dialogs: Modes:- Log Off: Log off or switch user
- Turn Off: Shutdown, restart, or cancel
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’suseReducer 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:onMouseDownfor focus/selectiononDoubleClickfor opening appsonClickfor 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.cssfor resets
Mobile Support
The application detects mobile devices using user agent detection:- Shows compatibility warning dialog
- Blocks certain apps (Minesweeper, Pinball)
- Adjusts window sizing for smaller screens
src/WinXP/index.jsx:46 and src/WinXP/apps/index.jsx:41