Raven Zero Logo RAVEN ZERO

Raven Zero - Architecture

πŸ“ System Overview

Raven Zero is built on a hybrid ephemeral architecture where Redis acts as the source of truth for active uploads, the filesystem provides encrypted storage, and all components are designed for data to disappear by default.

High-Level Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Client    β”‚ (Browser, cURL, App)
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
       β”‚ HTTPS
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚          FastAPI Application            β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚  β”‚  Routers                       β”‚     β”‚
β”‚  β”‚  - /upload    - /download      β”‚     β”‚
β”‚  β”‚  - /preview   - /status        β”‚     β”‚
β”‚  β”‚  - /health    - /scalar        β”‚     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β”‚               β”‚                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚  β”‚  Services                      β”‚     β”‚
β”‚  β”‚  - StorageService (encrypted)  β”‚     β”‚
β”‚  β”‚  - CacheService (Redis)        β”‚     β”‚
β”‚  β”‚  - DicewareService (keys)      β”‚     β”‚
β”‚  β”‚  - SecurityService (Fernet)    β”‚     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β”‚           β”‚           β”‚                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚  β”‚   Background Jobs (APScheduler)β”‚     β”‚
β”‚  β”‚  - Orphan cleanup (10 min)     β”‚     β”‚
β”‚  β”‚  - Health heartbeat (1 min)    β”‚     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚           β”‚
            β–Ό           β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚   Redis   β”‚  β”‚Filesystemβ”‚
    β”‚ (Valkey)  β”‚  β”‚(Encryptedβ”‚
    β”‚ Metadata  β”‚  β”‚  Files)  β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🎯 Technology Stack

Core Stack

ComponentTechnologyPurpose
LanguagePython 3.13Async/await, type hints
Web FrameworkFastAPIAsync, Pydantic validation, auto-docs
Cache/MetadataRedis/ValkeyTTL native, atomic ops
File StorageFilesystemEncrypted files with secure deletion
Package ManageruvFast, modern Python package management
ContainerizationDockerReproducible deployments

Security & Encryption

ComponentTechnologyPurpose
EncryptionFernet (cryptography)AES-128-CBC + HMAC-SHA256
Integrityhashlib SHA-256File verification
MIME Detectionpython-magicMagic bytes detection
Secure DeleteCustom shreddingByte overwriting before deletion

Observability

ComponentTechnologyPurpose
LoggingstructlogStructured JSON logging
SchedulingAPSchedulerBackground cleanup jobs
API DocsScalarInteractive API documentation

πŸ“ Project Structure

app/
β”œβ”€β”€ main.py              # FastAPI app, lifespan, middlewares
β”œβ”€β”€ config.py            # Pydantic Settings (env vars)
β”‚
β”œβ”€β”€ core/                # Infrastructure layer
β”‚   β”œβ”€β”€ logger.py        # Structlog JSON configuration
β”‚   β”œβ”€β”€ logging_middleware.py  # Request ID, timing
β”‚   β”œβ”€β”€ rate_limiting.py # Slowapi with Redis backend
β”‚   β”œβ”€β”€ redis.py         # Async Redis client
β”‚   β”œβ”€β”€ security.py      # Fernet encryption service
β”‚   β”œβ”€β”€ security_headers.py    # HTTP security headers
β”‚   └── uptime.py        # Application uptime tracker
β”‚
β”œβ”€β”€ models/
β”‚   └── schemas.py       # Pydantic request/response models
β”‚
β”œβ”€β”€ routers/             # API endpoints
β”‚   β”œβ”€β”€ upload.py        # POST /upload/
β”‚   β”œβ”€β”€ download.py      # GET /download/{key}
β”‚   β”œβ”€β”€ preview.py       # GET /preview/{key}
β”‚   β”œβ”€β”€ status.py        # GET /status/{key}
β”‚   └── health.py        # GET /health/
β”‚
└── services/
    β”œβ”€β”€ cache.py         # Redis metadata operations
    β”œβ”€β”€ diceware.py      # Key generation (7776 words)
    β”œβ”€β”€ scheduler.py     # APScheduler cleanup jobs
    β”‚
    └── storage/         # File storage module
        β”œβ”€β”€ storage_service.py  # Main orchestrator
        β”œβ”€β”€ repository.py       # File I/O + secure shredding
        β”œβ”€β”€ validators.py       # Size/MIME validation
        β”œβ”€β”€ sanitizer.py        # Filename sanitization
        β”œβ”€β”€ path_manager.py     # Path resolution
        └── mime_detector.py    # libmagic MIME detection

πŸ“– Documentation Index

DocumentDescription
Data ModelsRedis schema, filesystem structure
SecurityEncryption, shredding, defense layers
API SpecificationEndpoints, examples, errors
DeploymentDocker, configuration, environment
DevelopmentPatterns, testing, conventions
DecisionsDecision log, references