Architecture Overview β
The Usenet Media Stack is built on a foundation of professional software engineering principles, combining hot-swappable JBOD storage, universal hardware optimization, and a sophisticated CLI following modern design patterns.
Core Design Philosophy β
Bell Labs Standards β
The codebase follows principles taught by Stan Eisenstat at Yale:
- Clarity over cleverness - Every function is documented, every error teaches
- Professional standards - 80-character lines, comprehensive error handling
- Quality architecture - Single responsibility, proper abstractions, testing
Modern CLI Design β
Inspired by industry-leading tools:
- Git: Subcommand + flags perfection (
git commit -m "msg" --amend
) - Docker: Object + action model (
docker container run --rm -it
) - Pyenv: Workflow-oriented with smart help (
pyenv install 3.9.7
)
System Architecture β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Usenet Media Stack β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β CLI Interface (usenet) β
β ββ Pure subcommand routing β
β ββ Three-tier help system β
β ββ Rich zsh/bash completions β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Component Management β
β ββ Storage: Hot-swappable JBOD β
β ββ Hardware: Universal GPU optimization β
β ββ Services: 19-service orchestration β
β ββ Backup: Configuration management β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Service Layer (19 Services) β
β ββ Media: Jellyfin, Overseerr, YACReader, Tdarr β
β ββ Automation: Sonarr, Radarr, Readarr, Bazarr, etc. β
β ββ Downloads: SABnzbd, Transmission β
β ββ Management: Portainer, Netdata β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Container Orchestration (Docker Compose) β
β ββ Base: docker-compose.yml β
β ββ Hardware: docker-compose.optimized.yml β
β ββ Storage: docker-compose.storage.yml (dynamic) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Storage Layer β
β ββ Hot-swappable JBOD drives β
β ββ Cross-platform exFAT support β
β ββ Cloud storage integration β
β ββ Network storage (NFS/SMB) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Hardware Layer β
β ββ Universal GPU support (NVIDIA/AMD/Intel/Pi) β
β ββ Automatic driver installation β
β ββ Performance profiling β
β ββ Real-time optimization β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Component Architecture β
CLI Design Pattern β
bash
# Modern subcommand architecture
usenet <component> <action> [options]
# Examples:
usenet storage list # Component: storage, Action: list
usenet hardware optimize # Component: hardware, Action: optimize
usenet services restart # Component: services, Action: restart
Component Responsibilities β
Component | Purpose | Key Features |
---|---|---|
Storage | Hot-swappable JBOD management | Real-time detection, API sync, exFAT support |
Hardware | GPU optimization & drivers | Universal detection, auto-install, benchmarking |
Services | 19-service orchestration | Health monitoring, log access, API management |
Backup | Configuration management | Metadata tracking, atomic operations, encryption |
Deploy | Orchestrated deployment | Pre-flight checks, profile selection, validation |
Validate | System health checks | Auto-fix, monitoring, troubleshooting |
Data Flow Architecture β
Media Automation Pipeline β
βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ
β Request β β Search β β Download β β Process β
β (Overseerr) βββββΆβ (Prowlarr) βββββΆβ (SABnzbd) βββββΆβ (Tdarr) β
βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ
β β β β
βΌ βΌ βΌ βΌ
βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ
β Organize β β Quality β β Storage β β Serve β
β (Sonarr/ βββββΆβ (Recyclarr) βββββΆβ (JBOD) βββββΆβ (Jellyfin) β
β Radarr) β β β β β β β
βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ
Storage Integration Flow β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β Drive β β Discovery β β API β
β Detection βββββΆβ & Pool βββββΆβ Sync β
β β β Management β β β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β Docker β β Service β β Health β
β Compose βββββΆβ Restart βββββΆβ Validation β
β Generation β β β β β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
File System Architecture β
Project Structure β
usenet-media-stack/
βββ usenet # Single entry point CLI
βββ lib/ # Component implementations
β βββ commands/ # CLI command handlers
β β βββ storage.zsh # Hot-swappable JBOD management
β β βββ hardware.zsh # GPU optimization system
β β βββ backup.zsh # Configuration backup/restore
β β βββ services.zsh # 19-service management
β β βββ deploy.zsh # Orchestrated deployment
β β βββ validate.zsh # System health validation
β βββ core/ # Shared utilities
β β βββ init.zsh # Configuration loading
β β βββ common.zsh # Utilities and logging
β β βββ stan-quality.zsh # Code quality framework
β βββ test/ # Testing framework
βββ config/ # Service configurations (19 services)
βββ completions/ # Rich CLI completions
βββ docker-compose.yml # Base service definitions
βββ docker-compose.*.yml # Generated optimizations
βββ .env # All credentials (gitignored)
βββ docs/ # Professional documentation
Configuration Management β
Configuration Sources (Priority Order):
1. Command-line flags (--profile dedicated)
2. Environment variables (.env file)
3. Configuration files (config/*.conf)
4. Intelligent defaults (hardware-based)
Network Architecture β
Service Exposure β
External Access (Cloudflare Tunnel):
βββ jellyfin.example.com β Jellyfin (8096)
βββ requests.example.com β Overseerr (5055)
βββ comics.example.com β YACReader (8082)
βββ manage.example.com β Portainer (9000)
Internal Network (Docker Bridge):
βββ Media Services (8080-8099)
βββ Automation Stack (8900-8999, 6700-6799)
βββ Management Tools (9000-9999, 19999)
βββ File Sharing (445, 2049)
Security Model β
- Zero exposed ports - All access via Cloudflare Tunnel
- API authentication - Unique keys for each service
- Container isolation - Services in dedicated network
- Credential management - Environment-based secrets
Hardware Optimization Architecture β
Multi-Platform GPU Support β
GPU Detection & Optimization:
βββ NVIDIA RTX Series
β βββ NVENC/NVDEC encoding
β βββ CUDA acceleration
β βββ nvidia-docker2 integration
βββ AMD RDNA/GCN Series
β βββ VAAPI acceleration
β βββ AMF encoding
β βββ Mesa driver integration
βββ Intel Arc/Iris
β βββ QuickSync encoding
β βββ VA-API support
β βββ Intel media drivers
βββ Raspberry Pi
βββ VideoCore GPU
βββ Hardware decode
βββ GPU memory allocation
Performance Profiles β
Profile | Resources | Use Case | Transcoding |
---|---|---|---|
Light | 25% CPU, 4GB RAM | Development | Software only |
Balanced | 50% CPU, 8GB RAM | Home server | Hardware enabled |
High | 75% CPU, 16GB RAM | Media server | Optimized |
Dedicated | 100% CPU, All RAM | Appliance | Maximum |
Storage Architecture β
Hot-Swappable JBOD Design β
Storage Pool Management:
βββ Drive Discovery
β βββ Local drives (HDD/SSD/NVMe)
β βββ USB/External (hot-pluggable)
β βββ Network storage (NFS/SMB)
β βββ Cloud mounts (rclone)
βββ Pool Configuration
β βββ Interactive selection
β βββ Cross-platform compatibility
β βββ Permission management
β βββ Mount point generation
βββ Service Integration
βββ Dynamic Docker Compose
βββ API synchronization
βββ Hot-swap workflows
βββ Zero-downtime updates
Cross-Platform Compatibility β
- ExFAT support - Works across Windows/macOS/Linux
- Portable drives - Camping trips and travel
- Cloud integration - Dropbox, OneDrive, Google Drive
- Network storage - NAS and server integration
Service Integration Architecture β
API Synchronization β
Storage Change Event:
βββ Drive Detection
βββ Pool Update
βββ Docker Compose Generation
βββ Service API Updates
β βββ Sonarr: Root folders
β βββ Radarr: Movie libraries
β βββ Jellyfin: Media libraries
β βββ Tdarr: Processing paths
βββ Health Validation
Service Dependencies β
Dependency Graph:
βββ Core Services (Always first)
β βββ Prowlarr (indexer management)
β βββ SABnzbd (download client)
βββ Automation Services
β βββ Sonarr (depends: Prowlarr, SABnzbd)
β βββ Radarr (depends: Prowlarr, SABnzbd)
β βββ Bazarr (depends: Sonarr, Radarr)
βββ Media Services
β βββ Jellyfin (depends: storage availability)
β βββ Tdarr (depends: Jellyfin, storage)
βββ Management Services
βββ Overseerr (depends: Sonarr, Radarr)
βββ Recyclarr (depends: Sonarr, Radarr)
Quality Assurance Architecture β
Testing Framework β
Quality Gates:
βββ Code Quality (Stan's Standards)
β βββ 80-character lines
β βββ Function contracts
β βββ Error handling
β βββ Documentation
βββ Functionality Testing
β βββ Unit tests (component level)
β βββ Integration tests (workflow level)
β βββ System tests (full stack)
β βββ Regression tests (change validation)
βββ User Experience Testing
βββ CLI usability
βββ Error message clarity
βββ Help system completeness
βββ Performance benchmarks
Validation System β
- Pre-deployment checks - System requirements, configuration
- Runtime monitoring - Service health, resource usage
- Auto-fix capabilities - Common issues resolution
- Comprehensive reporting - JSON exports, troubleshooting
Extensibility Architecture β
Adding New Services β
bash
# Add service to docker-compose.yml
services:
new-service:
image: new-service:latest
ports:
- "8888:8080"
volumes:
- ./config/new-service:/config
environment:
- API_KEY=${NEW_SERVICE_API_KEY}
# Register with CLI system
usenet services add new-service --category custom
Custom Hardware Support β
bash
# Add hardware detection logic
detect_custom_hardware() {
# Custom GPU detection
if lspci | grep -i "custom gpu"; then
echo "Custom GPU detected"
return 0
fi
return 1
}
# Register optimization profile
usenet hardware profile add custom-gpu \
--transcoding-args "-hwaccel custom" \
--quality-settings high
Related Architecture Documentation β
- CLI Design Patterns - Command architecture deep dive
- Service Architecture - 19-service integration details
- Storage Architecture - Hot-swappable JBOD implementation
- Hardware Architecture - Multi-platform GPU optimization
- Network Architecture - Security and connectivity design