Portfolio
⚡ SERVER INFRASTRUCTURE MANAGEMENT

AI Supervisor
Total server control

Painel técnico de monitorização e gestão de infraestrutura de IA — Docker, GPU, Serviços, Rede, Backups, Cameras e Alerts num único dashboard em tempo real, construído com FastAPI + React + WebSockets.

FastAPI React 18 WebSockets Docker SDK NVIDIA GPU JWT Auth Ollama LLM psutil OpenCV QNAP NAS
15
Active modules
3s
WS live interval
30+
API endpoints
8
AI Services
JWT
Auth HS256
🏗️ Architecture Técnica

Asynchronous full-stack

React 18 + Vite frontend communicates with FastAPI (Python) backend via REST and WebSocket. The backend aggregates data from Docker SDK, psutil, nvidia-smi and systemctl in real time.

FRONTEND — React 18 + Vite
├── React Router 6 // 15 rotas
├── Axios // automatic JWT interceptor
├── Recharts // time-series charts
├── Tailwind CSS // dark theme vars
└── WS nativo // live metrics at 3s

BACKEND — FastAPI (Python 3)
├── Uvicorn // ASGI server :9100
├── Docker SDK // Unix socket
├── psutil // CPU/RAM/Disk
├── pynvml // GPU VRAM/temp/util
├── OpenCV + face_rec // câmeras
├── bcrypt + PyJWT // auth HS256 24h
├── smtplib + SMS API // alertas
└── CIFS + rsync // backup QNAP

STORAGE — File-based
├── users.json // bcrypt, lockout, flags
├── secret.key // 48-byte hex random
└── *.json configs // alerts, cameras, VRAM
Login
🔐 Login — JWT + bcrypt + rate limiting
24h
Token expiry
5
Max attempts / 15min
30min
Lockout after 10 failures
📊 Main Dashboard

Real-time view via WebSocket

Upon entering, the dashboard aggregates CPU, RAM, Disk, GPU metrics, AI service status and Docker containers — automatically updated every 3 seconds via WebSocket ws://…/ws/live.

Technical narration: "The AI Supervisor central dashboard presents all critical server indicators in real time: CPU and RAM usage with 60-sample history, NVIDIA GPU status with VRAM/temperature/utilization, and the service health grid aggregating AI Services, Docker Containers, open ports and active alerts. Data arrives via WebSocket broadcast at 3 seconds — no polling."
Dashboard
📊 Dashboard — live metrics, service health, Recharts charts
3s
WebSocket broadcast interval
60
Ring buffer samples (CPU/RAM/GPU)
4
Top KPI cards (CPU/RAM/Disk/GPU)
6
Service health tiles
WebSocket Live Feed
Endpoint WS /ws/live broadcasts to all connected clients every 3 seconds with CPU %, RAM %, GPU util and VRAM.
📈
Ring Buffer Metrics
Backend maintains 60 in-memory samples for CPU, RAM, GPU utilization and VRAM %. Visualized with Recharts line charts.
🩺
Service Health Grid
Grelha 2×3 com status de AI Services, Docker Containers, System Services, GPU, Network Ports e Alerts — com contadores live.
🖥️
Top KPI Cards
CPU (% + cores + freq), RAM (GB used/total + swap), Disk (GB + %), GPU (VRAM + temp + util) — data via psutil + pynvml.
🧠 AI Services

Control of 8 AI services

Centralized management of all AI services running on the server — Ollama, Whisper, Piper TTS, Edge-TTS, XTTS, Emotion Engine, Wakeword and AI Router — with start/stop/restart and real-time logs.

Technical narration: "The AI Services module automatically discovers the 8 configured AI services, checks their status via HTTP healthcheck on each port, and allows start/stop/restart via systemctl or Docker. The administrator sees each service's uptime, the port it's listening on, and can access the last session's logs without leaving the panel."
AI Services
🧠 AI Services — healthcheck + start/stop/logs
Registered AI Services:
├── Ollama :11434 LLM inference
├── Whisper STT :10300 speech-to-text
├── Piper TTS :10200 offline TTS
├── Edge-TTS :10201 Azure neural
├── XTTS :8020 advanced TTS
├── Emotion :5055 sentiment analysis
├── Wakeword :10400 voice activation
└── AI Router :8090 unified API GW
GET /api/services/ai POST /start|stop|restart GET /logs
🐳 Docker Management

Container management via Docker SDK

Lists, controls and monitors all running Docker containers — with access to logs, CPU/memory stats per container, and bulk operation to start all stacks at once.

Technical narration: "The Docker integration uses the Docker SDK for Python via Unix socket for direct communication with the Docker daemon. The panel lists all containers with status, image, exposed ports and the source docker-compose directory. Each container has start/stop/restart actions and log access. The 'Start All Stacks' button executes the ~/start_all_docker_stacks.sh script to bring up the entire infrastructure at once."
Docker
🐳 Docker Containers — status, logs, start/stop/restart, bulk ops
📋
Container List
Full list with status (running/stopped), image, ports, labels and source compose directory via Docker SDK.
📝
Real-Time Logs
Endpoint GET /api/docker/containers/{name}/logs with configurable number of lines via journalctl.
📊
Container Stats
CPU % and memory per container via GET /api/docker/containers/{name}/stats — direct data from the Docker daemon.
🚀
Start All Stacks
Bulk operation that executes the entire infrastructure startup script — useful after server reboot.
🎮 GPU & VRAM Management

NVIDIA GPU monitoring and automatic VRAM management

Complete NVIDIA GPU monitoring via pynvml — utilization, VRAM, temperature, power draw, fan speed and P-State. The VRAM Manager automatically unloads idle AI services to free up memory.

Technical narration: "The GPU module uses the pynvml library for direct reading of NVIDIA counters without relying on nvidia-smi subprocess. The VRAM Manager is an async watchdog running every 30 seconds: it compares each service's last activity timestamp with the configured timeout and, if exceeded, sends a stop to the service. The result is a dynamic VRAM pool that reconfigures itself based on services in use."
GPU Monitor
🎮 GPU Monitor — util/VRAM/temp/power/pstate
VRAM Manager
⚡ VRAM Manager — auto-unload idle AI services
30s
Watchdog check interval
2min
Idle timeout (Emotion/Whisper/XTTS)
5min
Idle timeout (Wakeword)
pynvml
GPU data source
VRAM Manager — per-service configuration:

Emotion Engine idle_timeout=120s auto_stop=true // unloads if idle
Whisper STT idle_timeout=120s auto_stop=true // frees VRAM after use
XTTS idle_timeout=120s auto_stop=true // large model, frees up
Ollama idle_timeout= auto_stop=false // manual control
Wakeword idle_timeout=300s auto_stop=false // disabled by default
🔧 Infrastructure

Disk, network and system services

Disk analysis with automatic cleanup, network interface and open port management, full systemd service control with journalctl and aggregated server log visualization.

Disk Manager
💾 Disk Manager — analysis + cleanup + migration
Network
🌐 Network — interfaces + open ports
System Services
⚙️ System Services — systemctl + journalctl
Metrics
📈 Metrics — time-series CPU/RAM/GPU charts
Logs
📄 Logs — system log aggregation
💾
Disk Manager
Partition analysis, Docker image/volume sizes, dangling image cleanup, large file scanner and volume migration.
🌐
Network & Ports
Lists network interfaces with statistics, open ports with PIDs and service names, and port availability checker.
⚙️
System Services
Systemd service control (start/stop/restart/enable/disable) with real-time logs via journalctl.
📈
Metrics History
60 CPU, RAM and GPU samples in ring buffers visualized as time-series charts with Recharts. Data via GET /api/metrics.
🗄️ Backup & Restore

Automatic backup to QNAP NAS via CIFS

Full backups of services, MariaDB databases, Docker volumes and data folders to QNAP NAS via CIFS/rsync — with selective restore per service or database.

Technical narration: "The Backup module mounts CIFS shares from the QNAP NAS and runs rsync to copy configured service data, runs mysqldump for each MariaDB database, and archives docker-compose YAMLs. Backups are catalogued in JSON with size and date metadata. Restore is selective — you can restore a single database or just one service's data without affecting the rest."
Backup
🗄️ Backup & Restore — QNAP NAS + rsync + mysqldump
Services with backup configured:
nextcloud · vaultwarden · bookstack
n8n · taiga · wordpress
nginx-proxy · mariadb
wireguard · portfolio · mmia

Backup targets:
Manual: /mnt/qnap_backup_manual
Auto: /mnt/qnap_backup_auto

What is included:
Docker compose YAMLs
Data folders (/srv/dev-disk-*/data)
MariaDB dumps (mysqldump)
Docker root configuration
📹 Vigilância & Cameras

IP surveillance with face recognition and motion detection

Video surveillance system supporting RTSP/HTTP cameras, motion detection via OpenCV, facial recognition with face_recognition + dlib, and automatic email notifications.

Narração técnica: "O módulo de câmeras usa OpenCV para capturar frames de streams RTSP ou HTTP. A detecção de movimento compara frames consecutivos por limiar de pixels configurável. O reconhecimento facial usa a biblioteca face_recognition para comparar encodings com a base de dados de rostos conhecidos. Quando deteta um rosto desconhecido ou movimento, dispara notificação por email com snapshot. Cameras Android podem auto-registar-se via API."
Cameras
📹 Camera Surveillance — RTSP/HTTP, motion, face recognition, events
🎥
MJPEG Live Stream
MJPEG proxy via GET /api/cameras/{id}/stream for any RTSP/HTTP camera — no browser plugins needed.
🏃
Motion Detection
OpenCV frame diff with configurable pixel threshold. Records event with timestamp and thumbnail. Notifies by email if active.
👤
Face Recognition
Known faces database with dlib encodings. Distinguishes "known face", "unknown face" and "no face". Separate alert per type.
🤖
AI Activity Analysis
Activity analysis via Ollama vision models — describes what is happening on the camera in natural language.
📱
Android Camera
Android phones register themselves as camera sources via POST /api/android/register.
🔍
Auto-Discovery
Automatic local network scan to discover IP cameras with brand detection and default credential suggestions.
🔔 Sistema de Alerts

Alerts por thresholds com recomendações de IA

Configurable thresholds per metric (CPU, RAM, GPU, VRAM, Disk, Temperature) with two levels (Warning/Critical), SMTP email and SMS Gateway notification, anti-spam cooldown and local LLM analysis.

Settings
🔔 Settings & Alerts — SMTP, SMS, thresholds, AI recs
Configurable thresholds:
cpu_percent warn=75% crit=90%
ram_percent warn=80% crit=95%
gpu_util warn=85% crit=95%
gpu_temp warn=75°C crit=85°C
vram_percent warn=80% crit=90%
disk_percent warn=75% crit=90%

Notification channels:
Email SMTP (HTML formatted)
SMS Gateway API
Ollama AI recommendations

Anti-spam:
configurable cooldown (min) + 200 alert history
🔐 Security & Autenticação

JWT + bcrypt + rate limiting + audit log

Production-ready authentication system with JWT HS256, bcrypt 12 rounds, IP rate limiting, automatic lockout for repeated failures, and complete login audit log.

Technical narration: "Security was designed to withstand brute force attacks: an IP exceeding 5 failed attempts in 15 minutes receives HTTP 429; after 10 consecutive failures the account is locked for 30 minutes. JWT uses a 48-byte randomly generated key on first startup, stored with 0o600 permissions. The audit log stores the last 200 login events with IP, timestamp and result — accessible only to superusers."
🔑
JWT HS256 — 24h
Token generated with 48-byte random key (secret.key, mode 0o600). Expires in 24h. Axios automatically injects into all headers.
🔒
bcrypt 12 rounds
Passwords stored with bcrypt (12 rounds) in users.json with 0o600 permissions. Never stored in plain text.
🛡️
IP Rate Limiting
Maximum 5 failed attempts per IP in a 15-minute window. Exceeded → HTTP 429. Implemented without external middleware.
🔓
Account Lockout
10 consecutive failures lock the account for 30 minutes. State saved in users.json with unlock timestamp.
📋
Audit Log
Last 200 login events in memory (IP, timestamp, result, user-agent). Accessible via GET /api/auth/login-audit — superusers only.
🔄
Force Password Change
must_change_password flag in user JSON. Modal blocks the app until the user sets a new password via POST /api/auth/change-password.
🚀 Launcher & Presentation

Application launching and integrated demo

Quick launch panel for configured applications and scripts, plus an internal presentation page with system information and platform version.

Launcher
🚀 Launcher — quick launch for apps and scripts

Sidebar — 15 Modules

Dashboard · Lançamentos · AI Services
Containers · Disk Manager · Backup
GPU Monitor · Network · System Services
VRAM Manager · Metrics · Logs
Settings · Cameras · Info

Footer: MagWeb · v{version}
React Router 6 PrivateRoute wrapper Collapsible mobile GET /api/version
⚡ AI SUPERVISOR — COMPLETE STACK

Infrastructure de IA
sob controlo total

FastAPI + React + Docker SDK + NVIDIA pynvml + OpenCV + Ollama + QNAP CIFS — a single panel to manage the entire server AI infrastructure in real time.

WebSocket Live
Metrics push at 3s to all connected clients via WS /ws/live.
🧠
8 AI Services
Ollama, Whisper, Piper, Edge-TTS, XTTS, Emotion, Wakeword, AI Router.
🎮
VRAM Manager
Async watchdog unloads idle services — dynamic VRAM pool.
🐳
Docker SDK
Direct communication via Unix socket — no CLI invocation.
🗄️
QNAP Backup
CIFS + rsync + mysqldump to NAS with selective restore per service.
📹
Face Recognition
OpenCV + dlib for motion detection and facial recognition.
🔐
JWT + bcrypt
HS256 24h, 12 rounds, IP rate limiting, 30min lockout.
🔔
Alerts IA
Thresholds + SMTP + SMS + Ollama LLM recommendations.
FastAPI 0.110 React 18.3 TypeScript 5.4 Python 3 psutil 5.9 pynvml 11.5 Docker SDK 7.0 bcrypt + PyJWT OpenCV 4.9 Vite 5.3 Recharts 2.12 Tailwind 3.4 Uvicorn 0.29