mirror of
https://github.com/blackboxprogramming/BlackRoad-Operating-System.git
synced 2026-03-17 04:57:15 -05:00
Implements complete Phase 2 scaffold across 6 core modules: ## New Modules ### 1. Backend API Enhancements - Add system router with /version, /config/public, /os/state endpoints - Register system router in main.py - Add comprehensive tests for system endpoints ### 2. Core OS Runtime (core_os/) - Implement UserSession, Window, OSState models - Add state management functions (open_window, close_window, etc.) - Create Backend API adapter for communication - Include full test suite for models and state ### 3. Operator Engine (operator_engine/) - Build job registry with example jobs - Implement simple scheduler with lifecycle management - Optional HTTP server on port 8001 - Complete tests for jobs and scheduler ### 4. Web Client Enhancements - Add CoreOSClient JavaScript class - Integrate system API endpoints - Event-driven architecture for state updates - Zero dependencies, vanilla JavaScript ### 5. Prism Console (prism-console/) - Modern dark-themed admin UI - Multi-tab navigation (Overview, Jobs, Agents, Logs, System) - Real-time metrics dashboard - Backend API integration with auto-refresh ### 6. Documentation (codex-docs/) - Complete MkDocs-based documentation - Architecture guides and component docs - Infrastructure setup guides - API reference documentation ## CI/CD - Add core-os-tests.yml workflow - Add operator-tests.yml workflow - Add docs-build.yml workflow ## Documentation - Create BLACKROAD_OS_REPO_MAP.md cross-reference - Add README for each module - Comprehensive integration documentation ## Summary - 37 new files created - ~3,500 lines of new code - 5 test suites with 15+ tests - 3 new CI workflows - 10+ documentation pages All modules are minimal working skeletons ready for integration. Designed to be extracted into separate repos if needed. Phase 2 scaffold complete and ready for review.
192 lines
5.1 KiB
Markdown
192 lines
5.1 KiB
Markdown
# Architecture Overview
|
|
|
|
BlackRoad OS is built on a **7-layer architecture** that spans from DNS/CDN at the bottom to user-facing applications at the top.
|
|
|
|
## The 7-Layer Stack
|
|
|
|
### Layer 1: DNS & CDN
|
|
**Purpose:** Domain management, SSL, DDoS protection
|
|
|
|
- **Provider:** Cloudflare
|
|
- **Domains:** 10+ domains (blackroad.systems, blackroadai.com, lucidia.earth, etc.)
|
|
- **Features:** DNS routing, SSL termination, caching, DDoS protection
|
|
|
|
### Layer 2: Compute & Infrastructure
|
|
**Purpose:** Application hosting and execution
|
|
|
|
- **Railway:** Production backend (FastAPI, PostgreSQL, Redis)
|
|
- **DigitalOcean:** Future RoadChain nodes
|
|
- **Cloudflare Workers:** Edge functions (future)
|
|
|
|
### Layer 3: Data & State
|
|
**Purpose:** Persistence, caching, and blockchain
|
|
|
|
- **PostgreSQL:** Primary relational database (Railway managed)
|
|
- **Redis:** Caching and session storage
|
|
- **RoadChain:** Tamper-evident audit ledger
|
|
- **Vault:** Compliance and encrypted storage
|
|
|
|
### Layer 4: Orchestration & Intelligence
|
|
**Purpose:** AI, job scheduling, and workflow automation
|
|
|
|
- **Lucidia Layer:** Multi-model AI orchestration (Phase 2)
|
|
- **Prism Layer:** Job queue, event log, metrics
|
|
- **Operator Engine:** Scheduled agents and workflows
|
|
|
|
### Layer 5: API Gateway & Routing
|
|
**Purpose:** HTTP API and WebSocket endpoints
|
|
|
|
- **FastAPI Backend:** REST API + WebSocket
|
|
- **Routes:** 30+ API routers for different services
|
|
- **Features:** Authentication, CORS, rate limiting
|
|
|
|
### Layer 6: Application Layer
|
|
**Purpose:** User-facing applications
|
|
|
|
- **Pocket OS:** Windows 95-style web interface
|
|
- **Prism Console:** Admin dashboard
|
|
- **Native Apps:** RoadStudio, CloudWay, Lucidia Chat, etc.
|
|
|
|
### Layer 7: User Experience
|
|
**Purpose:** Branded domains and landing pages
|
|
|
|
- **blackroad.systems:** Corporate website
|
|
- **os.blackroad.systems:** Main OS interface
|
|
- **prism.blackroad.systems:** Admin console
|
|
- **lucidia.earth:** AI narrative experiences
|
|
|
|
## Request Flow
|
|
|
|
Here's how a user request flows through the system:
|
|
|
|
```
|
|
User Browser
|
|
↓
|
|
Cloudflare DNS (Layer 1)
|
|
↓
|
|
Cloudflare CDN/SSL (Layer 1)
|
|
↓
|
|
Railway Load Balancer (Layer 2)
|
|
↓
|
|
FastAPI Backend (Layer 5)
|
|
↓
|
|
Business Logic (Layer 4: Operator, Prism, Lucidia)
|
|
↓
|
|
Database/Redis/RoadChain (Layer 3)
|
|
↓
|
|
Response → Browser
|
|
```
|
|
|
|
## Module Architecture
|
|
|
|
### Backend API
|
|
```
|
|
backend/
|
|
├── app/
|
|
│ ├── main.py # FastAPI app
|
|
│ ├── routers/ # API endpoints
|
|
│ ├── models/ # Database models
|
|
│ ├── services/ # Business logic
|
|
│ └── utils/ # Helpers
|
|
└── static/ # Frontend assets
|
|
```
|
|
|
|
### Core OS Runtime
|
|
```
|
|
core_os/
|
|
├── models.py # UserSession, Window, OSState
|
|
├── state.py # State management
|
|
└── adapters/
|
|
└── api_client.py # Backend communication
|
|
```
|
|
|
|
### Operator Engine
|
|
```
|
|
operator_engine/
|
|
├── jobs.py # Job definitions
|
|
├── scheduler.py # Scheduling logic
|
|
└── server.py # Optional HTTP API
|
|
```
|
|
|
|
### Web Client (Pocket OS)
|
|
```
|
|
backend/static/
|
|
├── index.html # Main UI
|
|
└── js/
|
|
├── core-os-client.js # Core OS integration
|
|
├── apps.js # Applications
|
|
└── auth.js # Authentication
|
|
```
|
|
|
|
### Prism Console
|
|
```
|
|
prism-console/
|
|
├── index.html # Admin UI
|
|
└── static/
|
|
├── css/prism.css # Styles
|
|
└── js/prism.js # Console logic
|
|
```
|
|
|
|
## Technology Stack
|
|
|
|
### Backend
|
|
- **FastAPI 0.104.1** - Modern async web framework
|
|
- **SQLAlchemy 2.0.23** - ORM
|
|
- **PostgreSQL** - Database
|
|
- **Redis 5.0.1** - Caching
|
|
- **Uvicorn 0.24.0** - ASGI server
|
|
|
|
### Frontend
|
|
- **Vanilla JavaScript** - No framework
|
|
- **HTML5 / CSS3** - Modern web standards
|
|
- **Zero dependencies** - No build process
|
|
|
|
### Infrastructure
|
|
- **Railway** - Backend hosting
|
|
- **Cloudflare** - DNS, CDN, SSL
|
|
- **GitHub Actions** - CI/CD
|
|
- **Docker** - Containerization
|
|
|
|
## Design Principles
|
|
|
|
1. **Agent-First**: Humans orchestrate, agents execute
|
|
2. **Memory-Conscious**: Everything is logged and retrievable
|
|
3. **Ledger-Aware**: Critical actions are provable and tamper-evident
|
|
4. **Zero-Dependency Frontend**: Vanilla JS with no build process
|
|
5. **Cloud-Native**: Infrastructure as software
|
|
|
|
## Scalability
|
|
|
|
### Current Capacity
|
|
- Single Railway instance
|
|
- PostgreSQL (managed)
|
|
- Redis (managed)
|
|
|
|
### Future Scaling
|
|
- Horizontal scaling via Railway
|
|
- Database read replicas
|
|
- Redis clustering
|
|
- Cloudflare Workers for edge compute
|
|
- RoadChain distributed nodes
|
|
|
|
## Security
|
|
|
|
- **HTTPS Everywhere**: Cloudflare SSL
|
|
- **JWT Authentication**: Token-based auth
|
|
- **Input Validation**: Pydantic models
|
|
- **SQL Injection Protection**: ORM queries
|
|
- **CORS Configuration**: Restricted origins
|
|
- **Rate Limiting**: API throttling (future)
|
|
|
|
## Monitoring
|
|
|
|
- **Health Checks**: `/health` endpoint
|
|
- **Logging**: Structured logging
|
|
- **Error Tracking**: Sentry integration
|
|
- **Metrics**: Prometheus (future)
|
|
- **Observability**: Prism Console
|
|
|
|
## Next: Component Deep Dive
|
|
|
|
See [Components](components.md) for detailed information about each module.
|