This Functional Specification Document (FSD) defines the requirements, architecture, and implementation plan for PiVault — a secure Network Attached Storage (NAS) system built on a Raspberry Pi 3B+. PiVault consolidates personal media, IoT sensor data, and security camera feeds into a single, self-hosted platform accessible through a custom web dashboard.
The system serves as a personal home server providing encrypted storage, real-time weather monitoring from an ESP32 station, security camera management with playback, and a searchable media library for movies, music, and documents.
1.1 Project Goals
Goal
Description
Priority
Secure NAS Storage
Encrypted file storage with access controls and backup capability
P0 — Critical
Custom Web Dashboard
Responsive, mobile-first UI for managing all system functions
P0 — Critical
ESP32 Weather Integration
Ingest, store, and visualize weather station data with trend analysis
P1 — High
Security Camera System
Live view, recording, and searchable playback of camera feeds
P1 — High
Media Library
Searchable catalog of movies, music, and documents with streaming
P2 — Medium
Remote Access
Secure external access via VPN or reverse proxy with TLS
P1 — High
2. System Overview & Architecture
PiVault is designed as a modular, containerized system running on Raspberry Pi OS Lite (64-bit). Each major service runs in its own Docker container, enabling independent updates, resource isolation, and simplified deployment.
Health check endpoints for all services (/api/health)
Watchdog timer: systemd monitors and restarts unresponsive containers
4.3 Storage & Data Retention
Data Type
Retention Period
Storage Estimate
NAS user files
Indefinite (user-managed)
Dependent on HDD size
Weather sensor data
1 year at full resolution, then downsampled to hourly
~500 MB/year at 30s intervals
Camera recordings (continuous)
14 days (configurable)
~50 GB/camera/week at 1080p
Camera motion events
90 days
~5 GB/camera/month
Media library metadata
Indefinite
< 100 MB for 10,000 items
System logs
30 days, rotated via logrotate
< 500 MB
4.4 Security Requirements
All web traffic encrypted via TLS 1.3 (HTTPS only, HTTP redirects to HTTPS)
No default passwords; initial setup wizard forces password creation
API endpoints authenticated via JWT; ESP32 endpoints via API key
Regular security updates via unattended-upgrades (Debian/Raspbian)
Docker images pinned to specific versions (no :latest tags in production)
SSH access: key-based only, password auth disabled, non-standard port
4.5 UI Design Language — Neumorphism
The dashboard shall use a neumorphic (soft UI) design language, characterized by soft shadows, subtle depth, and extruded/inset elements on a uniform background. This applies to all cards, buttons, inputs, and navigation components.
Color palette based on muted, uniform backgrounds with shadow-driven depth (no hard borders)
P0
UI-012
Interactive elements (buttons, toggles, inputs) shall use inset/pressed states consistent with neumorphic style
P1
4.6 RPi 3B+ Resource Constraints
The Raspberry Pi 3B+ has significant hardware limitations that shape architectural decisions throughout this project. All features must be designed within these constraints.
Development is organized into four phases, each building on the previous. Each phase ends with a functional milestone that can be tested independently.
Phase
Milestone
Key Deliverables
Est. Duration
Phase 1: Foundation
Secure bootable NAS
RPi OS setup, LUKS encryption, Samba shares, Docker infrastructure, Nginx + TLS, user auth system
2–3 weeks
Phase 2: Dashboard + Weather
Web UI with live weather
React dashboard shell, system health panel, ESP32 API endpoint, InfluxDB setup, weather gauges + trend charts
Concurrent user load, file transfer speeds, API latency
k6 load testing, iperf3
Security Tests
Auth bypass, injection, TLS config, open ports
OWASP ZAP, nmap, manual review
Hardware Stress
CPU/RAM under load, thermal throttling, SD card I/O
stress-ng, iotop, vcgencmd
9. Risks & Mitigations
Risk
Severity
Likelihood
Mitigation
RPi 3B+ underpowered for concurrent camera streams + transcoding
High
High
Limit to 2 cameras at 720p for continuous recording; use sub-streams; defer transcoding
SD card corruption from excessive writes
High
Medium
Move all databases, logs, and Docker volumes to USB HDD; use tmpfs for /tmp
USB HDD failure / data loss
Critical
Low
Weekly encrypted backups to second drive; SMART monitoring with alerts
Power loss during write operations
High
Medium
UPS with GPIO shutdown signal; ext4 journaling; WAL mode for SQLite
ESP32 WiFi connectivity drops
Medium
Medium
Local data buffer on ESP32 (SPIFFS); retry logic; offline indicator on dashboard
Security breach via exposed port
Critical
Low
VPN-only remote access; no port forwarding; regular security audits
InfluxDB memory usage exceeds available RAM
High
Medium
Configure InfluxDB memory limits in Docker; aggressive downsampling policies
10. Future Enhancements (Post-MVP)
The following features are out of scope for the initial release but are documented for future consideration:
Upgrade path to Raspberry Pi 5 (4GB/8GB RAM, USB 3.0, PCIe NVMe)
RAID-1 mirror with second USB drive for redundancy
Home Assistant integration for ESP32 data and camera feeds
AI-powered object detection on camera feeds (TensorFlow Lite)
Plex or Jellyfin integration for richer media streaming experience
Mobile push notifications via ntfy.sh or Pushover
Automated SSL certificate renewal via Certbot + Let’s Encrypt
Multi-site support: sync data between two PiVault instances
Voice control integration (Home Assistant + Alexa/Google)
Drag-and-drop upload/browse panel in PiVault web app (complements Samba shares, useful for mobile/remote access without mapping a network drive; writes into /mnt/nas/nas/shared)
Support for additional USB drives beyond the primary LUKS-encrypted HDD (e.g. old spare disks for backup target or extra shared storage). Requires generalizing setup-luks.sh (currently hardcoded to MAPPER_NAME=pivault-hdd, MOUNT_POINT=/mnt/nas) to accept mapper name/mount point as parameters, plus its own crypttab/fstab entries. Use a powered USB hub for spinning disks — Pi USB power isn’t reliable for that.
11. Glossary
Term
Definition
RTSP
Real Time Streaming Protocol — standard for streaming video from IP cameras
HLS
HTTP Live Streaming — adaptive bitrate streaming protocol for web delivery
LUKS
Linux Unified Key Setup — disk encryption standard for Linux
JWT
JSON Web Token — compact token format for stateless authentication
InfluxDB
Open-source time-series database optimized for IoT sensor data
MQTT
Message Queuing Telemetry Transport — lightweight IoT messaging protocol
SMB/Samba
Server Message Block — network file sharing protocol (Windows-compatible)
FFmpeg
Multimedia framework for recording, converting, and streaming audio/video
TOTP
Time-based One-Time Password — algorithm for two-factor authentication
PWA
Progressive Web App — web app installable on devices with offline support
WireGuard
Modern, lightweight VPN protocol for secure remote network access