mirror of
https://github.com/blackboxprogramming/BlackRoad-Operating-System.git
synced 2026-03-17 07:57:19 -05:00
[//]: # (dependabot-start) ⚠️ **Dependabot is rebasing this PR** ⚠️ Rebasing might not happen immediately, so don't worry if this takes some time. Note: if you make any changes to this PR yourself, they will take precedence over the rebase. --- [//]: # (dependabot-end) Bumps [redis](https://github.com/redis/redis-py) from 5.0.1 to 7.3.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/redis/redis-py/releases">redis's releases</a>.</em></p> <blockquote> <h2>7.3.0</h2> <h1>Changes</h1> <p><strong>OpenTelemetry Native Metrics Support for asynchronous clients</strong> Added comprehensive OpenTelemetry metrics support for asynchronous clients following the <a href="https://opentelemetry.io/docs/specs/semconv/database/database-metrics/">OpenTelemetry Database Client Semantic Conventions</a>. Metric groups include:</p> <ul> <li>Command metrics: Operation duration with retry tracking</li> <li>Connection basic: Connection count and creation time</li> <li>Resiliency: Errors, handoffs, timeout relaxation</li> <li>Connection advanced: Wait time and use time</li> <li>Pubsub metrics: Published and received messages</li> <li>Stream metrics: Processing duration and maintenance notifications</li> </ul> <h2>🚀 New Features</h2> <ul> <li>Added OTel instrumentation and metrics export for async client (<a href="https://redirect.github.com/redis/redis-py/issues/3977">#3977</a>)</li> </ul> <h2>🐛 Bug Fixes</h2> <ul> <li>[async] Adding access to cluster client's nodes_manager and set_response_callback in ClusterPipeline objects (<a href="https://redirect.github.com/redis/redis-py/issues/3989">#3989</a>)</li> <li>fix(connection): Ensure we have an initialized protocol in connection (<a href="https://redirect.github.com/redis/redis-py/issues/3981">#3981</a>)</li> </ul> <h2>🧰 Maintenance</h2> <ul> <li>fix: use KeysT for blpop and brpop keys parameter type annotation (<a href="https://redirect.github.com/redis/redis-py/issues/3987">#3987</a> <a href="https://redirect.github.com/redis/redis-py/issues/3990">#3990</a>)</li> <li>Bump actions/upload-artifact from 6 to 7 (<a href="https://redirect.github.com/redis/redis-py/issues/3985">#3985</a>)</li> <li>fix: replace 3 bare except clauses with except Exception (<a href="https://redirect.github.com/redis/redis-py/issues/3980">#3980</a>)</li> </ul> <p>We'd like to thank all the contributors who worked on this release! <a href="https://github.com/mitre88"><code>@mitre88</code></a> <a href="https://github.com/turanalmammadov"><code>@turanalmammadov</code></a> <a href="https://github.com/haosenwang1018"><code>@haosenwang1018</code></a> <a href="https://github.com/Medno"><code>@Medno</code></a> <a href="https://github.com/vladvildanov"><code>@vladvildanov</code></a> <a href="https://github.com/petyaslavova"><code>@petyaslavova</code></a></p> <h2>7.2.1</h2> <h1>Changes</h1> <h2>🐛 Bug Fixes</h2> <ul> <li>Handle connection attributes conditionally for metrics and set connection data on exceptions in cluster error handling (<a href="https://redirect.github.com/redis/redis-py/issues/3964">#3964</a>)</li> </ul> <h2>⚠️ Deprecations</h2> <ul> <li>Removed batch_size and consumer_name attributes from OTel metrics (<a href="https://redirect.github.com/redis/redis-py/issues/3978">#3978</a>)</li> </ul> <h2>🧰 Maintenance</h2> <ul> <li>Fixing error handling of connection buffer purging of closed connections. Enabling troubleshooting logging for maintenance notifications e2e tests. (<a href="https://redirect.github.com/redis/redis-py/issues/3971">#3971</a>)</li> <li>Fix protocol validation: replace finally with else and store parsed int (<a href="https://redirect.github.com/redis/redis-py/issues/3965">#3965</a>)</li> <li>Return copies from _get_free/in_use_connections and fix async _mock (<a href="https://redirect.github.com/redis/redis-py/issues/3967">#3967</a>)</li> <li>Add missing shard channel message types to async PubSub (<a href="https://redirect.github.com/redis/redis-py/issues/3966">#3966</a>)</li> <li>Fix issues with ClusterPipeline connection management (<a href="https://redirect.github.com/redis/redis-py/issues/3804">#3804</a>)</li> <li>fix(pubsub): avoid UnicodeDecodeError on reconnect with binary channel names (<a href="https://redirect.github.com/redis/redis-py/issues/3944">#3944</a>)</li> <li>Hold references to ClusterNode disconnect task (<a href="https://redirect.github.com/redis/redis-py/issues/3826">#3826</a>)</li> <li>remove remaining imports of typing_extensions (<a href="https://redirect.github.com/redis/redis-py/issues/3873">#3873</a>)</li> </ul> <p>We'd like to thank all the contributors who worked on this release! <a href="https://github.com/dotlambda"><code>@dotlambda</code></a> <a href="https://github.com/rhoboro"><code>@rhoboro</code></a> <a href="https://github.com/skylarkoo7"><code>@skylarkoo7</code></a> <a href="https://github.com/praboud"><code>@praboud</code></a> <a href="https://github.com/bysiber"><code>@bysiber</code></a> <a href="https://github.com/vladvildanov"><code>@vladvildanov</code></a> <a href="https://github.com/petyaslavova"><code>@petyaslavova</code></a></p> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="8ecbc7a728"><code>8ecbc7a</code></a> Updating lib version to 7.3.0</li> <li><a href="11043df86e"><code>11043df</code></a> typing: accept single-key input for blpop and brpop (<a href="https://redirect.github.com/redis/redis-py/issues/3990">#3990</a>)</li> <li><a href="d958125020"><code>d958125</code></a> fix: use KeysT for blpop and brpop keys parameter type annotation (<a href="https://redirect.github.com/redis/redis-py/issues/3987">#3987</a>)</li> <li><a href="75bf91b8a2"><code>75bf91b</code></a> [async] Adding access to cluster client's nodes_manager and set_response_call...</li> <li><a href="abf5bcb2de"><code>abf5bcb</code></a> Bump actions/upload-artifact from 6 to 7 (<a href="https://redirect.github.com/redis/redis-py/issues/3985">#3985</a>)</li> <li><a href="5b0303bf90"><code>5b0303b</code></a> fix: replace 3 bare except clauses with except Exception (<a href="https://redirect.github.com/redis/redis-py/issues/3980">#3980</a>)</li> <li><a href="e9fba8689f"><code>e9fba86</code></a> Added OTel instrumentation and metrics export for async client (<a href="https://redirect.github.com/redis/redis-py/issues/3977">#3977</a>)</li> <li><a href="7ce513d262"><code>7ce513d</code></a> fix(connection): Ensure we have an initialized protocol in connection (<a href="https://redirect.github.com/redis/redis-py/issues/3981">#3981</a>)</li> <li><a href="8e3a5b2f10"><code>8e3a5b2</code></a> remove remaining imports of typing_extensions (<a href="https://redirect.github.com/redis/redis-py/issues/3873">#3873</a>)</li> <li><a href="5b46430e23"><code>5b46430</code></a> Hold references to ClusterNode disconnect task (<a href="https://redirect.github.com/redis/redis-py/issues/3826">#3826</a>)</li> <li>Additional commits viewable in <a href="https://github.com/redis/redis-py/compare/v5.0.1...v7.3.0">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details>
BlackRoad Operating System - Backend API
A comprehensive FastAPI backend for the BlackRoad Operating System, a Windows 95-inspired web operating system with modern features.
Features
Core Services
- Authentication - JWT-based user authentication and authorization
- RoadMail - Full-featured email system with folders and attachments
- BlackRoad Social - Social media platform with posts, comments, likes, and follows
- BlackStream - Video streaming service with views and engagement tracking
- File Storage - File explorer with folder management and sharing
- RoadCoin Blockchain - Cryptocurrency with mining, transactions, and wallet management
- AI Chat - Conversational AI assistant with conversation history
- Chaos Inbox / Identity / Notifications / Creator / Compliance - New v0.2 APIs for capture, profiles, alerts, creative projects, and audit visibility
New v0.2 endpoints
/api/capture/*— capture items, clustering, status and tagging/api/identity/profile— canonical user profile for OS apps/api/notifications— create/list/mark notifications/api/creator/projects— manage creator projects and assets/api/compliance/events— surface audit events/api/search?q=— unified search scaffold
Technology Stack
- FastAPI - Modern, fast Python web framework
- PostgreSQL - Primary database with async support
- Redis - Caching and session storage
- SQLAlchemy - ORM with async support
- JWT - Secure authentication
- Docker - Containerization and deployment
Quick Start
The desktop UI is bundled in
backend/static/index.htmland is served by the FastAPI app athttp://localhost:8000/.
Prerequisites
- Python 3.11+
- Docker and Docker Compose
- PostgreSQL 15+ (if running locally)
- Redis 7+ (if running locally)
Installation
Option 1: Docker (Recommended)
# Clone the repository
cd backend
# Copy environment file
cp .env.example .env
# Edit .env with your configuration
nano .env
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f backend
The API will be available at:
- API: http://localhost:8000
- API Docs: http://localhost:8000/api/docs
- ReDoc: http://localhost:8000/api/redoc
- Adminer: http://localhost:8080
Option 2: Local Development
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Copy environment file
cp .env.example .env
# Edit .env with your configuration
nano .env
# Start PostgreSQL and Redis (using Docker)
docker run -d -p 5432:5432 -e POSTGRES_USER=blackroad -e POSTGRES_PASSWORD=password -e POSTGRES_DB=blackroad_db postgres:15-alpine
docker run -d -p 6379:6379 redis:7-alpine
# Run the application (serves backend/static/index.html at /)
# Run the application (PORT defaults to 8000 if unset)
python run.py
After either setup option finishes booting, browse to
http://localhost:8000/ to load the Windows 95 desktop that lives in
backend/static/index.html. The API is available at /api/* from the same
server, so no extra reverse proxying is required for local or hosted (Railway,
GoDaddy, etc.) deployments.
Configuration
Edit the .env file to configure:
# Database
DATABASE_URL=postgresql://blackroad:password@localhost:5432/blackroad_db
DATABASE_ASYNC_URL=postgresql+asyncpg://blackroad:password@localhost:5432/blackroad_db
# Redis
REDIS_URL=redis://localhost:6379/0
# JWT Secret (CHANGE THIS!)
SECRET_KEY=your-very-secret-key-change-this-in-production
# CORS (Add your frontend URLs)
ALLOWED_ORIGINS=http://localhost:3000,https://yourdomain.com
# OpenAI (for AI Chat)
OPENAI_API_KEY=your-openai-api-key
API Documentation
Authentication Endpoints
POST /api/auth/register
POST /api/auth/login
GET /api/auth/me
POST /api/auth/logout
Email (RoadMail) Endpoints
GET /api/email/folders
GET /api/email/inbox
GET /api/email/sent
POST /api/email/send
GET /api/email/{email_id}
DELETE /api/email/{email_id}
Social Media Endpoints
GET /api/social/feed
POST /api/social/posts
POST /api/social/posts/{post_id}/like
GET /api/social/posts/{post_id}/comments
POST /api/social/posts/{post_id}/comments
POST /api/social/users/{user_id}/follow
Video Streaming Endpoints
GET /api/videos
POST /api/videos
GET /api/videos/{video_id}
POST /api/videos/{video_id}/like
File Storage Endpoints
GET /api/files/folders
POST /api/files/folders
GET /api/files
POST /api/files/upload
GET /api/files/{file_id}
DELETE /api/files/{file_id}
POST /api/files/{file_id}/share
Blockchain Endpoints
GET /api/blockchain/wallet
GET /api/blockchain/balance
POST /api/blockchain/transactions
GET /api/blockchain/transactions
GET /api/blockchain/transactions/{tx_hash}
GET /api/blockchain/blocks
GET /api/blockchain/blocks/{block_id}
POST /api/blockchain/mine
GET /api/blockchain/stats
AI Chat Endpoints
GET /api/ai-chat/conversations
POST /api/ai-chat/conversations
GET /api/ai-chat/conversations/{id}
GET /api/ai-chat/conversations/{id}/messages
POST /api/ai-chat/conversations/{id}/messages
DELETE /api/ai-chat/conversations/{id}
Database Schema
The backend uses PostgreSQL with the following main tables:
users- User accounts with authentication and wallet infoemails- Email messagesemail_folders- Email folder organizationposts- Social media postscomments- Post commentslikes- Like trackingfollows- Follow relationshipsvideos- Video metadatavideo_views- Video view trackingvideo_likes- Video engagementfiles- File metadatafolders- Folder structureblocks- Blockchain blockstransactions- Blockchain transactionswallets- User walletsconversations- AI chat conversationsmessages- AI chat messages
Testing
# Install test dependencies
pip install pytest pytest-asyncio httpx
# Run tests
pytest
# Run with coverage
pytest --cov=app --cov-report=html
Deployment
Production Checklist
- Change
SECRET_KEYto a strong random value - Set
DEBUG=False - Set
ENVIRONMENT=production - Configure proper CORS origins
- Use strong database passwords
- Set up SSL/TLS certificates
- Configure AWS S3 for file storage
- Set up proper logging
- Enable rate limiting
- Set up monitoring and alerts
Docker Production Deployment
# Build production image
docker build -t blackroad-backend:latest .
# Run with production settings
docker run -d \
-p 8000:8000 \
-e DATABASE_URL=postgresql://user:pass@db:5432/blackroad \
-e SECRET_KEY=your-production-secret \
-e ENVIRONMENT=production \
-e DEBUG=False \
blackroad-backend:latest
Architecture
┌─────────────────────────────────────────────────────────┐
│ Frontend (HTML/JS) │
└─────────────────────────────────────────────────────────┘
│
↓
┌─────────────────────────────────────────────────────────┐
│ FastAPI Backend │
├─────────────────────────────────────────────────────────┤
│ Routers: │
│ • Authentication • Email • Social │
│ • Videos • Files • Blockchain │
│ • AI Chat │
└─────────────────────────────────────────────────────────┘
│
┌───────────┴───────────┐
↓ ↓
┌───────────────────────┐ ┌──────────────────┐
│ PostgreSQL DB │ │ Redis Cache │
│ • User data │ │ • Sessions │
│ • Emails │ │ • API cache │
│ • Posts │ │ • Rate limits │
│ • Files metadata │ └──────────────────┘
│ • Blockchain │
│ • Conversations │
└───────────────────────┘
Security
- Authentication: JWT tokens with expiration
- Password Hashing: bcrypt with salt
- Input Validation: Pydantic schemas
- SQL Injection: SQLAlchemy ORM protection
- CORS: Configurable origins
- Rate Limiting: Redis-based (TODO)
Performance
- Async/Await: Full async support with asyncio
- Connection Pooling: SQLAlchemy and Redis pools
- Caching: Redis for frequently accessed data
- Database Indexing: Optimized queries with indexes
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
License
MIT License - see LICENSE file for details
Support
For issues and questions:
- GitHub Issues: https://github.com/blackboxprogramming/BlackRoad-Operating-System/issues
- Documentation: /api/docs