VPS Infrastructure (planovi-vps) β Business Logic & Modules
Code-Verified Blueprint: 6 modules β’ 46 documented
BR-*business rules β’ Zero-orphan file coverage.
Switch betweenLatestand frozen release snapshots using the Documentation Version dropdown at the top of the left sidebar.
Module Specifications Index
| # | Module Specification | Rule Prefix | Rules (BR-*) | Open [TEAM_WHY] |
|---|---|---|---|---|
| 1 | Edge Reverse Proxy, SNI Stream Routing, IP Access Control & Error Pages | BR-EDGE | 12 | 3 |
| 2 | Dual-Environment Self-Hosted Supabase Stack (PROD & DEV) | BR-SUPA | 8 | 3 |
| 3 | Application Runtimes: PHP 8.3 FPM, Flutter Web & IoT Converter Backends / MQTT | BR-APP | 5 | 3 |
| 4 | GitHub Webhook Auto-Deployer & Legacy CI Workflow | BR-DEP | 10 | 3 |
| 5 | Host Provisioning, Kernel Tuning, RBAC User Management, Backups & Maintenance | BR-OPS | 8 | 3 |
| 6 | Local Docs-as-Code Scaffold & Repository Hygiene | BR-DOC | 3 | 1 |
- Cross-Cutting Concerns & Shared Infrastructure β
- Open
[TEAM_WHY_NEEDED]Questions & Tech Debt Board β
Repository Snapshot & Runtime Metadata
- Repository:
PA-IDEAS/planovi-vps - Branch & HEAD Commit:
main@b3a7ad3 - Target Production Host: Hostinger VPS running Ubuntu 24.04 LTS (
191.218.165.149, deployment root/opt/vps-stack, application checkouts under/opt/vps-apps)
Primary Stack & Pinned Versions
| Component | Runtime / Base Image | Pinned Version | Source File |
|---|---|---|---|
| Edge Reverse Proxy | nginx:alpine | Rolling Alpine (latest tag) | docker-compose.yml:6 |
| PostgreSQL (PROD & DEV) | supabase/postgres | 15.1.0.147 | docker-compose.yml:39,441 |
| API Gateway (PROD & DEV) | kong | 2.8.1 (DB-less declarative) | docker-compose.yml:63,465 |
| Supabase Studio (PROD & DEV) | supabase/studio | 2026.07.20-sha-74a0848 | docker-compose.yml:81,483 |
| Edge Functions Runtime (PROD & DEV) | supabase/edge-runtime | v1.54.3 | docker-compose.yml:116,518 |
| Postgres Meta (PROD & DEV) | supabase/postgres-meta | v0.68.0 | docker-compose.yml:157,562 |
| Auth / GoTrue (PROD & DEV) | supabase/gotrue | v2.132.3 | docker-compose.yml:181,586 |
| Storage API (PROD & DEV) | supabase/storage-api | v1.11.0 | docker-compose.yml:229,634 |
| PostgREST (PROD & DEV) | postgrest/postgrest | v11.2.0 | docker-compose.yml:257,662 |
| PHP Microservices & Webpage Runtime | php:8.3-fpm-alpine + Alpine nginx | PHP 8.3 FPM (pdo_pgsql, gd, zip, opcache, intl) | php-app/Dockerfile:1,13 |
| Flutter Web Static Container (orphaned) | nginx:alpine | Rolling Alpine | docker-compose.yml:296 |
| Webhook Auto-Deployer | python:3.11-alpine + docker-cli, docker-cli-compose, docker-cli-buildx, git, rsync, openssh-client | Python 3.11 | deployer/Dockerfile:1,5 |
| Converter FastAPI Backends (PROD & DEV) | python:3.13-slim (uvicorn cloud.app:app) | Python 3.13 | docker-compose.yml:341,399 |
| MQTT Broker (DEV only) | eclipse-mosquitto | 2 | docker-compose.yml:370 |
| Local Docs Scaffold | astro / @astrojs/starlight / sharp / typescript | astro ^4.16.1, starlight ^0.28.2, sharp ^0.33.5, typescript ^5.5.4 | docs/package.json:14-19 |
What This Repo Owns (and What It Explicitly Does NOT Own)
- Owns: All Docker Compose orchestration for the Hostinger VPS (
docker-compose.yml), including the dual PROD/DEV self-hosted Supabase stacks, PHP 8.3 FPM container, IoT Converter FastAPI + Mosquitto runtime definitions, and the Nginx L4/L7 edge proxy (proxy/). - Owns: The GitHub push webhook auto-deployment engine (
deployer/deployer.py), including FVM-driven on-demand Flutter builder image creation, browser-safe.public.envinjection, Edge Functionrsyncsync, ARM firmware build invocation, and automaticgit reset --hardrollback with Google Chat alerting. - Owns: Host-level operational automation: Ubuntu 24.04 initial provisioning (
setup-vps.sh), Linux kernel TCP BBR/socket tuning (sysctl-tuning.conf), IP whitelist updates (scripts/update-allowed-ip.sh), PostgreSQL backup/health/prune cron scripts (scripts/backup*.sh,check-health.sh,docker-prune.sh), and SSH/sudo user provisioning (scripts/planovi-adduser.sh,scripts/planovi-dev-docker.sh). - Does NOT Own: Application business logic, database SQL migrations, Supabase Edge Function TypeScript code, Flutter UI code, PHP microservice source code, or RP2350 C firmware/FastAPI application code β those live in sibling repositories (
planovi-flutter-app,planovi-backend,planovi-microservices,planovi-webpage,planovi-converter) and are pulled into/opt/vps-apps/*at deploy time. - Does NOT Own: Live production secrets, Cloudflare Origin TLS private keys, Device CA private keys, or the canonical ecosystem documentation portal (
PA-IDEAS/planovi-docsis the central documentation hub deployed to Cloudflare Pagesdev-docs-arq.pages.dev;docs/in this repo is a local Starlight copy).
Directory Map
planovi-vps/βββ .github/workflows/ # Legacy GitHub Actions workflow (deploy.yml β references non-existent fastapi-app)βββ deployer/ # Webhook auto-deployer HTTP server (Dockerfile, deployer.py)βββ docs/ # Local Astro Starlight docs scaffold (package.json, astro.config.mjs, 14 md/mdx pages)βββ php-app/ # Unified PHP 8.3-FPM + internal Nginx image serving webpage & PHP microservicesβββ proxy/ # Edge vps-proxy Nginx config, stream SNI router, Kong declarative configβ βββ conf.d/ # Per-domain vhosts (apps, converters, dev-api, docs, internal-email-templates, supabase)β βββ html/ # Branded PL/EN static fallback pages (404.html, 50x.html, default.html)βββ scripts/ # Host maintenance, backup, monitoring, IP whitelist, storage migration, SSH RBAC scriptsβββ docker-compose.yml # Master 22-service Docker Compose stack (PROD + DEV)βββ setup-vps.sh # Initial Ubuntu 24.04 VPS provisioning scriptβββ sysctl-tuning.conf # Linux kernel TCP BBR, socket backlog, and VM swap tuningβββ .env.example # Environment variable template (contains live-looking placeholder values β see Section 5)βββ supabase_cloud_dump.sql # 0-byte legacy placeholder tracked in Gitβββ .gitignore / README.mdLocal Development & Testing Commands
No automated unit test suite or linter configuration exists in this repository. Verified operational and validation commands:
- Validate Docker Compose syntax (requires
.envpresent):Terminal window cp .env.example .env # Replace all placeholders with environment-specific valuesdocker compose config --quiet - Validate Nginx config inside running
vps-proxy:Terminal window docker exec vps-proxy nginx -t - Validate Python syntax of
deployer/deployer.pyandscripts/migrate-storage-files.py:Terminal window python3 -m py_compile deployer/deployer.py scripts/migrate-storage-files.py - Validate shell script syntax:
Terminal window bash -n setup-vps.sh scripts/*.sh - Start / rebuild stack on VPS (
/opt/vps-stack):Terminal window docker compose up -d --build - Run local Docs-as-Code preview (
docs/):Terminal window cd docs && npm ci && npm run devnpm run build
Environment Variables & Config Keys (KEY NAMES ONLY)
| Key Name | Where Read (file) | Required? | Purpose |
|---|---|---|---|
POSTGRES_PASSWORD | docker-compose.yml, scripts/backup.sh, scripts/backup_databases.sh | Yes | Shared PostgreSQL password for both PROD (supabase-db) and DEV (supabase-db-dev) DBs, PostgREST, GoTrue, Storage, pg-meta, Edge Runtime, Converter FastAPI |
JWT_SECRET | docker-compose.yml | Yes | Shared HS256 JWT signing secret for PROD & DEV GoTrue, PostgREST, Storage, and Edge Runtime |
SUPABASE_ANON_KEY | docker-compose.yml | Yes | Public anon role JWT injected into PROD & DEV Studio, Storage, Edge Runtime |
SUPABASE_SERVICE_ROLE_KEY | docker-compose.yml | Yes | Privileged service_role JWT injected into PROD & DEV Studio, Storage, Edge Runtime (also mapped to ENERGY_SUPABASE_SERVICE_ROLE_KEY) |
SITE_URL | docker-compose.yml:194 | Yes | Base redirect URL for PROD GoTrue (GOTRUE_SITE_URL) |
SITE_URL_DEV | docker-compose.yml:599 | No (default https://dev-panel.planovi.app) | Base redirect URL for DEV GoTrue (GOTRUE_SITE_URL) |
API_EXTERNAL_URL | docker-compose.yml:196-197 | Yes | External Auth URL for PROD GoTrue (https://api.planovi.app/auth/v1) |
GOOGLE_CLIENT_ID | docker-compose.yml:149,222,554,627 | Yes | PROD Google OAuth Client ID (also fallback for DEV) |
GOOGLE_CLIENT_SECRET | docker-compose.yml:150,223,555,628 | Yes | PROD Google OAuth Client Secret (also fallback for DEV) |
GOOGLE_CLIENT_ID_DEV | docker-compose.yml:554,627 | No (falls back to GOOGLE_CLIENT_ID) | Separate DEV Google OAuth Client ID for supabase-auth-dev & supabase-edge-runtime-dev |
GOOGLE_CLIENT_SECRET_DEV | docker-compose.yml:555,628 | No (falls back to GOOGLE_CLIENT_SECRET) | Separate DEV Google OAuth Client Secret |
RESEND_API_KEY | docker-compose.yml:139,205,541,610 | Yes | SMTP password (smtp.resend.com:587) for GoTrue and API key for Resend transactional emails in Edge Functions |
SMTP_ADMIN_EMAIL | docker-compose.yml:206,611 | Yes | Sender address for GoTrue auth emails |
FROM_EMAIL | docker-compose.yml:140,542 | Yes (missing from .env.example) | Sender address for Edge Function emails |
UNSUBSCRIBE_BASE_URL | docker-compose.yml:143,545 | Yes (missing from .env.example) | Base URL for email unsubscribe links in Edge Functions |
PORTAL_URL | docker-compose.yml:144,546 | Yes (missing from .env.example) | Portal base URL used by Edge Functions |
GEMINI_API_KEY | docker-compose.yml:131,533 | Yes | Google Gemini API key for AI Edge Functions (jarvis, ai-energy-balancer, OCR) |
DEALFLOW_BASE_URL | docker-compose.yml:132,534 | Yes | Base API URL for PHP Dealflow microservice (shared by PROD & DEV compose blocks) |
DEALFLOW_API_SECRET | docker-compose.yml:133,535 | Yes | Shared secret for PROD form-writer.php / Dealflow API (fallback for DEV) |
DEALFLOW_API_SECRET_DEV | docker-compose.yml:535 | No (falls back to DEALFLOW_API_SECRET) | Separate DEV secret matching /opt/vps-apps/microservices/dev/.env |
SCHEDULER_BASE_URL | docker-compose.yml:134,536 | Yes | Base API URL for PHP Scheduler microservice |
SCHEDULER_API_SECRET | docker-compose.yml:135,537 | Yes | Shared secret for PROD Scheduler API (fallback for DEV) |
SCHEDULER_API_SECRET_DEV | docker-compose.yml:537 | No (falls back to SCHEDULER_API_SECRET) | Separate DEV secret matching /opt/vps-apps/microservices/dev/.env |
INCHARGE_API_TOKEN | docker-compose.yml:136,538 | Yes | External API token for InCharge integration |
STRIPE_SECRET_KEY | docker-compose.yml:146,548 | Yes (missing from .env.example) | Stripe API secret key for billing Edge Functions |
STRIPE_WEBHOOK_SECRET | docker-compose.yml:147,549 | Yes (missing from .env.example) | Stripe webhook signing secret for subscription events |
STRIPE_INQUIRY_WEBHOOK_SECRET | docker-compose.yml:148,550 | Yes (missing from .env.example) | Stripe webhook signing secret for inquiry checkout events |
SIGNING_SECRET_DEV | docker-compose.yml:553 | Yes for DEV (missing from .env.example and PROD) | Signing secret passed as SIGNING_SECRET to supabase-edge-runtime-dev |
WEBHOOK_SECRET | docker-compose.yml:324, deployer/deployer.py:18 | Yes (fatal if empty) | GitHub HMAC-SHA256 webhook verification secret |
DEPLOYER_PORT | deployer/deployer.py:16 | No (default 9000) | HTTP listen port inside vps-deployer |
GOOGLE_CHAT_WEBHOOK_URL | docker-compose.yml:325, deployer/deployer.py:19, scripts/backup.sh:22, scripts/check-health.sh:17, scripts/docker-prune.sh:10 | Optional in deployer; hardcoded fallback in backup.sh/check-health.sh | Google Chat space webhook for deploy, backup, health, and prune alerts |
ASLANDI_EDGE_SHARED_TOKEN | docker-compose.yml:417 | No (hardcoded fallback in compose) | Shared token for converters-api-dev edge integration |
ASLANDI_CARD_MASTER_KEY_B64 | docker-compose.yml:418 | Yes for converters-api-dev (missing from .env.example) | Base64 master encryption key for SD card crypto in converters-api-dev |
GITHUB_TOKEN, VPS_HOST, VPS_SSH_PRIVATE_KEY | .github/workflows/deploy.yml:24,50,52,55 | Yes (GitHub Actions Secrets) | Used by legacy CI workflow to push to GHCR and SSH into VPS |
Complete File Coverage Matrix (Zero-Orphan Inventory)
Every tracked file in git ls-files (54 files total) and every service in docker-compose.yml (22 services total) is mapped below with zero orphans.
| # | Module Name | Rule Prefix | Assigned Tracked Files & Services (100% Coverage) |
|---|---|---|---|
| 2.1 | Edge Reverse Proxy, SNI Stream Routing, IP Access Control & Error Pages | BR-EDGE-* | proxy/nginx.conf, proxy/allowed_ips.conf, proxy/conf.d/apps.conf, proxy/conf.d/converters.conf, proxy/conf.d/dev-api.conf, proxy/conf.d/docs.conf, proxy/conf.d/internal-email-templates.conf, proxy/conf.d/supabase.conf, proxy/html/404.html, proxy/html/50x.html, proxy/html/default.html, scripts/update-allowed-ip.sh, docker-compose.yml (proxy service) |
| 2.2 | Dual-Environment Self-Hosted Supabase Stack (PROD & DEV) | BR-SUPA-* | docker-compose.yml (supabase-db, supabase-kong, supabase-studio, supabase-edge-runtime, supabase-pg-meta, supabase-auth, supabase-storage, supabase-postgrest, supabase-db-dev, supabase-kong-dev, supabase-studio-dev, supabase-edge-runtime-dev, supabase-pg-meta-dev, supabase-auth-dev, supabase-storage-dev, supabase-postgrest-dev, networks, volumes), proxy/kong.yml, .env.example, scripts/migrate-storage-files.py, supabase_cloud_dump.sql |
| 2.3 | Application Runtimes (PHP 8.3 FPM, Flutter Web & IoT Converter Backends / MQTT) | BR-APP-* | php-app/Dockerfile, php-app/nginx-php.conf, docker-compose.yml (php-app, flutter-web, converters-api-prod, converters-api-dev, mosquitto-dev) |
| 2.4 | GitHub Webhook Auto-Deployer & Legacy CI Workflow | BR-DEP-* | deployer/Dockerfile, deployer/deployer.py, docker-compose.yml (vps-deployer), .github/workflows/deploy.yml |
| 2.5 | Host Provisioning, Kernel Tuning, RBAC User Management, Backups & Maintenance | BR-OPS-* | setup-vps.sh, sysctl-tuning.conf, scripts/planovi-adduser.sh, scripts/planovi-dev-docker.sh, scripts/backup.sh, scripts/backup_databases.sh, scripts/check-health.sh, scripts/docker-prune.sh |
| 2.6 | Local Docs-as-Code Scaffold & Repository Hygiene | BR-DOC-* | .gitignore, README.md, docs/astro.config.mjs, docs/package.json, docs/package-lock.json, docs/tsconfig.json, docs/public/favicon.svg, docs/src/env.d.ts, docs/src/content/config.ts, docs/src/components/SiteTitle.astro, docs/src/content/docs/index.mdx, docs/src/content/docs/architecture/overview.md, docs/src/content/docs/architecture/security-and-ssl.md, docs/src/content/docs/architecture/storage-and-volumes.md, docs/src/content/docs/developer-guide/configuration-and-secrets.md, docs/src/content/docs/developer-guide/deployment-workflows.md, docs/src/content/docs/developer-guide/provisioning.md, docs/src/content/docs/operations/backups-and-recovery.md, docs/src/content/docs/operations/monitoring-and-health.md, docs/src/content/docs/services/application-runtimes.md, docs/src/content/docs/services/deployer-service.md, docs/src/content/docs/services/nginx-and-vhosts.md, docs/src/content/docs/services/supabase-stack.md, docs/src/content/docs/support/troubleshooting.md |