Administracio de sistemes

SaaS Portal & WP Connector

SaaS platform to centrally manage WordPress sites with security, backups, SEO, tickets, and billing.

Context

Managing WordPress maintenance for multiple clients required connecting to each site individually to run updates, perform backups, verify security, and handle tickets. Without a unified tool, the process was slow, fragmented, and difficult to scale.

What it does

  • Security audit with 0-100 score, 10 categories and automatic hardening
  • Scheduled backups with 4 types (full, db, files, no-media), retention, restoration and cloud storage via SSH+rsync
  • Advanced SEO with Lighthouse audit (Node.js worker) and broken link detection
  • Ticket system with Kanban, priorities and bidirectional Portal-Plugin WordPress sync
  • Billing with automatic calculations, PDF generation and status tracking
  • Autonomous AI Agent (nanobot) with maintenance actions, human approval via Telegram
  • Audit-service to capture leads without needing to install the plugin
  • Content AI for post generation, alt-text and internal links

Architecture

Microservices system on Docker Compose with 8 containers: FastAPI backend (20+ routers, 17 DB models, 5 background workers), PostgreSQL 15, nanobot, Lighthouse worker (Node.js), broken-links worker (Python), audit-service. The WordPress plugin connects each client site through 43 REST endpoints authenticated with RSA SHA256 signature.

Main difficulties

  • 502 error in production caused by an await outside an async function in FastAPI
  • 14 security vulnerabilities found during the audit: SQL injection (CVSS 9.8), path traversal (CVSS 9.8), IDOR, SSRF, CSRF, insecure cookies, running as root in Docker
  • Event loop timeouts when WordPress servers (ISP/Cloudflare) did not respond
  • SQLite to PostgreSQL migration without downtime, using custom migration scripts
  • Cryptographic PHP-Python communication with RSA signature for site tokens

Solutions

  • CSRF middleware based on cookies, SSRF protection (blocking private IPs and cloud metadata endpoints), rate limiting with slowapi
  • SQLAlchemy parameterized queries, filename sanitization, authorization verification on all endpoints
  • asyncio.to_thread + 20s timeout to avoid blocking the event loop
  • Per-script migration system for controlled DB schema evolution
  • RSA token system with cross-signing and verification between PHP and Python
  • Dockerfile with a non-root user, HTTP-only cookies with a configurable secure flag
  • LiteLLM proxy to decouple the AI provider from business logic

Learnings

  • In FastAPI, never mix await calls inside sync functions: tracking down a 502 error trace is extremely difficult
  • Security must be designed from day one: SQL injection, SSRF and path traversal are preventable with the right patterns
  • Background workers require idempotency and solid error handling to avoid cascading failures
  • An AI agent running in production demands a robust approval system for high-risk actions
  • SQLite is excellent for development, but PostgreSQL is a must-have in production