Files
blackroad-operating-system/backend
Alexa Amundson 761bd19474 chore: bump pytest from 7.4.3 to 9.0.2 (#202)
Bumps [pytest](https://github.com/pytest-dev/pytest) from 7.4.3 to
9.0.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/pytest-dev/pytest/releases">pytest's
releases</a>.</em></p>
<blockquote>
<h2>9.0.2</h2>
<h1>pytest 9.0.2 (2025-12-06)</h1>
<h2>Bug fixes</h2>
<ul>
<li>
<p><a
href="https://redirect.github.com/pytest-dev/pytest/issues/13896">#13896</a>:
The terminal progress feature added in pytest 9.0.0 has been disabled by
default, except on Windows, due to compatibility issues with some
terminal emulators.</p>
<p>You may enable it again by passing <code>-p terminalprogress</code>.
We may enable it by default again once compatibility improves in the
future.</p>
<p>Additionally, when the environment variable <code>TERM</code> is
<code>dumb</code>, the escape codes are no longer emitted, even if the
plugin is enabled.</p>
</li>
<li>
<p><a
href="https://redirect.github.com/pytest-dev/pytest/issues/13904">#13904</a>:
Fixed the TOML type of the <code>tmp_path_retention_count</code>
settings in the API reference from number to string.</p>
</li>
<li>
<p><a
href="https://redirect.github.com/pytest-dev/pytest/issues/13946">#13946</a>:
The private <code>config.inicfg</code> attribute was changed in a
breaking manner in pytest 9.0.0.
Due to its usage in the ecosystem, it is now restored to working order
using a compatibility shim.
It will be deprecated in pytest 9.1 and removed in pytest 10.</p>
</li>
<li>
<p><a
href="https://redirect.github.com/pytest-dev/pytest/issues/13965">#13965</a>:
Fixed quadratic-time behavior when handling <code>unittest</code>
subtests in Python 3.10.</p>
</li>
</ul>
<h2>Improved documentation</h2>
<ul>
<li><a
href="https://redirect.github.com/pytest-dev/pytest/issues/4492">#4492</a>:
The API Reference now contains cross-reference-able documentation of
<code>pytest's command-line flags
&lt;command-line-flags&gt;</code>.</li>
</ul>
<h2>9.0.1</h2>
<h1>pytest 9.0.1 (2025-11-12)</h1>
<h2>Bug fixes</h2>
<ul>
<li><a
href="https://redirect.github.com/pytest-dev/pytest/issues/13895">#13895</a>:
Restore support for skipping tests via <code>raise
unittest.SkipTest</code>.</li>
<li><a
href="https://redirect.github.com/pytest-dev/pytest/issues/13896">#13896</a>:
The terminal progress plugin added in pytest 9.0 is now automatically
disabled when iTerm2 is detected, it generated desktop notifications
instead of the desired functionality.</li>
<li><a
href="https://redirect.github.com/pytest-dev/pytest/issues/13904">#13904</a>:
Fixed the TOML type of the verbosity settings in the API reference from
number to string.</li>
<li><a
href="https://redirect.github.com/pytest-dev/pytest/issues/13910">#13910</a>:
Fixed <!-- raw HTML omitted -->UserWarning: Do not expect
file_or_dir<!-- raw HTML omitted --> on some earlier Python 3.12 and
3.13 point versions.</li>
</ul>
<h2>Packaging updates and notes for downstreams</h2>
<ul>
<li><a
href="https://redirect.github.com/pytest-dev/pytest/issues/13933">#13933</a>:
The tox configuration has been adjusted to make sure the desired
version string can be passed into its <code>package_env</code> through
the <code>SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTEST</code> environment
variable as a part of the release process -- by
<code>webknjaz</code>.</li>
</ul>
<h2>Contributor-facing changes</h2>
<ul>
<li><a
href="https://redirect.github.com/pytest-dev/pytest/issues/13891">#13891</a>,
<a
href="https://redirect.github.com/pytest-dev/pytest/issues/13942">#13942</a>:
The CI/CD part of the release automation is now capable of
creating GitHub Releases without having a Git checkout on
disk -- by <code>bluetech</code> and <code>webknjaz</code>.</li>
<li><a
href="https://redirect.github.com/pytest-dev/pytest/issues/13933">#13933</a>:
The tox configuration has been adjusted to make sure the desired
version string can be passed into its <code>package_env</code> through
the <code>SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTEST</code> environment
variable as a part of the release process -- by
<code>webknjaz</code>.</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="3d10b5148e"><code>3d10b51</code></a>
Prepare release version 9.0.2</li>
<li><a
href="188750b725"><code>188750b</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest/issues/14030">#14030</a>
from pytest-dev/patchback/backports/9.0.x/1e4b01d1f...</li>
<li><a
href="b7d7bef90c"><code>b7d7bef</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest/issues/14014">#14014</a>
from bluetech/compat-note</li>
<li><a
href="bd08e85ac7"><code>bd08e85</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest/issues/14013">#14013</a>
from pytest-dev/patchback/backports/9.0.x/922b60377...</li>
<li><a
href="bc78386299"><code>bc78386</code></a>
Add CLI options reference documentation (<a
href="https://redirect.github.com/pytest-dev/pytest/issues/13930">#13930</a>)</li>
<li><a
href="5a4e398ce8"><code>5a4e398</code></a>
Fix docs typo (<a
href="https://redirect.github.com/pytest-dev/pytest/issues/14005">#14005</a>)
(<a
href="https://redirect.github.com/pytest-dev/pytest/issues/14008">#14008</a>)</li>
<li><a
href="d7ae6df394"><code>d7ae6df</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest/issues/14006">#14006</a>
from pytest-dev/maintenance/update-plugin-list-tmpl...</li>
<li><a
href="556f6a22e1"><code>556f6a2</code></a>
pre-commit: fix rst-lint after new release (<a
href="https://redirect.github.com/pytest-dev/pytest/issues/13999">#13999</a>)
(<a
href="https://redirect.github.com/pytest-dev/pytest/issues/14001">#14001</a>)</li>
<li><a
href="c60fbe63a2"><code>c60fbe6</code></a>
Fix quadratic-time behavior when handling <code>unittest</code> subtests
in Python 3.10 ...</li>
<li><a
href="73d9b01118"><code>73d9b01</code></a>
Merge pull request <a
href="https://redirect.github.com/pytest-dev/pytest/issues/13995">#13995</a>
from nicoddemus/patchback/backports/9.0.x/1b5200c0f...</li>
<li>Additional commits viewable in <a
href="https://github.com/pytest-dev/pytest/compare/7.4.3...9.0.2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pytest&package-manager=pip&previous-version=7.4.3&new-version=9.0.2)](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>
2026-03-15 20:27:49 -05:00
..
2025-11-18 14:14:50 +00:00
2025-11-16 03:48:34 -06:00

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.html and is served by the FastAPI app at http://localhost:8000/.

Prerequisites

  • Python 3.11+
  • Docker and Docker Compose
  • PostgreSQL 15+ (if running locally)
  • Redis 7+ (if running locally)

Installation

# 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:

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 info
  • emails - Email messages
  • email_folders - Email folder organization
  • posts - Social media posts
  • comments - Post comments
  • likes - Like tracking
  • follows - Follow relationships
  • videos - Video metadata
  • video_views - Video view tracking
  • video_likes - Video engagement
  • files - File metadata
  • folders - Folder structure
  • blocks - Blockchain blocks
  • transactions - Blockchain transactions
  • wallets - User wallets
  • conversations - AI chat conversations
  • messages - 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_KEY to 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

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

License

MIT License - see LICENSE file for details

Support

For issues and questions: