# BlackRoad OS Repository Map > **Version:** Phase 2 Scaffold > **Last Updated:** 2025-11-18 > **Branch:** `claude/os-phase2-scaffold-01LKeSDWFNBtXhhsV2xMbM4T` ## Overview This document maps all Phase 2 scaffolded components within the BlackRoad-Operating-System monorepo. ## Repository Structure All components are housed in the **single monorepo**: - **Repo:** `blackboxprogramming/BlackRoad-Operating-System` - **Approach:** Monorepo with modular services - **Future:** May extract to separate repos if needed --- ## Component Map ### 1. Backend API | Property | Value | |----------|-------| | **Location** | `backend/` | | **Language** | Python (FastAPI) | | **New Endpoints** | `/api/system/version`, `/api/system/config/public`, `/api/system/os/state` | | **Tests** | `backend/tests/test_system.py` | | **CI Workflow** | `.github/workflows/backend-tests.yml` | | **Run Command** | `cd backend && uvicorn app.main:app --reload` | | **API Docs** | `http://localhost:8000/api/docs` | **Key Features:** - 30+ existing API routers - New system endpoints for OS integration - JWT authentication - PostgreSQL + Redis integration **How to Run:** ```bash cd backend uvicorn app.main:app --reload # πŸ—ΊοΈ BlackRoad OS Repository Map **Version**: 2.5 **Date**: 2025-11-18 **Purpose**: Complete module-by-module breakdown showing how components connect --- ## Repository Structure ``` BlackRoad-Operating-System/ # Canonical OS monorepo β”œβ”€β”€ backend/ # FastAPI backend + static UI β”‚ β”œβ”€β”€ app/ # Core application β”‚ β”‚ β”œβ”€β”€ main.py # FastAPI app, router registration β”‚ β”‚ β”œβ”€β”€ config.py # Settings (Pydantic) β”‚ β”‚ β”œβ”€β”€ database.py # SQLAlchemy async sessions β”‚ β”‚ β”œβ”€β”€ redis_client.py # Redis connection pool β”‚ β”‚ β”œβ”€β”€ models/ # Database models (SQLAlchemy) β”‚ β”‚ β”œβ”€β”€ routers/ # API endpoint routers (33+) β”‚ β”‚ β”œβ”€β”€ services/ # Business logic layer β”‚ β”‚ └── utils/ # Shared utilities β”‚ β”œβ”€β”€ static/ # Frontend UI (canonical) β”‚ β”‚ β”œβ”€β”€ index.html # Main OS interface β”‚ β”‚ β”œβ”€β”€ prism/ # Prism Console UI β”‚ β”‚ β”œβ”€β”€ js/ # JavaScript modules β”‚ β”‚ └── assets/ # CSS, images, fonts β”‚ β”œβ”€β”€ tests/ # Backend test suite β”‚ β”œβ”€β”€ requirements.txt # Python dependencies β”‚ └── Dockerfile # Container definition β”‚ β”œβ”€β”€ agents/ # 200+ AI agent ecosystem β”‚ β”œβ”€β”€ base/ # Core agent framework β”‚ β”œβ”€β”€ categories/ # 10 agent categories β”‚ └── tests/ # Agent tests β”‚ β”œβ”€β”€ sdk/ # Client SDKs β”‚ β”œβ”€β”€ python/ # Python SDK β”‚ └── typescript/ # TypeScript SDK β”‚ β”œβ”€β”€ codex-docs/ # MkDocs documentation β”‚ β”œβ”€β”€ mkdocs.yml # Docs configuration β”‚ β”œβ”€β”€ docs/ # Markdown documentation β”‚ └── DEPLOY_DOCS.md # Deployment guide β”‚ β”œβ”€β”€ infra/ # Infrastructure configs β”‚ β”œβ”€β”€ cloudflare/ # DNS, Workers β”‚ β”œβ”€β”€ railway/ # Railway deployment β”‚ └── env/ # Environment variables β”‚ β”œβ”€β”€ .github/ # GitHub automation β”‚ β”œβ”€β”€ workflows/ # CI/CD pipelines β”‚ └── CODEOWNERS # Code ownership β”‚ β”œβ”€β”€ docs/ # Legacy docs (consolidating to codex-docs/) β”œβ”€β”€ scripts/ # Utility scripts β”œβ”€β”€ ops/ # Operations tools └── [Root documentation files] β”œβ”€β”€ README.md # Project overview β”œβ”€β”€ CLAUDE.md # AI assistant guide β”œβ”€β”€ MASTER_ORCHESTRATION_PLAN.md # Infrastructure blueprint β”œβ”€β”€ PHASE2_5_SUMMARY_FOR_ALEXA.md # Phase 2.5 summary └── DEPLOYMENT_NOTES.md # Production deployment guide ``` --- ## Module Connections & Data Flow ### 1. Request Flow (User β†’ Backend β†’ Database) ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ USER BROWSER β”‚ β”‚ - Visits: https://blackroad.systems β”‚ β”‚ - Loads: backend/static/index.html β”‚ β”‚ - Executes: JavaScript (OS boot) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↓ HTTP Request β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ CLOUDFLARE CDN β”‚ β”‚ - DNS resolution β”‚ β”‚ - SSL termination β”‚ β”‚ - Static asset caching β”‚ β”‚ - DDoS protection β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↓ Proxy β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ RAILWAY β†’ FastAPI Backend (backend/app/main.py) β”‚ β”‚ β”‚ β”‚ Request Handling: β”‚ β”‚ 1. CORS Middleware (app/main.py:78) β”‚ β”‚ 2. Timing Middleware (app/main.py:89) β”‚ β”‚ 3. Router Matching β”‚ β”‚ β”‚ β”‚ Routes: β”‚ β”‚ β€’ GET / β†’ StaticFiles(backend/static/) β”‚ β”‚ β€’ GET /prism β†’ StaticFiles(backend/static/prism/) β”‚ β”‚ β€’ GET /api/docs β†’ OpenAPI documentation β”‚ β”‚ β€’ GET /health β†’ Health check endpoint β”‚ β”‚ β€’ POST /api/auth/login β†’ auth.router β”‚ β”‚ β€’ GET /api/prism/jobs β†’ prism.router (future) β”‚ β”‚ β€’ [30+ other API routes] β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↓ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ ROUTER LAYER (backend/app/routers/) β”‚ β”‚ β”‚ β”‚ Example: POST /api/auth/login β”‚ β”‚ 1. routers/auth.py:login() β”‚ β”‚ 2. Validate request (Pydantic schema) β”‚ β”‚ 3. Call service layer β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↓ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ SERVICE LAYER (backend/app/services/) β”‚ β”‚ β”‚ β”‚ Example: services/auth.py β”‚ β”‚ 1. authenticate_user(email, password) β”‚ β”‚ 2. Query database via models β”‚ β”‚ 3. Verify password hash β”‚ β”‚ 4. Generate JWT token β”‚ β”‚ 5. Store session in Redis β”‚ β”‚ 6. Return user data + token β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↓ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ DATA LAYER β”‚ β”‚ β”‚ β”‚ PostgreSQL (Railway managed): β”‚ β”‚ β€’ app/database.py β†’ async session β”‚ β”‚ β€’ app/models/ β†’ SQLAlchemy ORM β”‚ β”‚ β€’ Tables: users, wallets, blocks, etc. β”‚ β”‚ β”‚ β”‚ Redis (Railway managed): β”‚ β”‚ β€’ app/redis_client.py β†’ connection pool β”‚ β”‚ β€’ Usage: sessions, caching, WebSocket state β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↓ Response β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ BROWSER (JavaScript) β”‚ β”‚ - Receives JSON response β”‚ β”‚ - Updates OS UI (DOM manipulation) β”‚ β”‚ - Stores token in localStorage β”‚ β”‚ - Makes subsequent API calls with auth header β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ### 2. Core OS Runtime | Property | Value | |----------|-------| | **Location** | `core_os/` | | **Language** | Python | | **Key Files** | `models.py`, `state.py`, `adapters/api_client.py` | | **Tests** | `core_os/tests/` | | **CI Workflow** | `.github/workflows/core-os-tests.yml` | | **README** | `core_os/README.md` | **Key Features:** - `UserSession`, `Window`, `OSState` models - State management functions (open_window, close_window, etc.) - Backend API adapter for communication - In-memory state storage (future: Redis/PostgreSQL) **How to Run:** ```python from core_os import get_initial_state, open_window state = get_initial_state() state = open_window("notepad") ``` --- ### 3. Operator Engine | Property | Value | |----------|-------| | **Location** | `operator_engine/` | | **Language** | Python | | **Key Files** | `jobs.py`, `scheduler.py`, `server.py` | | **Tests** | `operator_engine/tests/` | | **CI Workflow** | `.github/workflows/operator-tests.yml` | | **Run Command** | `python -m operator_engine.server` | | **README** | `operator_engine/README.md` | **Key Features:** - In-memory job registry with example jobs - Simple interval-based scheduler - Optional HTTP API on port 8001 - Job lifecycle management (pending, running, completed, failed) **How to Run:** ```bash # As a library python -c "from operator_engine import Scheduler; print('OK')" # As a service python -m operator_engine.server # Visit http://localhost:8001/docs ## 2. Frontend Architecture (Vanilla JavaScript) ### Main OS (backend/static/) ``` static/ β”œβ”€β”€ index.html # OS entry point β”‚ └── Loads: β”‚ β”œβ”€β”€ css/os.css # OS styling β”‚ β”œβ”€β”€ js/os.js # Core OS runtime β”‚ β”œβ”€β”€ js/components.js # UI component library β”‚ β”œβ”€β”€ js/registry.js # App registry β”‚ └── js/apps/*.js # Individual apps β”‚ β”œβ”€β”€ js/ β”‚ β”œβ”€β”€ os.js # Core OS β”‚ β”‚ β”œβ”€β”€ window.OS object # Global OS namespace β”‚ β”‚ β”œβ”€β”€ Event bus # Inter-app communication β”‚ β”‚ β”œβ”€β”€ Window manager # Draggable windows β”‚ β”‚ └── State management # Local storage β”‚ β”‚ β”‚ β”œβ”€β”€ components.js # UI Components β”‚ β”‚ β”œβ”€β”€ Button() # Button component β”‚ β”‚ β”œβ”€β”€ Card() # Card component β”‚ β”‚ β”œβ”€β”€ Modal() # Modal dialog β”‚ β”‚ └── [12+ other components] β”‚ β”‚ β”‚ β”œβ”€β”€ registry.js # App Registry β”‚ β”‚ β”œβ”€β”€ List of all apps # Icon, name, category β”‚ β”‚ └── App initialization # Load on demand β”‚ β”‚ β”‚ └── apps/ # Application Modules β”‚ β”œβ”€β”€ prism.js # Prism Console app β”‚ β”œβ”€β”€ lucidia.js # AI chat app β”‚ β”œβ”€β”€ miners.js # Mining app β”‚ β”œβ”€β”€ dashboard.js # Dashboard app β”‚ └── [20+ other apps] β”‚ └── assets/ β”œβ”€β”€ css/ # Stylesheets β”‚ β”œβ”€β”€ os.css # Main OS styles β”‚ β”œβ”€β”€ win95.css # Windows 95 theme β”‚ └── components.css # Component styles β”‚ └── images/ # Icons, logos, backgrounds ``` ### Prism Console (backend/static/prism/) ``` prism/ β”œβ”€β”€ index.html # Prism entry point (served at /prism) β”‚ └── Loads: β”‚ β”œβ”€β”€ css/prism.css # Prism-specific styling β”‚ β”œβ”€β”€ js/prism-core.js # Prism runtime β”‚ └── js/prism-components.js # Prism UI components β”‚ β”œβ”€β”€ js/ β”‚ β”œβ”€β”€ prism-core.js # Core Prism logic β”‚ β”‚ β”œβ”€β”€ Job queue management # Monitor running jobs β”‚ β”‚ β”œβ”€β”€ Event log viewer # System event stream β”‚ β”‚ β”œβ”€β”€ Metrics dashboard # Health, performance β”‚ β”‚ └── API client # Calls /api/prism/* β”‚ β”‚ β”‚ └── prism-components.js # Prism-specific UI β”‚ β”œβ”€β”€ JobCard() # Job display card β”‚ β”œβ”€β”€ LogViewer() # Event log component β”‚ └── MetricsChart() # Metrics visualization β”‚ └── assets/ └── css/prism.css # Prism styling ``` ### Communication Pattern ```javascript // Example: Prism Console fetching jobs // 1. Prism UI component (prism/js/prism-core.js) async function fetchJobs() { const response = await fetch('/api/prism/jobs', { headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}` } }); const jobs = await response.json(); renderJobs(jobs); } // 2. Backend router (backend/app/routers/prism.py) @router.get("/jobs") async def get_jobs( current_user = Depends(get_current_user), db: AsyncSession = Depends(get_db) ): jobs = await db.execute(select(Job).where(Job.user_id == current_user.id)) return jobs.scalars().all() // 3. Response flows back to frontend, rendered in UI ``` --- ### 4. Web Client (Pocket OS) | Property | Value | |----------|-------| | **Location** | `backend/static/` (primary), `web-client/` (docs) | | **Language** | JavaScript (Vanilla), HTML, CSS | | **New File** | `backend/static/js/core-os-client.js` | | **CI Workflow** | `.github/workflows/ci.yml` (HTML/JS validation) | | **Run Command** | Served by backend at `http://localhost:8000/` | | **README** | `web-client/README.md` | **Key Features:** - Windows 95-style desktop UI - New `CoreOSClient` class for API integration - Event-driven architecture - Zero dependencies **How to Run:** ```bash # Start backend (serves frontend at /) cd backend uvicorn app.main:app --reload # Visit http://localhost:8000/ ``` **New in Phase 2:** ```javascript await window.coreOS.initialize(); const version = await window.coreOS.getVersion(); console.log('OS Version:', version.version); ## 3. Backend API Architecture ### Router Organization (backend/app/routers/) ``` routers/ β”œβ”€β”€ auth.py # Authentication β”‚ β”œβ”€β”€ POST /api/auth/register # User registration β”‚ β”œβ”€β”€ POST /api/auth/login # User login β”‚ β”œβ”€β”€ POST /api/auth/refresh # Token refresh β”‚ └── GET /api/auth/me # Current user β”‚ β”œβ”€β”€ prism_static.py # Prism Console static serving (NEW) β”‚ └── GET /prism/* # Serve Prism UI files β”‚ β”œβ”€β”€ prism.py # Prism API (future) β”‚ β”œβ”€β”€ GET /api/prism/jobs # List jobs β”‚ β”œβ”€β”€ POST /api/prism/jobs # Create job β”‚ β”œβ”€β”€ GET /api/prism/jobs/{id} # Get job details β”‚ β”œβ”€β”€ GET /api/prism/events # Event stream β”‚ └── GET /api/prism/metrics # System metrics β”‚ β”œβ”€β”€ dashboard.py # Dashboard data β”‚ β”œβ”€β”€ GET /api/dashboard/stats # System statistics β”‚ └── GET /api/dashboard/activity # Recent activity β”‚ β”œβ”€β”€ blockchain.py # RoadChain β”‚ β”œβ”€β”€ GET /api/blockchain/blocks # List blocks β”‚ β”œβ”€β”€ POST /api/blockchain/blocks # Create block β”‚ └── GET /api/blockchain/verify # Verify chain β”‚ β”œβ”€β”€ ai_chat.py # AI/Lucidia integration β”‚ β”œβ”€β”€ POST /api/chat/message # Send message β”‚ └── GET /api/chat/history # Chat history β”‚ β”œβ”€β”€ miner.py # Mining operations β”‚ β”œβ”€β”€ POST /api/miner/start # Start mining β”‚ β”œβ”€β”€ POST /api/miner/stop # Stop mining β”‚ └── GET /api/miner/stats # Mining statistics β”‚ └── [30+ other routers] # See backend/app/main.py for full list ``` ### Service Layer (backend/app/services/) ``` services/ β”œβ”€β”€ auth.py # Authentication logic β”‚ β”œβ”€β”€ authenticate_user() # Verify credentials β”‚ β”œβ”€β”€ create_access_token() # Generate JWT β”‚ └── verify_token() # Validate JWT β”‚ β”œβ”€β”€ crypto.py # Cryptography β”‚ β”œβ”€β”€ hash_password() # Password hashing β”‚ β”œβ”€β”€ verify_password() # Password verification β”‚ └── encrypt_wallet_key() # Wallet encryption β”‚ β”œβ”€β”€ blockchain.py # RoadChain logic β”‚ β”œβ”€β”€ create_block() # Create new block β”‚ β”œβ”€β”€ verify_chain() # Verify blockchain β”‚ └── calculate_hash() # SHA-256 hashing β”‚ └── [Other services] ``` ### Database Models (backend/app/models/) ``` models/ β”œβ”€β”€ user.py # User model β”‚ β”œβ”€β”€ id: int (PK) β”‚ β”œβ”€β”€ email: str (unique) β”‚ β”œβ”€β”€ password_hash: str β”‚ β”œβ”€β”€ created_at: datetime β”‚ └── Relationships: wallets, jobs β”‚ β”œβ”€β”€ wallet.py # Wallet model β”‚ β”œβ”€β”€ id: int (PK) β”‚ β”œβ”€β”€ user_id: int (FK β†’ users) β”‚ β”œβ”€β”€ address: str (unique) β”‚ β”œβ”€β”€ private_key_encrypted: str β”‚ └── balance: float β”‚ β”œβ”€β”€ block.py # Blockchain block β”‚ β”œβ”€β”€ id: int (PK) β”‚ β”œβ”€β”€ index: int β”‚ β”œβ”€β”€ timestamp: datetime β”‚ β”œβ”€β”€ data: JSON β”‚ β”œβ”€β”€ previous_hash: str β”‚ └── hash: str β”‚ β”œβ”€β”€ job.py # Prism job (future) β”‚ β”œβ”€β”€ id: int (PK) β”‚ β”œβ”€β”€ user_id: int (FK β†’ users) β”‚ β”œβ”€β”€ type: str (e.g., "deploy", "test") β”‚ β”œβ”€β”€ status: str (pending/running/completed/failed) β”‚ β”œβ”€β”€ created_at: datetime β”‚ └── result: JSON β”‚ └── [Other models] ``` --- ### 5. Prism Console | Property | Value | |----------|-------| | **Location** | `prism-console/` | | **Language** | HTML, CSS, JavaScript | | **Entry Point** | `prism-console/index.html` | | **Run Command** | `cd prism-console && python -m http.server 8080` | | **README** | `prism-console/README.md` | **Key Features:** - Modern dark-themed admin UI - Multi-tab navigation (Overview, Jobs, Agents, Logs, System) - System metrics dashboard - Backend API integration - Auto-refresh every 30 seconds **How to Run:** ```bash # Standalone cd prism-console python -m http.server 8080 # Visit http://localhost:8080/ # Or integrate with backend (future) # Visit http://localhost:8000/prism ``` --- ### 6. Documentation (Codex) | Property | Value | |----------|-------| | **Location** | `codex-docs/` | | **Technology** | MkDocs + Material theme | | **Config** | `codex-docs/mkdocs.yml` | | **Source** | `codex-docs/docs/` | | **CI Workflow** | `.github/workflows/docs-build.yml` | | **Run Command** | `cd codex-docs && mkdocs serve` | | **README** | `codex-docs/README.md` | **Key Features:** - Complete system documentation - Architecture guides - Component documentation - API reference - Development guides **How to Run:** ```bash cd codex-docs pip install mkdocs mkdocs-material mkdocstrings mkdocs serve # Visit http://localhost:8000 ## 4. Agent Ecosystem (agents/) ### Base Framework (agents/base/) ``` base/ β”œβ”€β”€ agent.py # Base Agent class β”‚ β”œβ”€β”€ __init__(name, version, category) β”‚ β”œβ”€β”€ async execute() # Main execution method β”‚ β”œβ”€β”€ async initialize() # Setup before execution β”‚ β”œβ”€β”€ async cleanup() # Cleanup after execution β”‚ └── async on_error(error) # Error handling β”‚ β”œβ”€β”€ executor.py # Execution engine β”‚ β”œβ”€β”€ run_agent(agent) # Execute single agent β”‚ β”œβ”€β”€ run_workflow(agents) # Execute agent workflow β”‚ └── schedule_agent(agent, cron) # Schedule recurring execution β”‚ └── registry.py # Agent discovery β”œβ”€β”€ register(agent) # Register agent β”œβ”€β”€ discover() # Auto-discover agents └── get_agent(name) # Get agent by name ``` ### Agent Categories (agents/categories/) ``` categories/ β”œβ”€β”€ devops/ # DevOps agents (30+) β”‚ β”œβ”€β”€ deploy_agent.py # Deployment automation β”‚ β”œβ”€β”€ monitor_agent.py # Infrastructure monitoring β”‚ └── backup_agent.py # Backup automation β”‚ β”œβ”€β”€ engineering/ # Engineering agents (40+) β”‚ β”œβ”€β”€ code_review_agent.py # Code review β”‚ β”œβ”€β”€ test_generator_agent.py # Test generation β”‚ └── refactor_agent.py # Code refactoring β”‚ β”œβ”€β”€ ai_ml/ # AI/ML agents (25+) β”‚ β”œβ”€β”€ model_trainer_agent.py # Model training β”‚ β”œβ”€β”€ data_pipeline_agent.py # Data processing β”‚ └── inference_agent.py # Model inference β”‚ └── [7 more categories] # See agents/README.md ``` ### Agent Communication (via Prism) ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ AGENT A (Deploy Agent) β”‚ β”‚ 1. Execute deployment β”‚ β”‚ 2. Publish event to Prism: {"type": "deploy_complete"} β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↓ Event β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ PRISM (Event Bus) β”‚ β”‚ - Receives event β”‚ β”‚ - Logs to event table (database) β”‚ β”‚ - Publishes to Redis (pub/sub) β”‚ β”‚ - Notifies subscribed agents β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↓ Subscription β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ AGENT B (Monitor Agent) β”‚ β”‚ 1. Receives "deploy_complete" event β”‚ β”‚ 2. Runs health checks β”‚ β”‚ 3. Publishes event: {"type": "health_check_passed"} β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ## CI/CD Workflows All workflows in `.github/workflows/`: | Workflow | Triggers | Tests | Artifact | |----------|----------|-------|----------| | `backend-tests.yml` | backend/* changes | Backend API + system endpoints | Test results | | `core-os-tests.yml` | core_os/* changes | Core OS models + state management | Test results | | `operator-tests.yml` | operator_engine/* changes | Operator jobs + scheduler | Test results | | `docs-build.yml` | codex-docs/* changes | MkDocs build | Documentation site | | `ci.yml` | HTML/JS changes | HTML/JS validation | - | --- ## Integration Flow ### User Request Flow ``` User Browser ↓ Web Client (Pocket OS) β”œβ”€β”€ core-os-client.js β”œβ”€β”€ Calls: GET /api/system/version └── Calls: GET /api/system/os/state ↓ Backend API (FastAPI) β”œβ”€β”€ /api/system/version β†’ system.py router β”œβ”€β”€ /api/system/config/public β†’ system.py router └── /api/system/os/state β†’ system.py router (stub) ↓ Core OS Runtime (future integration) β”œβ”€β”€ get_current_state() └── Returns OSState with windows, desktop, etc. ``` ### Admin/Ops Flow ``` Admin Browser ↓ Prism Console β”œβ”€β”€ prism.js β”œβ”€β”€ Calls: GET /api/system/version β”œβ”€β”€ Calls: GET /api/system/config/public └── Calls: GET /api/operator/jobs (future) ↓ Backend API ↓ Operator Engine (future integration) β”œβ”€β”€ list_jobs() └── execute_job(job_id) ## 5. Documentation (codex-docs/) ### MkDocs Structure ``` codex-docs/ β”œβ”€β”€ mkdocs.yml # Configuration β”‚ β”œβ”€β”€ site_name: "BlackRoad OS Codex" β”‚ β”œβ”€β”€ theme: material # Material for MkDocs β”‚ β”œβ”€β”€ plugins: search, etc. # MkDocs plugins β”‚ └── nav: [navigation structure] # Sidebar navigation β”‚ β”œβ”€β”€ docs/ # Markdown documentation β”‚ β”œβ”€β”€ index.md # Landing page β”‚ β”‚ β”‚ β”œβ”€β”€ architecture/ # Architecture docs β”‚ β”‚ β”œβ”€β”€ overview.md # System overview β”‚ β”‚ β”œβ”€β”€ phase2-decisions.md # Phase 2.5 decisions β”‚ β”‚ └── infra-deployment.md # Deployment architecture β”‚ β”‚ β”‚ β”œβ”€β”€ api/ # API reference β”‚ β”‚ β”œβ”€β”€ authentication.md # Auth endpoints β”‚ β”‚ β”œβ”€β”€ prism.md # Prism API β”‚ β”‚ └── blockchain.md # RoadChain API β”‚ β”‚ β”‚ β”œβ”€β”€ guides/ # User guides β”‚ β”‚ β”œβ”€β”€ quickstart.md # Quick start guide β”‚ β”‚ β”œβ”€β”€ deployment.md # Deployment guide β”‚ β”‚ └── development.md # Development setup β”‚ β”‚ β”‚ β”œβ”€β”€ agents/ # Agent documentation β”‚ β”‚ β”œβ”€β”€ overview.md # Agent ecosystem β”‚ β”‚ β”œβ”€β”€ creating-agents.md # How to create agents β”‚ β”‚ └── categories.md # Agent categories β”‚ β”‚ β”‚ └── contributing.md # Contribution guidelines β”‚ β”œβ”€β”€ DEPLOY_DOCS.md # Deployment guide for docs β”‚ └── site/ # Generated site (gitignored) └── [Built HTML files] ``` ### Documentation Deployment Flow ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ DEVELOPER β”‚ β”‚ 1. Edit markdown in codex-docs/docs/ β”‚ β”‚ 2. Test locally: mkdocs serve β”‚ β”‚ 3. Commit and push to main β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↓ Git Push β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ GITHUB ACTIONS (.github/workflows/docs-deploy.yml) β”‚ β”‚ 1. Checkout code β”‚ β”‚ 2. Install MkDocs + Material theme β”‚ β”‚ 3. Run: mkdocs build --strict β”‚ β”‚ 4. Deploy to gh-pages branch β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↓ Deploy β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ GITHUB PAGES β”‚ β”‚ - Serves from: gh-pages branch β”‚ β”‚ - URL: https://blackboxprogramming.github.io/BlackRoad-* β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↓ DNS β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ CLOUDFLARE β”‚ β”‚ - CNAME: docs.blackroad.systems β†’ blackboxprogramming.github.io β”‚ β”‚ - Proxied: Yes (SSL + CDN) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↓ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ USER β”‚ β”‚ - Visits: https://docs.blackroad.systems β”‚ β”‚ - Views: MkDocs documentation β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ## Request Path Examples ### Example 1: Get System Version **Client Code:** ```javascript const version = await window.coreOS.getVersion(); ``` **HTTP Request:** ``` GET /api/system/version ``` **Backend Route:** ```python # backend/app/routers/system.py @router.get("/version") async def get_version(): return { "version": settings.APP_VERSION, "build_time": datetime.utcnow().isoformat(), "env": settings.ENVIRONMENT, } ``` **Response:** ```json { "version": "1.0.0", "build_time": "2025-11-18T12:00:00", "env": "development", "git_sha": "abc12345" } ## 6. SDK Architecture (sdk/) ### Python SDK (sdk/python/) ```python # Example usage: from blackroad import BlackRoadClient client = BlackRoadClient( base_url="https://blackroad.systems", api_key="your-api-key" ) # Authenticate user = await client.auth.login("email@example.com", "password") # Create a job job = await client.prism.create_job({ "type": "deploy", "target": "production", "config": {...} }) # Monitor job status = await client.prism.get_job_status(job.id) ``` ### TypeScript SDK (sdk/typescript/) ```typescript // Example usage: import { BlackRoadClient } from '@blackroad/sdk'; const client = new BlackRoadClient({ baseUrl: 'https://blackroad.systems', apiKey: 'your-api-key' }); // Authenticate const user = await client.auth.login('email@example.com', 'password'); // Create a job const job = await client.prism.createJob({ type: 'deploy', target: 'production', config: {...} }); // Monitor job const status = await client.prism.getJobStatus(job.id); ``` --- ### Example 2: Get Public Config **Client Code:** ```javascript const config = await window.coreOS.getPublicConfig(); ``` **HTTP Request:** ``` GET /api/system/config/public ``` **Response:** ```json { "environment": "development", "app_name": "BlackRoad Operating System", "version": "1.0.0", "features": { "blockchain_enabled": true, "ai_agents_enabled": true, "video_streaming_enabled": true }, "limits": { "max_upload_size_mb": 100, "session_timeout_minutes": 60 }, "external_services": { "github_integration": true, "stripe_enabled": false, "openai_enabled": true } } ## 7. Infrastructure (infra/) ### Cloudflare (infra/cloudflare/) ``` cloudflare/ β”œβ”€β”€ records.yaml # DNS records β”œβ”€β”€ CLOUDFLARE_DNS_BLUEPRINT.md # DNS configuration guide β”œβ”€β”€ DNS_CONFIGURATION.md # Detailed DNS setup (NEW) └── cloudflare_dns_sync.py # Automated DNS sync script ``` ### Railway (infra/railway/) ``` railway/ β”œβ”€β”€ RAILWAY_DEPLOYMENT_GUIDE.md # Complete deployment guide (NEW) β”œβ”€β”€ railway.toml # Railway configuration └── railway.json # Service definitions ``` ### Environment (infra/env/) ``` env/ └── ENVIRONMENT_MAP.md # Cross-platform env vars ``` --- ### Example 3: Initialize OS (Client-side) **Client Code:** ```javascript const result = await window.coreOS.initialize(); console.log('Version:', result.version); console.log('Config:', result.config); console.log('State:', result.state); ``` **Makes 3 parallel requests:** 1. `GET /api/system/version` 2. `GET /api/system/config/public` 3. `GET /api/system/os/state` --- ## Testing Each Component ### Backend API ```bash cd backend pytest tests/test_system.py -v ``` ### Core OS ```bash pytest core_os/tests/ -v ``` ### Operator Engine ```bash pytest operator_engine/tests/ -v ``` ### Web Client ```bash # Start backend cd backend && uvicorn app.main:app --reload # Open browser: http://localhost:8000/ # Open console: Should see "Core OS Client loaded (v0.1.0)" # Run: await window.coreOS.initialize() ``` ### Prism Console ```bash cd prism-console python -m http.server 8080 # Visit http://localhost:8080/ # Should see system metrics dashboard ``` ### Documentation ```bash cd codex-docs mkdocs build # Check for errors in build output ``` --- ## File Count Summary | Component | Files Created | Tests | CI Workflows | |-----------|--------------|-------|--------------| | Backend API | 1 new router | 1 test file | Existing | | Core OS | 6 files | 2 test files | 1 new workflow | | Operator Engine | 7 files | 2 test files | 1 new workflow | | Web Client | 2 files | Manual | Existing | | Prism Console | 4 files | Manual | None yet | | Documentation | 10+ files | Build test | 1 new workflow | **Total New Files:** ~30+ **Total New Tests:** 5 test files **Total New Workflows:** 3 CI workflows --- ## Environment Variables All modules share these environment variables (set in `backend/.env`): ```bash # Core DATABASE_URL=postgresql+asyncpg://user:pass@host:5432/db REDIS_URL=redis://localhost:6379/0 SECRET_KEY=your-secret-key-here # Application APP_NAME="BlackRoad Operating System" APP_VERSION="1.0.0" ENVIRONMENT=development # Operator SCHEDULER_INTERVAL_SECONDS=60 MAX_CONCURRENT_JOBS=5 # External (optional) GITHUB_TOKEN=... OPENAI_API_KEY=... STRIPE_SECRET_KEY=... ``` --- ## Next Steps (Post-PR) 1. **Merge PR** - Review and merge this scaffold 2. **Deploy to Railway** - Test in production 3. **Integrate Core OS** - Connect backend API to core_os module 4. **Enable Prism Route** - Serve Prism at `/prism` from backend 5. **Add WebSocket** - Real-time state sync 6. **Production Jobs** - Replace stub jobs with real ones 7. **Deploy Docs** - Publish Codex to GitHub Pages --- ## Troubleshooting ### Backend won't start ```bash # Check dependencies pip install -r backend/requirements.txt # Check database # Ensure DATABASE_URL is set # Check ports # Ensure port 8000 is available ``` ### Tests failing ```bash # Install test dependencies pip install pytest pytest-asyncio pytest-cov # Run with verbose output pytest -v --tb=short ``` ### Docs won't build ```bash # Install MkDocs pip install mkdocs mkdocs-material mkdocstrings # Build with strict mode cd codex-docs mkdocs build --strict ``` --- ## Repository Summary **Monorepo:** `blackboxprogramming/BlackRoad-Operating-System` **Branch:** `claude/os-phase2-scaffold-01LKeSDWFNBtXhhsV2xMbM4T` **Components:** 6 modules (API, Core OS, Operator, Web, Prism, Docs) **New Code:** ~3,000 lines (Python + JavaScript + HTML + Markdown) **Tests:** 5 test suites with 15+ tests **CI:** 3 new workflows + 4 existing **Documentation:** 10+ pages in MkDocs --- **Phase 2 Scaffold Complete! Ready for Alexa's review. πŸš€** ## 8. CI/CD (.github/workflows/) ``` workflows/ β”œβ”€β”€ ci.yml # Main CI (lint, test, build) β”œβ”€β”€ backend-tests.yml # Backend test suite β”œβ”€β”€ railway-deploy.yml # Deploy to Railway β”œβ”€β”€ docs-deploy.yml # Deploy docs to GitHub Pages (NEW) β”œβ”€β”€ railway-automation.yml # Railway secrets audit └── [Other workflows] ``` --- ## API Contracts Between Layers ### Frontend ↔ Backend **Authentication:** ```typescript // Request POST /api/auth/login { "email": "user@example.com", "password": "password123" } // Response { "access_token": "eyJhbGciOi...", "token_type": "bearer", "user": { "id": 1, "email": "user@example.com" } } ``` **Prism Jobs:** ```typescript // Request GET /api/prism/jobs Headers: { "Authorization": "Bearer eyJhbGciOi..." } // Response { "data": [ { "id": 1, "type": "deploy", "status": "completed", "created_at": "2025-11-18T12:00:00Z", "result": {...} } ], "total": 42, "page": 1, "per_page": 20 } ``` ### Backend ↔ Database **User Query:** ```python # ORM Query (SQLAlchemy) from app.models.user import User from sqlalchemy import select result = await db.execute( select(User).where(User.email == email) ) user = result.scalar_one_or_none() ``` **Blockchain Query:** ```python # Get latest blocks from app.models.block import Block result = await db.execute( select(Block) .order_by(Block.index.desc()) .limit(10) ) blocks = result.scalars().all() ``` ### Backend ↔ Redis **Session Storage:** ```python # Store session await redis.setex( f"session:{user_id}", 3600, # 1 hour json.dumps({"user_id": user_id, "email": email}) ) # Retrieve session session_data = await redis.get(f"session:{user_id}") ``` **WebSocket State:** ```python # Publish event await redis.publish( "prism:events", json.dumps({"type": "job_completed", "job_id": 123}) ) # Subscribe to events pubsub = redis.pubsub() await pubsub.subscribe("prism:events") ``` --- ## Key Integration Points ### 1. OS β†’ Prism Console - User clicks "Prism Console" app in OS - OS opens window with iframe/route to `/prism` - Prism UI loads, shares auth token from OS - Prism makes API calls to `/api/prism/*` ### 2. Prism β†’ Backend API - Prism fetches jobs: `GET /api/prism/jobs` - Backend queries database via models - Returns JSON response - Prism renders in UI ### 3. Backend β†’ Database - Router receives request - Service layer business logic - ORM query via async session - Results returned to router ### 4. Backend β†’ Redis - Session management - WebSocket state - Caching API responses - Pub/sub for real-time events ### 5. Frontend β†’ Documentation - "Help" link in OS - Opens new tab to `https://docs.blackroad.systems` - MkDocs site served from GitHub Pages - Searchable documentation --- ## Deployment Connections ### Development Environment ``` Developer Machine β”œβ”€β”€ Backend: http://localhost:8000 β”‚ β”œβ”€β”€ OS: http://localhost:8000/ β”‚ β”œβ”€β”€ Prism: http://localhost:8000/prism β”‚ └── API Docs: http://localhost:8000/api/docs β”‚ β”œβ”€β”€ Docs: http://localhost:8001 β”‚ └── mkdocs serve (port 8001) β”‚ β”œβ”€β”€ PostgreSQL: localhost:5432 (via Docker) └── Redis: localhost:6379 (via Docker) ``` ### Production Environment ``` User Browser ↓ Cloudflare CDN (DNS + SSL) ↓ Railway Backend β”œβ”€β”€ FastAPI (port 8000) β”œβ”€β”€ PostgreSQL (Railway managed) └── Redis (Railway managed) GitHub Pages └── Docs (codex-docs/ β†’ gh-pages branch) ``` --- ## Phase 2 vs Phase 3: Monorepo Evolution ### Phase 2 (Current): Monorepo **All in `BlackRoad-Operating-System`:** - βœ… Single source of truth - βœ… Easy cross-component changes - βœ… Simple CI/CD ### Phase 3 (Future): Multi-Repo **When to split:** - Team size > 10 developers - Independent release cycles needed - Different tech stacks emerging **Potential split:** ``` blackroad-os-core β†’ Core runtime (Python) blackroad-os-api β†’ Backend API (Python/FastAPI) blackroad-os-web β†’ Frontend UI (JavaScript) blackroad-os-prism β†’ Prism Console (JavaScript/Python) blackroad-os-operator β†’ Worker engine (Python) blackroad-os-docs β†’ Documentation (Markdown/MkDocs) ``` **Migration strategy:** - Use `git subtree split` to preserve history - Set up cross-repo CI coordination - Implement versioned API contracts - Maintain unified documentation --- ## Summary: How It All Connects 1. **User** visits `blackroad.systems` 2. **Cloudflare** resolves DNS, terminates SSL, proxies to Railway 3. **Railway** runs FastAPI backend 4. **Backend** serves static OS UI from `backend/static/` 5. **OS** boots in browser, renders Windows 95-style interface 6. **User** opens Prism Console app 7. **OS** loads `/prism` route (static Prism UI) 8. **Prism** makes API calls to `/api/prism/*` 9. **Backend** routes to `routers/prism.py` 10. **Router** calls service layer 11. **Service** queries database via models 12. **Database** returns data 13. **Service** returns to router 14. **Router** returns JSON to Prism 15. **Prism** renders data in UI 16. **User** sees job queue, metrics, events **For documentation:** 1. **Developer** edits `codex-docs/docs/` 2. **Push** to main branch 3. **GitHub Actions** runs `mkdocs build` 4. **Deploys** to `gh-pages` branch 5. **GitHub Pages** serves at `blackboxprogramming.github.io/...` 6. **Cloudflare** CNAMEs `docs.blackroad.systems` to GitHub Pages 7. **User** visits `https://docs.blackroad.systems` --- **Where AI meets the open road.** πŸ›£οΈ *Complete repository map showing all module connections and data flows.*