BaluHost ist eine Full‑Stack NAS-Management-Anwendung. Das Backend ist in Python (FastAPI) implementiert, das Frontend ist ein React + TypeScript Single-Page-Application (Vite). Diese Dokumentation beschreibt Architektur, Komponenten, Deployment- und Entwicklungs-Workflows und zeigt ein ASCII-Diagramm, wie Frontend und Backend miteinander zusammenspielen.
- Maintainer: Xveyn
- Status: ✅ DEPLOYED IN PRODUCTION (seit 25. Januar 2026)
- Version: siehe
backend/pyproject.toml(Single Source of Truth) bzw. den Kopf vonCHANGELOG.md. Hier bewusst nicht wiederholt: die handgepflegte Kopie stand bis Juli 2026 auf 1.16.4, während das Projekt bei 1.38.0 war (#349) - Letzte inhaltliche Änderung:
git log -1 --format=%ad -- docs/TECHNICAL_DOCUMENTATION.md— git weiß das genauer als eine Zeile, die beim Bearbeiten mitgepflegt werden müsste
- Frontend: React 18, TypeScript, Vite, Tailwind CSS
- Backend: Python 3.11+, FastAPI, Pydantic, SQLAlchemy, Alembic
- Runtime: Uvicorn (ASGI)
- System & Monitoring: psutil, smartctl (optional, Linux)
- Auth: JWT (Access + Refresh flows)
- DB (dev): SQLite; Production: PostgreSQL 17.7 (seit Januar 2026 im Einsatz, nicht bloß empfohlen)
backend/— FastAPI App (app/), Services, Dev‑Storage, Scriptsclient/— React App (Vite),src/pages,src/api,src/lib/api.tsdocs/— technische How‑tos, RAID, Telemetrie, Mobile, etc.start_dev.py— kombiniertes Dev-Start-Skript
Dieses Diagramm zeigt die wichtigsten Laufzeit-Komponenten und wie sie interagieren. Architektur-Übersicht (ASCII)
Dieses Diagramm zeigt die wichtigsten Laufzeit-Komponenten und wie sie interagieren.
+----------------------+ +----------------------+ +---------------------+
| Developer / Browser | <---HTTP-->| Frontend (Vite) | <---XHR--->| API Client (axios) |
| (React SPA) | | client/src/... | | client/src/lib/api |
+----------------------+ +----------------------+ +----------+----------+
| |
| v
+--------+--------------+
| Backend API (FastAPI) |
| backend/app/main.py |
+---+----+----+---------+
| | |
+-----------------------------+ | +------------------+
| | |
v v v
+-----------------------+ +----------------+ +--------------------+
| Services Layer | | Background | | Dev / Prod Storage |
| backend/app/services/ | | Jobs (jobs.py) | | - dev-storage/ |
+---+--+---+---+----+---+ +--------+-------+ +--------------------+
| | | | | |
| | | | | v
+---------------+ | | | | +----------------------------+
| | | | | | Disk I/O Monitor, SMART |
v v v v v | (disk_monitor.py, smart.py)|
+---------+ +---------+ +-----+ +------+ +----------------------------+
| Auth & | | Files | | RAID| | Tele- |
| Users | | (files) | | (raid)| | metry | +-----------------------+
| (auth.py| | | | | | (telemetry) | Database (SQLAlchemy) |
+---------+ +---------+ +-----+ +------+ | backend/app/models/ |
+-----------------------+
- Browser <> Frontend: SPA served by Vite dev server während Entwicklung oder statisch aus
client/dist/in Produktion. - Frontend <> Backend: REST/JSON über
client/src/lib/api.ts(axios) zu FastAPI Endpoints (/api/*). - Backend Services: Logik in
backend/app/services/(z. B.files.py,raid.py,smart.py,telemetry.py,audit_logger.py). - Background Jobs: Telemetrie-Collector, Disk I/O Sampler, Job-Manager lebt in
app/services+ Lifespan events. - Storage: Dev-Mode Sandbox unter
backend/dev-storage/(mit Mock-RAID) oder echte Mountpoints in Production; Metadaten in.metadata.jsonplus DB‑Referenzen.
- App-Entry:
backend/app/main.py(FastAPI app + Lifespan) - API-Routen:
backend/app/api/routes/(z. B.auth.py,files.py,system.py,logging.py) - Services (Business-Logic):
backend/app/services/—auth.py— JWT, Login/Refresh, Role handlingfiles.py— Upload/Download, Mountpoints, Quota checksraid.py— RAID-Status, Simulation & Control (Dev-Mode)disk_monitor.py/smart.py— Disk I/O & SMARTtelemetry.py— Telemetry collection & historyaudit_logger.py— JSON-Audit-Logs & API accessvpn.py,mobile.py— WireGuard config + mobile pairing
- Schemas:
backend/app/schemas/(Pydantic Models für Requests/Responses) - Models/ORM:
backend/app/models/(SQLAlchemy) - Migrations: Alembic (
alembic/)
POST /api/auth/login,POST /api/auth/refresh,GET /api/auth/meGET /api/files/mountpoints,POST /api/files/upload,GET /api/files/downloadGET /api/system/raid/status,POST /api/system/raid/rebuildGET /api/system/smart/status,GET /api/system/disk-io/historyGET /api/logging/audit
- JWT Access Tokens (kurze Laufzeit) + Refresh Token Flow (mobile: 30 Tage)
- RBAC:
adminvsuser— Endpunkte entsprechend eingeschränkt - Audit-Logging für sensitive Aktionen (Upload, Delete, VPN-Registration)
- App-Entrypoint:
client/src/main.tsx/client/src/App.tsx - Seiten:
client/src/pages/—Dashboard.tsx,FileManager.tsx,RaidManagement.tsx,SystemMonitor.tsx,Logging.tsx,UserManagement.tsx - API-Client:
client/src/lib/api.ts+ modulare Endpunkt-Wrapper inclient/src/api/(e.g.raid.ts,smart.ts) - Hooks:
client/src/hooks/—useSystemTelemetry.ts,useSmartData.ts - UI: Tailwind + lucide-react icons; Recharts für Graphen
- Nutzer öffnet Browser → React SPA lädt →
GET /api/auth/meprüft Session - Dashboard ruft Telemetrie, Storage und RAID-Status per API ab
- FileManager ruft Mountpoints, List, Upload/Download Endpoints auf; Quota wird vor Upload geprüft
- Admins sehen zusätzliche Controls (RAID, Disk Format, Create Array)
- Dev-Flag:
NAS_MODE=dev(inbackend/app/core/config.py) aktiviert Sandbox:backend/dev-storage/mit Mock-Disks und automatischer Seed-Daten- Mock SMART / RAID / Telemetry falls System-APIs fehlen
- Start-Dev (kombiniert):
python start_dev.py
- Backend Tests:
cd backend && python -m pytest
- Production Backend:
uvicorn app.main:app --host 0.0.0.0 --port 8000 - Frontend:
npm run build→client/dist/→ Serve via Nginx / static host - DB: Verwende PostgreSQL in Produktion, setze
DATABASE_URL
- Telemetry:
TELEMETRY_INTERVAL_SECONDS(Prod: 3s, Dev: 2s optional) - Telemetry History:
TELEMETRY_HISTORY_SIZE(Prod: 60 samples) - Quota:
NAS_QUOTA_BYTESoder mountpoint-spezifisch
- API-Referenz:
docs/API_REFERENCE.md - RAID-Setup:
docs/RAID_SETUP_WIZARD.md - Telemetrie-Empfehlungen:
docs/TELEMETRY_CONFIG_RECOMMENDATIONS.md - Audit Logging:
docs/AUDIT_LOGGING.md - VPN:
docs/VPN_INTEGRATION.md
- Storage Mountpoints (Multi-Drive) & Quota-Prüfung vor Upload
- Disk-Management UI (Format, Create Array, Device Actions)
- Erweiterte Disk I/O + SMART Visualisierung
- QR-basiertes VPN/Mobile Pairing + 30-Tage-Refresh-Tokens
- Audit-Logging als JSON + API-Zugriff
- Die Release-Historie steht vollständig in
CHANGELOG.mdund wird dort gepflegt; dieser Abschnitt fasst nur zusammen, was das System heute kann. - Plugin-System mit Pluggy-Hooks, async Events, Permission-System, Dashboard-Panels. Smart-Device-Framework mit Capability-Protocols und SHM-basiertem Polling. Mitgelieferte Plugins: Optical Drive, Storage Analytics, Tapo Smart Plug. Security: Rate Limiting, Security Headers, TOTP 2FA, Fernet-Verschlüsselung. PostgreSQL 17.7 in Produktion.
- Issues/PR: GitHub-Repo → Fork → Branch → PR
- Lokale Dev-Hilfe:
scripts/dev_check.py,scripts/reset_dev_storage.py
- Möchtest du, dass ich eine
docs/CHANGELOG.mdmit Release-Notizen anlege oder die Änderungen direkt commite?
- Storage Mountpoints: Multi-Drive- und RAID-Darstellung in UI und Backend (siehe
app/services/files.pyundclient/pages/FileManager.tsx). - Quota-System: Konfigurierbare Quotas pro Mountpoint mit Echtzeitprüfung vor Uploads.
- Disk Management UI (Frontend): Verfügbarkeitsliste, Formatierung, Array-Erstellung und Device-Controls in
RaidManagement. - Disk I/O Monitor & SMART: Erweiterte Echtzeit-Metriken und historische Ansichten (
app/services/disk_monitor.py,app/services/smart.py,client/pages/SystemMonitor.tsx). - Telemetrie: Empfehlungen und konfigurierbare Intervalle; neues Dokument
docs/TELEMETRY_CONFIG_RECOMMENDATIONS.md. - VPN / Mobile: QR-Code-basierte VPN-Registrierung, 30-Tage-Refresh-Tokens für mobile Geräte und verbesserte Pairing-Flows.
- Audit-Logging: Verbesserte Ereignistypen und JSON-Format, API-Zugriff auf Audit-Daten.
- Dev-Mode & Windows: Verbesserter Sandbox-Modus mit Windows-Kompatibilität und Seed-Daten für Entwickler (
start_dev.py,backend/dev-storage/). - Neue/aktualisierte Dokumentation:
docs/RAID_SETUP_WIZARD.md,docs/UPLOAD_PROGRESS.md,docs/TELEMETRY_CONFIG_RECOMMENDATIONS.md.
- Backend: Erweiterungen in
app/services/— insbesonderefiles.py,raid.py,disk_monitor.py,telemetry.py,smart.py,audit_logger.py,vpn.py,mobile.py. - Frontend: Neue/erweiterte Seiten in
client/src/pages/—FileManager.tsx,RaidManagement.tsx,SystemMonitor.tsx,Logging.tsx. - Docs: Viele technische Ergänzungen und How‑tos im
docs/-Verzeichnis (RAID, Telemetrie, Backup/Restore, Mobile/VPN). - Konfiguration: Neue Umgebungs-/Konfigurationsoptionen für Quotas, Telemetrie-Intervalle und Dev-Mode-Seed.
Service: app/services/auth.py
API Route: app/api/routes/auth.py
-
JWT Token-based Authentication
- Access Tokens with configurable expiry
- Secure token generation with HS256
- Token validation in protected routes
-
Role System
admin: Full access to all resourcesuser: Limited access to own files
-
User Context
- Authentication middleware populates
request.user - User ID and roles available in every request
- Authentication middleware populates
POST /api/auth/login - User login
POST /api/auth/logout - User logout
GET /api/auth/me - Current user
POST /api/auth/refresh - Refresh access token (mobile)
- Admin:
admin/DevMode2024 - User:
user/User123
- Purpose: Allow mobile clients to refresh expired access tokens without re-authentication
- Flow:
- Mobile registration returns 30-day refresh token with unique JTI
- App stores refresh token in secure storage (Keychain)
- When access token expires, call
/api/auth/refreshwith refresh token - Backend checks revocation status before issuing new access token
- Receive new access token (if not revoked)
- Database Model:
RefreshTokenstores all issued refresh tokens with metadata - JTI (JWT ID): Each refresh token has a unique identifier for tracking
- Token Storage:
- Token stored as SHA-256 hash (not plaintext)
- Device ID, IP address, and user agent tracked
- Revocation status and reason logged
- Revocation Methods:
revoke_token(jti)- Revoke specific tokenrevoke_all_user_tokens(user_id)- Revoke all user tokens (e.g., password change)revoke_device_tokens(device_id)- Revoke device-specific tokens
- Security: Compromised tokens can be immediately revoked, preventing unauthorized access
- Service:
app/services/token_service.py
- Für jede Datei können beliebig viele Berechtigungsregeln (pro Nutzer) gesetzt werden.
- Beim Speichern werden immer alle Regeln für die Datei übertragen und im Backend vollständig ersetzt (keine inkrementelle Änderung).
- Die UI lädt beim Öffnen alle existierenden Regeln aus dem Backend und zeigt sie an.
- Änderungen, Hinzufügen und Entfernen von Regeln werden direkt übernommen.
Service: app/services/files.py
API Route: app/api/routes/files.py
Schemas: app/schemas/files.py, app/schemas/storage.py
-
CRUD Operations
- Upload (Single & Multi-File)
- Download
- Folder creation
- Rename
- Move
- Delete (Files & Folders)
-
Storage Mountpoints / Drive Selector ⭐ NEW
- Multi-drive support with visual selector
- Shows RAID arrays as selectable "drives"
- Per-mountpoint capacity and usage
- Path structure:
root\RAID1 Setup - md0\folder\file.txt - See Storage Mountpoints Documentation
-
Quota System
- Configurable via
NAS_QUOTA_BYTES(Default: 5 GB per disk, 2x5GB RAID1) - Quota check before each upload
- Real-time display in Storage Info
- Per-mountpoint capacity tracking
- Configurable via
-
File Ownership & Permissions
- Each file/folder has an owner (User ID)
- Metadata stored in
.metadata.json - Access control: Owner or Admin
- Permission helpers in
app/services/permissions.py
-
Sandbox Storage (Dev-Mode)
- Isolated storage under
backend/dev-storage/ - 2x5GB RAID1 setup (effectively 5 GB, configurable)
- Automatic seed data on startup
- Mock RAID arrays for testing
- Isolated storage under
GET /api/files/mountpoints - List storage devices/arrays
GET /api/files/list - File list
POST /api/files/upload - Upload file
GET /api/files/download - Download file
POST /api/files/create-folder - Create folder
POST /api/files/rename - Rename
POST /api/files/move - Move
DELETE /api/files/delete - Delete
{
"version": 1,
"items": {
"documents/report.pdf": {
"owner_id": 1,
"created_at": "2025-11-23T10:00:00Z",
"size_bytes": 2048000
}
}
}Service: app/services/shares.py
API Route: app/api/routes/shares.py
Schemas: app/schemas/shares.py
-
Public Share Links
- Generate unique shareable links for files/folders
- Optional password protection
- Configurable expiration dates
- Access count tracking
-
Share Management
- Create, read, update, delete shares
- List all shares for a user
- Revoke access at any time
- Share activity logging
-
Access Control
- Password validation for protected shares
- Expiration check on every access
- Owner-only management
- Admin override capabilities
GET /api/shares - List user's shares
POST /api/shares - Create new share
GET /api/shares/{share_id} - Get share details
DELETE /api/shares/{share_id} - Delete share
GET /api/shares/public/{token} - Access shared resource
Service: app/services/backup.py
API Route: app/api/routes/backup.py
Schemas: app/schemas/backup.py
-
Backup Creation
- Full and incremental backups
- Compression support (gzip, bzip2)
- Encryption with password protection
- Metadata preservation
-
Backup Management
- List all backups with metadata
- Size and date tracking
- Automatic cleanup of old backups
- Verification of backup integrity
-
Restore Operations
- Restore from backup with verification
- Selective file restoration
- Conflict resolution options
- Progress tracking
POST /api/backups - Create backup
GET /api/backups - List backups
GET /api/backups/{backup_id} - Get backup details
POST /api/backups/{backup_id}/restore - Restore backup
DELETE /api/backups/{backup_id} - Delete backup
Service: app/services/sync.py, app/services/sync_background.py
API Routes: app/api/routes/sync.py, app/api/routes/sync_advanced.py
Schemas: app/schemas/sync.py
-
Desktop Sync Client
- Real-time folder synchronization
- Selective folder sync
- Conflict detection and resolution
- Bidirectional sync support
-
Background Processing
- Scheduled sync jobs
- Automatic conflict detection
- File change monitoring
- Bandwidth throttling
-
Conflict Resolution
- Manual and automatic resolution
- Version history preservation
- Conflict notification system
- Merge strategies
GET /api/sync/folders - List sync folders
POST /api/sync/folders - Create sync folder
GET /api/sync/conflicts - List conflicts
POST /api/sync/conflicts/{id}/resolve - Resolve conflict
GET /api/sync/status - Sync status
POST /api/sync/force - Force sync
Service: app/services/mobile.py
API Route: app/api/routes/mobile.py
Schemas: app/schemas/mobile.py
-
Device Registration
- Secure token-based registration
- QR code pairing with desktop
- Device management and tracking
- Multiple device support per user
- Device naming and identification
- Refresh tokens matching the device authorization validity (30-180 days, default 90) for long-lived sessions
-
Camera Backup
- Automatic photo/video backup
- Configurable backup settings
- WiFi-only or cellular options
- Battery-aware scheduling
-
Sync Configuration
- Per-device sync folder configuration
- Selective folder sync on mobile
- Background sync support
- Conflict resolution on mobile
POST /api/mobile/token/generate - Generate registration token (with VPN config)
POST /api/mobile/register - Register mobile device
GET /api/mobile/devices - List devices
GET /api/mobile/devices/{device_id} - Get device details
PATCH /api/mobile/devices/{device_id} - Update device
DELETE /api/mobile/devices/{device_id} - Delete device
GET /api/mobile/camera/settings/{device_id} - Get camera backup settings
PUT /api/mobile/camera/settings/{device_id} - Update camera settings
Service: app/services/vpn.py
API Route: app/api/routes/vpn.py
Schemas: app/schemas/vpn.py
Models: app/models/vpn.py
-
WireGuard Configuration
- Automatic keypair generation (private/public keys)
- Preshared key support for additional security
- Client IP assignment from VPN network pool (10.8.0.0/24)
- Server configuration management (singleton pattern)
-
VPN Client Management
- Multiple VPN clients per user
- Device-specific configurations
- Client activation/deactivation
- Last handshake tracking
- Public key-based authentication
-
QR Code Integration
- Desktop generates QR code with VPN config
- Base64-encoded WireGuard configuration
- One-time registration token + VPN setup
- Seamless mobile pairing (scan & connect)
-
Security Features
- Immutable user IDs in JWT tokens
- Time-limited registration tokens (5 minutes)
- Per-device VPN credentials
- Automatic key rotation support
POST /api/vpn/generate-config - Generate WireGuard config for device
GET /api/vpn/clients - List user's VPN clients
GET /api/vpn/clients/{client_id} - Get VPN client details
PATCH /api/vpn/clients/{client_id} - Update VPN client (name, active status)
DELETE /api/vpn/clients/{client_id} - Delete VPN client
POST /api/vpn/clients/{client_id}/revoke - Revoke VPN access (deactivate)
GET /api/vpn/server-config - Get server config (admin only)
POST /api/vpn/handshake/{client_id} - Update last handshake timestamp
Generated WireGuard Config:
[Interface]
PrivateKey = <client_private_key>
Address = 10.8.0.2/32
DNS = 1.1.1.1
[Peer]
PublicKey = <server_public_key>
PresharedKey = <preshared_key>
Endpoint = 192.168.1.100:51820
AllowedIPs = 10.8.0.0/24
PersistentKeepalive = 25VPN Config Table (Singleton):
CREATE TABLE vpn_config (
id INTEGER PRIMARY KEY,
server_private_key VARCHAR(64) NOT NULL,
server_public_key VARCHAR(64) UNIQUE NOT NULL,
server_ip VARCHAR(15) NOT NULL,
server_port INTEGER DEFAULT 51820,
network_cidr VARCHAR(18) NOT NULL,
created_at TIMESTAMP,
updated_at TIMESTAMP
);VPN Clients Table:
CREATE TABLE vpn_clients (
id INTEGER PRIMARY KEY,
user_id INTEGER NOT NULL,
device_name VARCHAR(100) NOT NULL,
public_key VARCHAR(64) UNIQUE NOT NULL,
preshared_key VARCHAR(64) NOT NULL,
assigned_ip VARCHAR(15) UNIQUE NOT NULL,
is_active BOOLEAN DEFAULT 1,
created_at TIMESTAMP,
last_handshake TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);- Mock Key Generation: Uses Base64-encoded random bytes (no
wgcommand required) - Automatic Testing: All VPN APIs functional in dev environment
- Windows Compatible: No Linux-specific dependencies
Service: app/services/users.py
API Route: app/api/routes/users.py
Schemas: app/schemas/user.py
-
User CRUD (Admin-Only)
- List all users
- Create user
- Update user
- Delete user
-
Role Management
- Assign Admin/User roles
- Role-based access control
-
Password Hashing
- Secure storage with bcrypt (passlib)
GET /api/users - List all users (Admin)
POST /api/users - Create user (Admin)
PUT /api/users/{id} - Update user (Admin)
DELETE /api/users/{id} - Delete user (Admin)
Services: app/services/system.py, app/services/telemetry.py, app/services/sensors.py, app/services/disk_monitor.py
API Route: app/api/routes/system.py, app/api/routes/metrics.py (Prometheus)
Schemas: app/schemas/system.py
- CPU usage (psutil)
- CPU frequency (MHz, psutil + sysfs fallback)
- CPU temperature (°C, psutil sensors + hwmon fallback)
- RAM usage (Total, Used, Free)
- Network statistics (Sent/Received)
- Uptime & operating system info
- Background Task collects metrics every N seconds
- Configurable:
TELEMETRY_INTERVAL_SECONDS(Default: 3s) - History size:
TELEMETRY_HISTORY_SIZE(Default: 60 Samples) - Metrics: CPU%, CPU frequency (MHz), CPU temperature (°C), RAM%, Network TX/RX
- Primary Method: psutil (cross-platform)
- Linux Fallback: sysfs (
/sys/devices/system/cpu/cpufreq/,/sys/class/hwmon/) - Temperature Sources: hwmon sensors (coretemp, k10temp, cpu_thermal)
- Frequency Sources: cpufreq scaling, /proc/cpuinfo
- Graceful Degradation: Warning-level logging for missing sensors, continues with available data
- CPU Metrics:
baluhost_cpu_usage_percent,baluhost_cpu_frequency_mhz,baluhost_cpu_temperature_celsius - Memory Metrics:
baluhost_memory_*_bytes,baluhost_memory_usage_percent - Disk Metrics: I/O, SMART health, temperatures
- RAID Metrics: Array status, sync progress
- Application Metrics: HTTP requests, database stats, user activity
Linux Systems (Recommended):
# Install lm-sensors for enhanced temperature monitoring
sudo apt update && sudo apt install lm-sensors
# Detect and load sensor modules (run once)
sudo sensors-detect
# Follow prompts and accept recommended modules
# Test sensors
sensorsFallback Operation:
- Without lm-sensors: Uses psutil-only (may have limited temperature data)
- In containers/VMs: Falls back to available system interfaces
- Dev-mode: Includes sensor diagnostics in logs
- Real-time monitoring of all physical disks
- Sampling: 1 second
- History: 120 samples (2 minutes)
- Metrics:
- Read/Write MB/s (Throughput)
- Read/Write IOPS (Operations per Second)
- Platform Support:
- Windows:
PhysicalDrive0,PhysicalDrive1, ... - Linux:
sda,sdb,nvme0n1, ...
- Windows:
- Audit Logging: Automatic summary every 60 seconds
- Total storage & usage
- Available storage
- Quota information
- Top N processes by CPU/RAM
- PID, Name, CPU%, Memory%
GET /api/system/info - System info
GET /api/system/storage - Storage info
GET /api/system/quota - Quota status
GET /api/system/processes - Process list
GET /api/system/telemetry/history - Telemetry history
GET /api/system/disk-io/history - Disk I/O history
Service: app/services/raid.py
API Route: app/api/routes/system.py
-
RAID Status Query
- Parses
/proc/mdstat(Linux) or provides mock data (Dev-Mode) - Status: optimal, degraded, rebuilding, inactive
- Parses
-
RAID Simulation & Control
- Degrade array / Start rebuild / Finalize rebuild
- Bitmap management (internal/none)
- Write-mostly devices
- Add/remove spare devices
- Start integrity check (scrub)
- Configurable sync limits (min/max kB/s)
-
Disk Management
- Retrieve list of available disks
- Format disks (ext4, ext3, xfs, btrfs)
- Create RAID arrays (RAID 0, 1, 5, 6, 10)
- Delete RAID arrays
- Dev-Mode: 7 mock disks (2x5GB, 2x10GB, 3x20GB) with RAID1 setup (sda1, sdb1 in md0)
GET /api/system/raid/status - RAID status
POST /api/system/raid/degrade - Degrade simulation (Admin)
POST /api/system/raid/rebuild - Start rebuild (Admin)
POST /api/system/raid/finalize - Finalize rebuild (Admin)
POST /api/system/raid/options - Set RAID options (Admin)
GET /api/system/raid/available-disks - Available disks (Admin)
POST /api/system/raid/format-disk - Format disk (Admin)
POST /api/system/raid/create-array - Create array (Admin)
POST /api/system/raid/delete-array - Delete array (Admin)
{
"healthy": true,
"arrays": [
{
"name": "md0",
"level": "raid1",
"status": "optimal",
"size_bytes": 5368709120,
"devices": [
{"name": "sda1", "state": "active"},
{"name": "sdb1", "state": "active"}
],
"resync_progress": null,
"bitmap": "internal",
"sync_action": "idle"
}
],
"speed_limits": {
"minimum": 5000,
"maximum": 200000
}
}Available Disks (Dev-Mode):
{
"disks": [
{
"name": "sda",
"size_bytes": 5368709120,
"model": "BaluHost Dev Disk 5GB (Mirror A) (in RAID)",
"is_partitioned": true,
"partitions": ["sda1"],
"in_raid": true
},
{
"name": "sdb",
"size_bytes": 5368709120,
"model": "BaluHost Dev Disk 5GB (Mirror B) (in RAID)",
"is_partitioned": true,
"partitions": ["sdb1"],
"in_raid": true
},
{
"name": "sdc",
"size_bytes": 10737418240,
"model": "BaluHost Dev Disk 10GB (Backup A)",
"is_partitioned": true,
"partitions": ["sdc1"],
"in_raid": false
},
{
"name": "sdd",
"size_bytes": 10737418240,
"model": "BaluHost Dev Disk 10GB (Backup B)",
"is_partitioned": true,
"partitions": ["sdd1"],
"in_raid": false
},
{
"name": "sde",
"size_bytes": 21474836480,
"model": "BaluHost Dev Disk 20GB (Archive A)",
"is_partitioned": true,
"partitions": ["sde1"],
"in_raid": false
},
{
"name": "sdf",
"size_bytes": 21474836480,
"model": "BaluHost Dev Disk 20GB (Archive B)",
"is_partitioned": true,
"partitions": ["sdf1"],
"in_raid": false
},
{
"name": "sdg",
"size_bytes": 21474836480,
"model": "BaluHost Dev Disk 20GB (Archive C)",
"is_partitioned": true,
"partitions": ["sdg1"],
"in_raid": false
}
]
}Service: app/services/smart.py
API Route: app/api/routes/system.py
-
SMART Status Query
- Reads SMART data via
smartctl(Linux) - Mock data in Dev-Mode
- Reads SMART data via
-
Health Check
- Overall Health: PASSED / FAILED
- Temperature, Power-On-Hours
- Reallocated Sectors, Pending Sectors
GET /api/system/smart/status - SMART status of all disks
{
"devices": [
{
"device": "/dev/sda",
"model": "Samsung SSD 870",
"health": "PASSED",
"temperature": 35,
"power_on_hours": 1234,
"attributes": {
"reallocated_sectors": 0,
"pending_sectors": 0
}
}
]
}Service: app/services/audit_logger.py
API Route: app/api/routes/logging.py
-
Event Types:
FILE_ACCESS: Upload, Download, Delete, Move, Create FolderDISK_MONITOR: Start, Stop, Error, SummarySYSTEM_EVENT: Startup, Shutdown, Config Changes
-
Log Format: JSON
{ "timestamp": "2025-11-23T10:30:45.123456+00:00", "event_type": "FILE_ACCESS", "user": "admin", "action": "upload", "resource": "/documents/report.pdf", "success": true, "details": {"size_bytes": 2048000} } -
Configuration:
- Dev-Mode: Logging disabled
- Production-Mode: Logging enabled
- Log path:
{nas_temp_path}/audit/audit.log
-
API Access:
- Read audit logs
- Filter by event type, user, time period
GET /api/logging/audit - Retrieve audit logs
GET /api/logging/audit/filter - Filtered logs
Services: app/services/jobs.py, app/services/scheduler_service.py
API Route: app/api/routes/schedulers.py
Models: app/models/scheduler_history.py
Schemas: app/schemas/scheduler.py
-
Telemetry Collection
- Periodic background task
- Collects CPU, RAM, Network
- Configurable interval
-
Disk I/O Monitor
- Continuous sampling
- 1 second interval
- Automatic logging every 60s
-
Job Management:
- Start/stop background tasks
- Lifecycle management via FastAPI Lifespan
The Scheduler Service provides centralized management for all system background jobs with execution tracking, manual triggers, and configuration.
Managed Schedulers (6 total):
| Scheduler | Display Name | Default Interval | Description |
|---|---|---|---|
raid_scrub |
RAID Scrub | Weekly (7 days) | Data integrity checks on RAID arrays |
smart_scan |
SMART Scan | Hourly (60 min) | Disk health monitoring via SMART |
backup |
Auto Backup | Daily (24 hours) | Automated system backups |
sync_check |
Sync Check | 5 minutes | Triggers due sync schedules |
notification_check |
Notification Check | Hourly | Device expiration warnings |
upload_cleanup |
Upload Cleanup | Daily (3 AM) | Cleans expired chunked uploads |
Features:
- Execution History Tracking - Records every run with start/end time, status, duration, and error details
- Run-Now Functionality - Trigger any scheduler immediately via API
- Enable/Disable Toggle - Pause schedulers without removing configuration
- Timeline View - Visual execution history across all schedulers
- Retry Mechanism - Re-run failed executions with one click
- Service Status Integration - RAID scrub and SMART scan integrate with service status monitoring
GET /api/schedulers - List all schedulers with status
GET /api/schedulers/{name} - Get specific scheduler details
POST /api/schedulers/{name}/run-now - Trigger immediate execution
GET /api/schedulers/{name}/history - Get execution history for scheduler
GET /api/schedulers/history/all - Get combined execution timeline
POST /api/schedulers/{name}/toggle - Enable/disable scheduler
SchedulerExecution Table:
CREATE TABLE scheduler_executions (
id INTEGER PRIMARY KEY,
scheduler_name VARCHAR(50) NOT NULL,
started_at TIMESTAMP NOT NULL,
ended_at TIMESTAMP,
status VARCHAR(20) NOT NULL, -- pending, running, completed, failed
trigger_type VARCHAR(20), -- scheduled, manual, retry
error_message TEXT,
result_data JSON,
created_at TIMESTAMP
);SchedulerConfig Table:
CREATE TABLE scheduler_configs (
id INTEGER PRIMARY KEY,
scheduler_name VARCHAR(50) UNIQUE NOT NULL,
is_enabled BOOLEAN DEFAULT TRUE,
interval_seconds INTEGER,
last_run_at TIMESTAMP,
next_run_at TIMESTAMP,
created_at TIMESTAMP,
updated_at TIMESTAMP
);- SchedulerDashboard.tsx - Main dashboard page with 5 tabs
- SchedulerOverview.tsx - Summary cards for all schedulers
- SchedulerTable.tsx - Detailed table with run-now and toggle actions
- SchedulerHistory.tsx - Per-scheduler execution history
- SchedulerTimeline.tsx - Visual timeline across all schedulers
- SchedulerSettings.tsx - Configuration panel (intervals, enable/disable)
ORM: SQLAlchemy 2.0+
Migration Tool: Alembic
Models: app/models/
-
Database Models
- User model with authentication data
- FileMetadata model for file ownership
- Share model for file sharing
- Backup model for backup management
- SyncFolder model for sync configuration
- MobileDevice model for mobile registration
- AuditLog model for security logging
-
Database Operations
- CRUD operations via SQLAlchemy
- Relationship management (foreign keys)
- Transaction support
- Database session management
-
Migrations
- Alembic for schema versioning
- Automatic migration generation
- Rollback support
- Database upgrade/downgrade
-
Database Support
- SQLite for development
- PostgreSQL for production
- Configurable via DATABASE_URL
CREATE TABLE users (
id INTEGER PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
email VARCHAR(100) NOT NULL,
hashed_password VARCHAR(255) NOT NULL,
role VARCHAR(20) NOT NULL,
created_at TIMESTAMP,
updated_at TIMESTAMP
);
CREATE TABLE file_metadata (
id INTEGER PRIMARY KEY,
path VARCHAR(1000) UNIQUE NOT NULL,
name VARCHAR(255) NOT NULL,
owner_id INTEGER NOT NULL,
size_bytes INTEGER NOT NULL,
is_directory BOOLEAN NOT NULL,
mime_type VARCHAR(100),
parent_path VARCHAR(1000),
created_at TIMESTAMP,
updated_at TIMESTAMP,
FOREIGN KEY (owner_id) REFERENCES users(id)
);
CREATE TABLE shares (
id INTEGER PRIMARY KEY,
token VARCHAR(64) UNIQUE NOT NULL,
file_path VARCHAR(1000) NOT NULL,
owner_id INTEGER NOT NULL,
password_hash VARCHAR(255),
expires_at TIMESTAMP,
access_count INTEGER DEFAULT 0,
created_at TIMESTAMP,
FOREIGN KEY (owner_id) REFERENCES users(id)
);
-- Additional tables: backups, sync_folders, mobile_devices, audit_logsModule: app/api/docs.py
-
Custom Swagger UI
- BaluHost branded styling
- Matches frontend design (dark theme, glassmorphism)
- Custom colors and fonts
- Enhanced readability
-
Styling Features
- Dark background with gradient
- Custom topbar with BaluHost branding
- Color-coded HTTP methods (GET, POST, PUT, DELETE)
- Glassmorphism effects on cards
- Smooth transitions and hover effects
-
Documentation Access
- Swagger UI:
/docs - ReDoc:
/redoc - Auto-generated from FastAPI schemas
- Swagger UI:
Service: app/services/power_manager.py, app/services/power_monitor.py
API Route: app/api/routes/monitoring.py
Models: app/models/monitoring.py
-
CPU Frequency Scaling
- AMD Ryzen & Intel processor support
- 4 Power Profiles: IDLE, LOW, MEDIUM, SURGE
- Automatic scaling based on system demand
- Manual profile override
-
Power Profiles
- IDLE: Minimum frequency, maximum power savings
- LOW: Balanced efficiency for light workloads
- MEDIUM: Standard performance
- SURGE: Maximum frequency for heavy workloads
-
Power Monitoring
- Real-time CPU frequency tracking
- Power consumption estimation
- Profile change history logging
- Temperature-based throttling
GET /api/power/status - Current power state
GET /api/power/profiles - Available profiles
POST /api/power/profile - Set power profile
GET /api/power/history - Profile change history
CREATE TABLE power_profile_config (
id INTEGER PRIMARY KEY,
profile_name VARCHAR(50) NOT NULL,
min_freq_mhz INTEGER,
max_freq_mhz INTEGER,
governor VARCHAR(50),
is_active BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP,
updated_at TIMESTAMP
);
CREATE TABLE power_sample (
id INTEGER PRIMARY KEY,
timestamp TIMESTAMP NOT NULL,
cpu_freq_mhz INTEGER,
power_watts FLOAT,
temperature_celsius FLOAT,
profile_name VARCHAR(50)
);
CREATE TABLE power_profile_log (
id INTEGER PRIMARY KEY,
timestamp TIMESTAMP NOT NULL,
old_profile VARCHAR(50),
new_profile VARCHAR(50),
reason VARCHAR(255),
user_id INTEGER
);Service: app/services/fan_control.py
API Route: app/api/routes/monitoring.py
Models: app/models/monitoring.py
-
PWM Fan Control
- Direct PWM control for connected fans
- RPM monitoring and feedback
- Multiple fan support
-
Operating Modes
auto: Temperature-based automatic controlmanual: User-defined PWM valuesemergency: Maximum speed on critical temperature
-
Temperature Curves
- Customizable temperature-to-PWM mapping
- Curve editor in frontend
- Hysteresis to prevent rapid changes
-
Safety Features
- Minimum PWM floor (fans never stop completely)
- Emergency override on critical temperature
- Fallback to maximum speed on sensor failure
GET /api/fans/status - All fans status
GET /api/fans/{fan_id} - Single fan details
POST /api/fans/{fan_id}/mode - Set fan mode
POST /api/fans/{fan_id}/pwm - Set manual PWM (manual mode)
GET /api/fans/{fan_id}/curve - Get temperature curve
POST /api/fans/{fan_id}/curve - Set temperature curve
GET /api/fans/history - Fan history data
CREATE TABLE fan_config (
id INTEGER PRIMARY KEY,
fan_id VARCHAR(50) UNIQUE NOT NULL,
name VARCHAR(100),
mode VARCHAR(20) DEFAULT 'auto',
manual_pwm INTEGER,
min_pwm INTEGER DEFAULT 20,
max_pwm INTEGER DEFAULT 100,
curve_points JSON,
created_at TIMESTAMP,
updated_at TIMESTAMP
);
CREATE TABLE fan_sample (
id INTEGER PRIMARY KEY,
fan_id VARCHAR(50) NOT NULL,
timestamp TIMESTAMP NOT NULL,
rpm INTEGER,
pwm INTEGER,
temperature_celsius FLOAT
);Service: app/services/monitoring/orchestrator.py
Collectors: CPU, Memory, Network, Disk I/O, Process
-
Unified Monitoring System
- Central orchestrator for all collectors
- Configurable collection intervals
- Database persistence with retention policies
-
Collectors
CPUCollector: Usage, frequency, temperature, per-thread statsMemoryCollector: RAM usage, swap, available memoryNetworkCollector: Interface throughput, packet countsDiskIOCollector: Read/write IOPS, throughputProcessCollector: BaluHost process tracking
-
Retention Policies
- Configurable data retention per metric type
- Automatic cleanup of old samples
- Database optimization
CREATE TABLE monitoring_config (
id INTEGER PRIMARY KEY,
metric_type VARCHAR(50) UNIQUE NOT NULL,
retention_hours INTEGER DEFAULT 168,
collection_interval_seconds INTEGER DEFAULT 3,
enabled BOOLEAN DEFAULT TRUE
);
CREATE TABLE cpu_samples (
id INTEGER PRIMARY KEY,
timestamp TIMESTAMP NOT NULL,
usage_percent FLOAT,
frequency_mhz INTEGER,
temperature_celsius FLOAT,
per_thread_usage JSON
);
CREATE TABLE memory_samples (
id INTEGER PRIMARY KEY,
timestamp TIMESTAMP NOT NULL,
total_bytes BIGINT,
used_bytes BIGINT,
available_bytes BIGINT,
usage_percent FLOAT
);
CREATE TABLE network_samples (
id INTEGER PRIMARY KEY,
timestamp TIMESTAMP NOT NULL,
interface VARCHAR(50),
bytes_sent BIGINT,
bytes_recv BIGINT,
packets_sent BIGINT,
packets_recv BIGINT
);
CREATE TABLE disk_io_samples (
id INTEGER PRIMARY KEY,
timestamp TIMESTAMP NOT NULL,
device VARCHAR(50),
read_bytes BIGINT,
write_bytes BIGINT,
read_iops INTEGER,
write_iops INTEGER
);
CREATE TABLE process_samples (
id INTEGER PRIMARY KEY,
timestamp TIMESTAMP NOT NULL,
pid INTEGER,
name VARCHAR(255),
cpu_percent FLOAT,
memory_percent FLOAT
);Service: app/services/service_status.py
API Route: app/api/routes/service_status.py
Schemas: app/schemas/service_status.py
-
Service Health Dashboard
- Real-time health status for all services
- Service registry with metadata
- Restart/stop/start capabilities (admin only)
-
Health Checks
- Database connectivity
- Background job status
- Disk space availability
- Memory usage thresholds
-
Service Registry
- Automatic service discovery
- Health endpoint aggregation
- Dependency tracking
GET /api/services/status - All services status
GET /api/services/{name} - Single service details
POST /api/services/{name}/restart - Restart service (admin)
POST /api/services/{name}/stop - Stop service (admin)
POST /api/services/{name}/start - Start service (admin)
GET /api/services/health - Aggregated health check
Service: app/services/admin_db.py
API Route: app/api/routes/admin_db.py
-
Read-Only Database Browser
- Whitelist-based table access
- Sensitive data redaction
- Query result pagination
-
Security Features
- Admin-only access
- Read-only operations (no modifications)
- Automatic PII redaction
- Audit logging of all queries
-
UI Components
- Table browser with stats
- Storage usage visualization
- Query history
- Maintenance tools
GET /api/admin-db/tables - List available tables
GET /api/admin-db/tables/{name} - Table data (paginated)
GET /api/admin-db/stats - Database statistics
GET /api/admin-db/storage - Storage breakdown
Smart device support (e.g., TP-Link Tapo) is now part of the Plugin System. See Section 23 for the full plugin architecture.
Unified API: app/api/routes/smart_devices.py
Plugin: app/plugins/installed/tapo_smart_plug/
Framework: app/plugins/smart_device/
- Tapo integration migrated from standalone service to
SmartDevicePlugin - All smart devices share the unified
/api/smart-devices/API - Capability-based architecture (Switch, PowerMonitor, Sensor, Dimmer, ColorControl)
- SHM-based polling in monitoring worker, encrypted credential storage
- Dashboard panel support for power monitoring visualization
GET /api/smart-devices/ - List all smart devices
POST /api/smart-devices/ - Add device
GET /api/smart-devices/{id} - Device details + state
PUT /api/smart-devices/{id} - Update device
DELETE /api/smart-devices/{id} - Delete device
POST /api/smart-devices/{id}/command - Execute command (turn_on, set_brightness, etc.)
GET /api/smart-devices/types - Available device types
GET /api/smart-devices/power-summary - Aggregated power consumption
GET /api/energy/status - Energy consumption data
GET /api/energy/history - Energy usage history
Service: app/services/network_discovery.py
API Route: app/api/routes/system.py
-
mDNS/Bonjour Broadcasting
- Automatic service announcement
- Local network discovery
- Zero-configuration networking
-
Service Types
_http._tcp- Web interface_baluhost._tcp- BaluHost API_webdav._tcp- WebDAV access
-
Device Discovery
- Find other BaluHost instances
- Network topology mapping
- Service availability checks
GET /api/discovery/services - Discovered services
GET /api/discovery/status - mDNS status
POST /api/discovery/scan - Trigger network scan
Configuration: app/core/config.py
Services: All services with Dev-Mode support
-
Environment Flag:
NAS_MODE=dev -
Sandbox Storage:
backend/dev-storage/(2x5GB RAID1 setup, effectively 5 GB) -
Mock Data:
- Users (admin, user)
- Files & folders (demo structure)
- RAID status
- SMART data
- System metrics (when psutil not available)
-
Windows Compatibility:
- All features work on Windows
- No Linux-specific code required
- Disk I/O monitor detects Windows disks
-
Seed Data:
- Automatic initialization on startup
- Demo folders: Documents, Media
- Demo files with owner metadata
start_dev.py- Combined frontend + backend startscripts/dev_check.py- API test scriptscripts/reset_dev_storage.py- Reset sandbox
Core: app/plugins/ (base, manager, hooks, events, permissions, dashboard_panel)
Smart Devices: app/plugins/smart_device/ (base, capabilities, manager, poller, schemas)
Installed: app/plugins/installed/ (optical_drive, storage_analytics, tapo_smart_plug)
Full Documentation: backend/app/plugins/README.md
The plugin system provides modular extensibility with:
- PluginBase ABC — All plugins extend this. Provides lifecycle hooks (
on_startup,on_shutdown), route injection, background tasks, event handlers, UI manifests, config schemas, dashboard panels, and i18n translations. - PluginManager — Singleton that handles discovery (scanning
installed/for__init__.py), loading, permission validation, activation, route mounting at/api/plugins/{name}/, and graceful shutdown. - Pluggy Hooks — 30+ typed hook specifications for system events (file ops, user events, backup, RAID, SMART, VPN, smart devices). Plugins implement hooks with
@hookimpl. - Async Event Manager — Queue-based event system complementing Pluggy. Supports wildcard subscribers and non-blocking dispatch.
- Permission System — 15 granular permissions. 5 marked as dangerous (
file:write,file:delete,system:execute,db:write,user:write) requiring explicit admin approval. - Dashboard Panels — Plugins can claim a dashboard slot with panel types: gauge, stat, status, chart.
- Discovery — Scan
installed/for directories with__init__.py - Loading — Import module, find
PluginBasesubclass - Permission Check — Validate required permissions against granted list
- Activation —
on_startup(), register Pluggy hooks, subscribe events, start background tasks - Running — Routes mounted, tasks running, hooks active
- Deactivation — Stop tasks, unsubscribe events,
on_shutdown()
Specialized SmartDevicePlugin base class for IoT devices:
- Capability Protocols:
Switch,PowerMonitor,Sensor,Dimmer,ColorControl— runtime-checkable Python protocols - SmartDeviceManager: Web-worker-side CRUD, command dispatch, SHM state reads
- SmartDevicePoller: Runs in monitoring worker process, polls all active devices, writes state to SHM files (
smart_devices.json,smart_devices_changes.json), periodically persists to DB - Encrypted Config: Device credentials stored with Fernet encryption via
VPNEncryption
| Plugin | Category | Features |
|---|---|---|
optical_drive |
storage | CD/DVD/Blu-ray read, rip (ISO/WAV), burn, blank. Custom routes, UI, config, async jobs |
storage_analytics |
storage | Per-user usage, file type distribution, top files. Background tasks, Pluggy hooks |
tapo_smart_plug |
smart_device | TP-Link Tapo P110/P115. Switch + PowerMonitor, dashboard gauge panel, i18n (en/de) |
GET /api/plugins/ - List all plugins (discovered + enabled)
POST /api/plugins/{name}/enable - Enable plugin (with permission grant)
POST /api/plugins/{name}/disable - Disable plugin
GET /api/plugins/{name}/config - Plugin configuration
PUT /api/plugins/{name}/config - Update plugin config
GET /api/plugins/ui-manifest - Combined UI manifest for frontend
/api/plugins/{name}/... - Plugin-specific routes
Component: src/pages/Login.tsx
API Client: src/lib/api.ts
-
Login Form
- Username & password
- Error handling
- Redirect after successful login
-
JWT Token Handling
- Token in localStorage
- Automatic addition to API requests (Authorization Header)
- Token refresh (Placeholder)
-
Protected Routes
- Redirect to login when not authenticated
- Role-based route guards (admin pages)
Component: src/pages/Dashboard.tsx
Hook: src/hooks/useSystemTelemetry.ts
-
System Overview:
- CPU usage (real-time)
- RAM usage (real-time)
- Network statistics (Sent/Received)
- Storage overview (Used/Total)
-
Live Charts (Recharts):
- CPU sparkline (last 60 seconds)
- RAM sparkline (last 60 seconds)
- Network sparkline (TX/RX)
-
Auto-Refresh:
- Polling every 5 seconds
- Custom hook:
useSystemTelemetry
-
Stat Cards:
- Current values prominent
- Color coding (Green/Yellow/Red)
- Icons for visual orientation
Component: src/pages/FileManager.tsx
-
File Browser:
- Breadcrumb navigation
- Folder hierarchy
- File/folder list with icons
-
Operations:
- Upload (Multiple Files)
- Download
- Create folder
- Rename (Modal)
- Move (Modal)
- Delete (Confirmation)
-
Permissions:
- Owner display
- Actions only visible for owner/admin
- Error feedback for missing rights
-
UI Features:
- File sizes formatted (KB, MB, GB)
- Date formatted (locale)
- Context menu (Right-click, Placeholder)
- Loading states
Component: src/pages/UserManagement.tsx
-
User List:
- Table with ID, Username, Role
- Sorting (Placeholder)
-
CRUD Operations:
- Create user (Modal)
- Edit user (Modal)
- Delete user (Confirmation)
-
Role Management:
- Admin/User dropdown
- Role update via API
-
Validation:
- Client-side form validation
- Server error handling
Component: src/pages/RaidManagement.tsx
API Client: src/api/raid.ts
-
RAID Status Display:
- Array name, level, status, bitmap, sync action
- Device list with states (active, failed, rebuilding, spare, write-mostly)
- Resync progress with visual progress bar
- Capacity & device count
- Sync speed limits (min/max kB/s)
-
RAID Control (Admin):
- Enable/disable bitmap
- Start integrity check (scrub)
- Degrade array (Simulation/Real)
- Start rebuild for failed devices
- Finalize rebuild
- Delete array (with confirmation)
-
Device Management:
- Degrade individual devices
- Start rebuild for specific devices
- Set/remove write-mostly status
- Remove spare devices
- Add new spare device (form)
-
Sync Limits:
- Configure min/max speed (kB/s)
- Form for speed limits
-
Available Disks:
- Table with name, size, model, status
- Status badges: "In RAID", "Partitioned"
- Auto-refresh available disks
-
Disk Formatting:
- Modal dialog for formatting
- Filesystem selection (ext4, ext3, xfs, btrfs)
- Optional: Set label
- Only available for disks not in RAID
-
Array Creation:
- Modal dialog for new arrays
- RAID level selection (0, 1, 5, 6, 10)
- Device input (comma-separated)
- Optional: Spare devices
- Array name input
-
UI Features:
- Loading states for all operations
- Error/Success toasts
- Confirmation dialogs for destructive actions
- Buttons disabled when disk in RAID
- Auto-refresh every 8 seconds
Component: src/pages/SystemMonitor.tsx
Hooks: src/hooks/useSystemTelemetry.ts, src/hooks/useSmartData.ts
-
Disk Selection:
- Button group for all physical disks
- Active disk highlighted
-
Real-Time Charts:
- Read/Write throughput (MB/s)
- Read/Write IOPS
- Toggle between views
- 60 seconds history
- Auto-update every 2 seconds
-
Stat Cards:
- Current read MB/s
- Current write MB/s
- Current read IOPS
- Current write IOPS
-
Device List:
- Model, device path
- Health status (badge)
- Temperature
-
Attributes:
- Power-on-hours
- Reallocated sectors
- Pending sectors
-
Refresh:
- Manual refresh button
- Loading state
- Top Processes:
- PID, name, CPU%, Memory%
- Sorted by CPU usage
- Limit: Top 10
Component: src/pages/Logging.tsx
API Client: src/api/logging.ts
-
Log Display:
- Table with timestamp, event type, user, action, resource
- Color coding by event type
-
Filter:
- By event type
- By user
- By time period (Placeholder)
-
Pagination:
- Next/Previous
- Configurable limit
-
Details View:
- Modal with complete log details
- JSON-formatted details
-
Export:
- Download as JSON (Placeholder)
Component: src/components/Layout.tsx
-
Sidebar Navigation:
- Logo
- Navigation links (Dashboard, Files, Users, RAID, Monitor, Logs)
- Active state highlighting
- Icons (lucide-react)
-
Header:
- Breadcrumb (optional)
- User menu (Logout)
-
Responsive Design:
- Mobile menu (Toggle, Placeholder)
- Breakpoints via Tailwind
-
Protected Layout:
- Checks auth status
- Redirect to login if needed
Module: src/lib/api.ts, src/api/*.ts
-
Base Client:
- Axios instance
- Authorization header automatic
- Error handling (401 → Logout)
- Base URL configurable
-
Type-Safe API Calls:
- TypeScript interfaces for all requests/responses
- Auto-complete in IDE
-
Modular Structure:
api/raid.ts- RAID endpointsapi/smart.ts- SMART endpointsapi/logging.ts- Logging endpoints
- Polls system telemetry data
- Interval: 5 seconds
- Manages loading/error states
- Loads SMART data on-demand
- Manual refresh function
Baluhost/
├── backend/ # Python FastAPI Backend
│ ├── app/
│ │ ├── api/
│ │ │ ├── routes/ # API endpoints
│ │ │ │ ├── auth.py
│ │ │ │ ├── files.py
│ │ │ │ ├── users.py
│ │ │ │ ├── system.py
│ │ │ │ └── logging.py
│ │ │ └── deps.py # Dependency Injection
│ │ ├── core/
│ │ │ └── config.py # Konfiguration & Settings
│ │ ├── models/ # DB-Models (Placeholder)
│ │ ├── schemas/ # Pydantic-Schemas
│ │ │ ├── auth.py
│ │ │ ├── files.py
│ │ │ ├── user.py
│ │ │ └── system.py
│ │ ├── services/ # Business logic
│ │ │ ├── auth.py # JWT, Login/Refresh
│ │ │ ├── files/ # File operations, quota
│ │ │ ├── hardware/ # RAID (mdadm), SMART
│ │ │ ├── power/ # CPU frequency, fan control, energy
│ │ │ ├── vpn/ # WireGuard, encryption
│ │ │ ├── monitoring/ # Unified monitoring with collectors
│ │ │ ├── scheduler/ # Scheduler management
│ │ │ ├── notifications/ # Firebase push
│ │ │ ├── backup/ # Backup/restore
│ │ │ ├── sync/ # Desktop sync
│ │ │ ├── audit/ # Audit logging, admin DB
│ │ │ └── ... # cloud, versioning, pihole, etc.
│ │ ├── plugins/ # Plugin system (see plugins/README.md)
│ │ │ ├── base.py # PluginBase ABC, metadata
│ │ │ ├── manager.py # Discovery, lifecycle, routing
│ │ │ ├── hooks.py # Pluggy hook specs (30+)
│ │ │ ├── events.py # Async event manager
│ │ │ ├── permissions.py # 15 granular permissions
│ │ │ ├── dashboard_panel.py # Dashboard panel schemas
│ │ │ ├── smart_device/ # Smart device subsystem
│ │ │ └── installed/ # Bundled plugins
│ │ │ ├── optical_drive/
│ │ │ ├── storage_analytics/
│ │ │ └── tapo_smart_plug/
│ │ └── main.py # FastAPI App
│ ├── dev-storage/ # Dev-Mode Sandbox
│ ├── dev-tmp/ # Dev-Mode Temp (Audit Logs)
│ ├── scripts/
│ │ ├── dev_check.py # API test script
│ │ ├── reset_dev_storage.py
│ │ └── benchmark_telemetry.py
│ ├── tests/ # Pytest tests
│ ├── pyproject.toml # Python project config
│ └── README.md
│
├── client/ # React TypeScript Frontend
│ ├── src/
│ │ ├── api/ # API client modules
│ │ │ ├── raid.ts
│ │ │ ├── smart.ts
│ │ │ └── logging.ts
│ │ ├── components/
│ │ │ └── Layout.tsx
│ │ ├── hooks/
│ │ │ ├── useSystemTelemetry.ts
│ │ │ └── useSmartData.ts
│ │ ├── lib/
│ │ │ └── api.ts # Base API client
│ │ ├── pages/
│ │ │ ├── Login.tsx
│ │ │ ├── Dashboard.tsx
│ │ │ ├── FileManager.tsx
│ │ │ ├── UserManagement.tsx
│ │ │ ├── RaidManagement.tsx
│ │ │ ├── SystemMonitor.tsx
│ │ │ ├── Logging.tsx
│ │ │ ├── SettingsPage.tsx # User settings & preferences
│ │ │ ├── PowerManagement.tsx # Power profiles & CPU control
│ │ │ ├── FanControl.tsx # Fan control & curves
│ │ │ ├── AdminDatabase.tsx # Database browser
│ │ │ ├── AdminHealth.tsx # Service status dashboard
│ │ │ └── ApiCenterPage.tsx # API documentation center
│ │ ├── contexts/
│ │ │ └── ThemeContext.tsx # Theme management (prepared for future use)
│ │ ├── App.tsx
│ │ └── main.tsx
│ ├── public/
│ ├── package.json
│ ├── vite.config.ts
│ ├── tailwind.config.js
│ └── README.md
│
├── start_dev.py # Combined dev start
├── TODO.md # Global TODO list
├── TECHNICAL_DOCUMENTATION.md # This file
└── README.md # Project README
# Backend
cd backend
python -m venv .venv
.venv\Scripts\activate # Windows
pip install -e ".[dev]"
# Frontend
cd client
npm install
# Kombinierter Start
python start_dev.pyURLs:
- Frontend: http://localhost:5173
- Backend API: http://localhost:8000/api
# Backend
cd backend
pip install .
uvicorn app.main:app --host 0.0.0.0 --port 8000
# Frontend (Build)
cd client
npm run build
# Serve dist/ with Nginx or other web servercd backend
python -m pytest
python -m pytest tests/test_permissions.py -vcd client
npm run test # Unit tests (Placeholder)
npm run test:e2e # E2E tests (Placeholder)- Sample Time: ~3.8ms
- CPU Impact @ 1s interval: 0.38%
- CPU Impact @ 3s interval: 0.13%
Recommended Configuration:
- Dev: 2s interval, 90 samples
- Production: 3s interval, 60 samples
- Sample interval: 1s
- History: 120 samples (2 minutes)
- Overhead: ~0.1% CPU
- JWT tokens with expiry (access: 15min, refresh: 7 days)
- Password hashing (bcrypt via passlib)
- Two-Factor Authentication (TOTP)
- File ownership & permissions with
_jail_path()sandbox - Role-based access control (RBAC) with
admin/userroles - Audit logging of all critical actions (database-backed)
- Quota system for resource limitation
- Rate limiting (slowapi with per-endpoint limits)
- Security headers middleware (CSP, HSTS, X-Frame-Options, X-Content-Type-Options)
- Encrypted VPN/SSH/device keys (Fernet AES)
- Subprocess safety (list-args only, no
shell=True) - SQLAlchemy ORM-only queries (no raw SQL with user input)
- HTTPS (external access via WireGuard VPN, HTTP on trusted LAN)
- CSRF protection (mitigated by JWT Bearer auth, no cookie-based auth)
Complete API reference: See docs/API_REFERENCE.md.
FastAPI Docs (automatically generated with custom styling):
- Swagger UI: http://localhost:8000/docs (Custom BaluHost design)
- ReDoc: http://localhost:8000/redoc
Custom Swagger Features:
- Dark theme matching frontend design
- Glassmorphism effects
- Color-coded endpoints by HTTP method
- Enhanced readability and navigation
scripts/dev_check.py- API test scriptscripts/reset_dev_storage.py- Reset sandboxscripts/benchmark_telemetry.py- Performance test
- Vite HMR (Hot Module Replacement)
- React DevTools
- Tailwind CSS IntelliSense
Comprehensive user settings interface with multiple tabs:
- Display user information (username, role, member since)
- Avatar upload and management
- Email address update
- Account information overview (ID, role, creation date)
- Password change functionality
- Active session management
- Security settings overview
- Theme preview system (6 color schemes: Light, Dark, Ocean, Forest, Sunset, Midnight)
- Theme selection interface with color previews
- Note: Theme switching prepared but currently uses fixed dark theme
- LocalStorage persistence for theme preferences
- Storage quota visualization with progress bars
- Used vs. available space display
- Percentage-based quota tracking
- Auto-updates from backend
/api/system/quotaendpoint
- Recent audit log entries
- Action history with timestamps
- Success/failure status indicators
- Detailed activity information from
/api/logging/auditendpoint
Components:
AppearanceSettings.tsx- Theme selection component with color previewsThemeContext.tsx- Theme state management (prepared for future theme switching)
API Integration:
GET /api/auth/me- User profile dataPUT /api/users/{id}- Update user informationGET /api/system/quota- Storage quota informationGET /api/logging/audit- Activity logs
AUDIT_LOGGING.md- Audit system detailsDISK_IO_MONITOR.md- Disk I/O monitorTELEMETRY_CONFIG_RECOMMENDATIONS.md- Telemetry configurationDEV_CHECKLIST.md- Dev-Mode checklist
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push branch (
git push origin feature/AmazingFeature) - Open pull request
[License to be added]
Maintainer: Xveyn Status: ✅ DEPLOYED IN PRODUCTION Version & Änderungsdatum: siehe „Stand" am Anfang dieses Dokuments