How frappe/press works
Project Type & Purpose
• Press is a full-stack, multi-tenant cloud hosting platform for the Frappe Framework. It combines a Vue-based dashboard (the “frontend”), a Python/Frappe REST API backend, CLI agents for server communication, and Ansible/Docker/Packer-based infrastructure orchestration.
High-Level Architecture Components
A. User & Admin Interfaces
• Dashboard SPA (dashboard/): a Vue 3 single-page app served as static assets.
• Public Website & Docs (press/www/): Flask or Frappe-based webpages.
B. Core Backend
• Press App (press/ + press/saas/): a Frappe Framework application exposing REST API endpoints under /api.
• Authentication, Billing, Marketplace, Multi-tenant logic implemented as Frappe Doctypes & Python controllers.
C. Agents & CLI
• backbone CLI tool (backbone/): a Python CLI to bootstrap servers, run commands against remote “agent” services.
• press agent (press/agent.py): a Flask microservice deployed on each managed server to receive instructions.
D. Infrastructure Orchestration
• Ansible playbooks & roles (press/playbooks/): automate provisioning, configuration, backups, failover, etc.
• Packer templates & scripts (backbone/packer/): build base VM/container images.
• Docker Compose & Dockerfiles (press/docker/): containerize the backend and agent services.
E. Data Stores & Messaging
• MariaDB (Frappe’s primary RDBMS)
• Redis (caching, job queue)
• RQ (Redis-Queue) or Celery for background tasks
F. Supporting Libraries
• filewarmer and mariadb_binlog_indexer (libs/): standalone tools for warm-up and binlog processing.
Component Interactions & Data Flows
• 1. User opens Dashboard SPA →
• 2. SPA issues HTTP/HTTPS REST calls to Press Backend API →
• 3. Backend authenticates (JWT/cookie), reads/writes MariaDB, points to Redis for caching/queues →
• 4. For long-running operations (e.g., deploy, backup), backend enqueues jobs in Redis →
• 5. Worker processes (RQ/Celery) pick up jobs, invoke Ansible playbooks via Ansible Controller →
• 6. Ansible connects over SSH (via jump/proxy servers) to managed nodes →
• 7. On each node, the Press Agent receives dispatch commands (HTTP or socket) to perform local tasks (e.g., Docker container restarts, database backups) →
• 8. Agent reports status back to Backend (via its API).
Architectural Patterns & Principles
• Layered Architecture: clear separation among Presentation (Vue SPA + public website), Application (Press/Frappe REST API), Infrastructure (Ansible + Agent), Data (RDBMS + Redis).
• Event-Driven/Queue-Based: use Redis/RQ or Celery for background job orchestration.
• Microservices & Agents: core backend and per-node agent communicate over HTTP, isolating responsibilities.
• Infrastructure as Code: Ansible roles/playbooks and Packer templates manage reproducible environments.
• Annotations for frameworks (Vue, Frappe, Flask, Ansible, Docker)