# BlackRoad Web Client (Pocket OS) **Version:** 0.1.0 **Status:** Phase 2 Enhanced ## Overview The BlackRoad Web Client (codename: **Pocket OS**) is the browser-facing frontend for BlackRoad OS. It provides a Windows 95-inspired desktop interface powered by vanilla JavaScript with zero dependencies. ## Architecture ``` web-client/ ├── README.md # This file └── (Primary code is in backend/static/) backend/static/ ├── index.html # Main OS interface ├── js/ │ ├── api-client.js # Legacy API client │ ├── core-os-client.js # New Core OS client (Phase 2) │ ├── apps.js # Application definitions │ └── auth.js # Authentication └── assets/ ├── css/ # Stylesheets ├── images/ # Icons and images └── fonts/ # Custom fonts ``` ## Features ### Phase 1 (Existing) - ✅ Windows 95-style desktop UI - ✅ Window management (drag, resize, minimize, maximize) - ✅ Start menu and taskbar - ✅ Multiple built-in applications - ✅ Authentication system - ✅ API integration ### Phase 2 (New) - ✅ Core OS Client (`core-os-client.js`) - ✅ System version API integration - ✅ Public config API integration - ✅ OS state management client-side - ✅ Event-driven architecture - 🔄 Real-time state sync (coming soon) - 🔄 WebSocket support (coming soon) ## Quick Start ### Running the Web Client The web client is served by the FastAPI backend at `/`: ```bash # Start backend cd backend uvicorn app.main:app --reload # Visit http://localhost:8000/ # The OS interface loads automatically ``` ### Using Core OS Client ```javascript // Initialize Core OS const result = await window.coreOS.initialize(); console.log('OS Version:', result.version); console.log('OS Config:', result.config); console.log('OS State:', result.state); // Listen for state updates window.coreOS.on('state:updated', (state) => { console.log('State changed:', state); }); // Check backend health const healthy = await window.coreOS.healthCheck(); console.log('Backend healthy:', healthy); // Get system version const version = await window.coreOS.getVersion(); console.log('System version:', version.version); ``` ## API Endpoints Used The web client communicates with these backend endpoints: - `GET /health` - Backend health check - `GET /api/system/version` - System version and build info - `GET /api/system/config/public` - Public configuration - `GET /api/system/os/state` - Current OS state - `GET /api/auth/*` - Authentication endpoints - `GET /api/agents/*` - Agent library - And 30+ other API endpoints for apps ## Integration with Core OS Runtime The web client integrates with the Core OS Runtime (Python) via HTTP API: ``` ┌─────────────────────┐ │ Web Browser │ │ (Pocket OS UI) │ └──────────┬──────────┘ │ HTTP/WebSocket ▼ ┌─────────────────────┐ │ Backend API │ │ (FastAPI) │ └──────────┬──────────┘ │ Python imports ▼ ┌─────────────────────┐ │ Core OS Runtime │ │ (Python) │ └─────────────────────┘ ``` ## File Structure ### Main Entry Point - **`backend/static/index.html`** - Main OS interface (97KB) - Includes complete Windows 95-style UI - Desktop with draggable icons - Taskbar with Start menu - System tray with clock - Multiple pre-built applications ### JavaScript Modules #### Legacy (Phase 1) - **`api-client.js`** (11KB) - REST API client - Authentication helpers - Request/response handling - **`apps.js`** (33KB) - Application definitions - Window management - App lifecycle hooks - **`auth.js`** (11KB) - Login/logout - Session management - Token handling #### New (Phase 2) - **`core-os-client.js`** (2KB) - Core OS API integration - System state management - Event system - Health monitoring ## Development Workflow ### Making Changes 1. **Edit files** in `backend/static/` ```bash cd backend/static # Edit index.html or js/*.js ``` 2. **No build step required** - Vanilla JS, direct changes ``` # Just refresh browser! ``` 3. **Test locally** ```bash cd backend uvicorn app.main:app --reload # Visit http://localhost:8000/ ``` ### Adding a New Application 1. **Define app** in `apps.js`: ```javascript window.Apps.MyNewApp = { init() { console.log('App initialized'); }, render() { return `