ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
refactor(app): register core blueprints from one manifest
Juan Denis654acc4f32db
diff --git a/backend/app/__init__.py b/backend/app/__init__.pyindex 254cee33..833556bb 100644--- a/backend/app/__init__.py+++ b/backend/app/__init__.py@@ -210,464 +210,16 @@ def create_app(config_name=None):from app.agent_gateway import init_agent_gatewayinit_agent_gateway(socketio)- # Register blueprints - Auth- from app.api.auth import auth_bp- app.register_blueprint(auth_bp, url_prefix='/api/v1/auth')-- # Agent polling fallback transport (REST equivalent of the WS gateway,- # used when tunnels mangle WebSocket frames).- from app.api.agent_poll import agent_poll_bp- app.register_blueprint(agent_poll_bp, url_prefix='/api/v1/agent')-- # ServerKit-to-ServerKit peering: this panel linked to a master panel- # (embedded agent mode — no standalone Go agent required).- from app.api.linked_panel import linked_panel_bp- app.register_blueprint(linked_panel_bp, url_prefix='/api/v1/linked-panel')-- # Register blueprints - Core- from app.api.apps import apps_bp- from app.api.domains import domains_bp- from app.api.private_urls import private_urls_bp- app.register_blueprint(apps_bp, url_prefix='/api/v1/apps')- # "Services" is the user-facing term for Applications (§1 unification).- # Mount the same blueprint under /api/v1/services as a true alias so the- # canonical `apps` routes and any `services` callers resolve identically.- app.register_blueprint(apps_bp, url_prefix='/api/v1/services', name='services')- app.register_blueprint(domains_bp, url_prefix='/api/v1/domains')- app.register_blueprint(private_urls_bp, url_prefix='/api/v1/apps')- # Per-app managed volumes — same dual mount as apps (/apps + /services alias).- from app.api.app_volumes import app_volumes_bp- app.register_blueprint(app_volumes_bp, url_prefix='/api/v1/apps')- app.register_blueprint(app_volumes_bp, url_prefix='/api/v1/services', name='app_volumes_services')-- # Register blueprints - System- from app.api.system import system_bp- from app.api.processes import processes_bp- from app.api.logs import logs_bp- app.register_blueprint(system_bp, url_prefix='/api/v1/system')- app.register_blueprint(processes_bp, url_prefix='/api/v1/processes')- app.register_blueprint(logs_bp, url_prefix='/api/v1/logs')-- # Register blueprints - Infrastructure- from app.api.nginx import nginx_bp- from app.api.ssl import ssl_bp- app.register_blueprint(nginx_bp, url_prefix='/api/v1/nginx')- app.register_blueprint(ssl_bp, url_prefix='/api/v1/ssl')-- # Register blueprints - PHP- from app.api.php import php_bp- app.register_blueprint(php_bp, url_prefix='/api/v1/php')- # WordPress is the standalone `serverkit-wordpress` extension (plan 52- # Phase 5 — it left the tree into its own repo and installs from the- # registry; the setup wizard offers it from the bundled index entry).- # Its blueprints (wordpress / wordpress_sites / environment_pipeline,- # keeping the /api/v1/wordpress[/projects|/pipelines] prefixes per D3,- # incl. the /pipelines alias) are registered from the extension by the- # plugin loader when installed. The old `wordpress` module toggle is- # retired; the plugin status guard is the gate.-- # Register blueprints - Python- from app.api.python import python_bp- app.register_blueprint(python_bp, url_prefix='/api/v1/python')-- # Register blueprints - Docker- from app.api.docker import docker_bp- app.register_blueprint(docker_bp, url_prefix='/api/v1/docker')-- # Register blueprints - Databases- from app.api.databases import databases_bp- app.register_blueprint(databases_bp, url_prefix='/api/v1/databases')-- # Register blueprints - Database engine catalog (composed from templates)- from app.api.database_engines import database_engines_bp- app.register_blueprint(database_engines_bp, url_prefix='/api/v1/databases/engines')-- # Register blueprints - Managed DB users + Adminer SSO- from app.api.managed_db_users import managed_db_users_bp- app.register_blueprint(managed_db_users_bp, url_prefix='/api/v1/managed-databases')-- # Register blueprints - Curated DB config tuner- from app.api.db_tuner import db_tuner_bp- app.register_blueprint(db_tuner_bp, url_prefix='/api/v1/db-tuner')-- # Register blueprints - Monitoring & Alerts- from app.api.monitoring import monitoring_bp- app.register_blueprint(monitoring_bp, url_prefix='/api/v1/monitoring')-- # Register blueprints - Container status aggregator- from app.api.container_status import container_status_bp- app.register_blueprint(container_status_bp, url_prefix='/api/v1/status')-- # Register blueprints - Build packs (zero-Dockerfile detection)- from app.api.buildpacks import buildpacks_bp- app.register_blueprint(buildpacks_bp, url_prefix='/api/v1/buildpacks')-- # Register blueprints - Deployment config snapshots + diff- from app.api.snapshots import snapshots_bp- app.register_blueprint(snapshots_bp, url_prefix='/api/v1/apps')-- # Register blueprints - Declarative serverkit.yaml manifest- from app.api.manifests import manifests_bp- app.register_blueprint(manifests_bp, url_prefix='/api/v1/manifests')-- # Register blueprints - Projects & Environments hierarchy- from app.api.projects import projects_bp- app.register_blueprint(projects_bp, url_prefix='/api/v1/projects')- from app.api.environments import environments_bp- app.register_blueprint(environments_bp, url_prefix='/api/v1/environments')-- # Register blueprints - Polymorphic shared resources (tags + variable groups)- from app.api.shared_resources import shared_resources_bp- app.register_blueprint(shared_resources_bp, url_prefix='/api/v1/shared')-- # Register blueprints - PR preview environments- from app.api.previews import previews_bp- app.register_blueprint(previews_bp, url_prefix='/api/v1/apps')- from app.api.webhooks import webhooks_bp- app.register_blueprint(webhooks_bp, url_prefix='/api/v1/webhooks')-- # Register blueprints - Per-server managed proxy stack- from app.api.proxy import proxy_bp- app.register_blueprint(proxy_bp, url_prefix='/api/v1/servers')-- # Register blueprints - Notifications- from app.api.notifications import notifications_bp- app.register_blueprint(notifications_bp, url_prefix='/api/v1/notifications')-- # Register blueprints - Backups- from app.api.backups import backups_bp- app.register_blueprint(backups_bp, url_prefix='/api/v1/backups')-- # Register blueprints - Git Deployment- from app.api.deploy import deploy_bp- app.register_blueprint(deploy_bp, url_prefix='/api/v1/deploy')-- # Register blueprints - Builds & Deployments- from app.api.builds import builds_bp- from app.api.deployment_jobs import deployment_jobs_bp- from app.api.deployments import deployments_bp- app.register_blueprint(builds_bp, url_prefix='/api/v1/builds')- app.register_blueprint(deployment_jobs_bp, url_prefix='/api/v1/deployment-jobs')- # §3 unification: one /api/v1/deployments surface. Federated history/detail- # live in deployments_bp; the canonical execution records (DeploymentJob)- # are also mounted here under /deployments/jobs (alias of /deployment-jobs).- app.register_blueprint(deployments_bp, url_prefix='/api/v1/deployments')- app.register_blueprint(deployment_jobs_bp, url_prefix='/api/v1/deployments/jobs',- name='deployment_jobs_unified')-- # Register blueprints - Templates- from app.api.templates import templates_bp- app.register_blueprint(templates_bp, url_prefix='/api/v1/templates')-- # Register blueprints - File Manager- from app.api.files import files_bp- app.register_blueprint(files_bp, url_prefix='/api/v1/files')-- # FTP Server is an opt-in builtin extension (serverkit-ftp, plan 47) — its- # blueprint loads from builtin-extensions/serverkit-ftp/ when installed, not- # from core. A fresh panel that never touches FTP loads none of it.-- # Register blueprints - Firewall- from app.api.firewall import firewall_bp- app.register_blueprint(firewall_bp, url_prefix='/api/v1/firewall')-- # Register blueprints - Git Server- from app.api.git import git_bp- app.register_blueprint(git_bp, url_prefix='/api/v1/git')-- # Register blueprints - Security (ClamAV, File Integrity, etc.)- from app.api.security import security_bp- app.register_blueprint(security_bp, url_prefix='/api/v1/security')-- # Register blueprints - Secrets manager + inbound webhook gateway- from app.api.secrets_webhooks import bp as secrets_webhooks_bp- app.register_blueprint(secrets_webhooks_bp, url_prefix='/api/v1')-- # Register blueprints - Cron Jobs- from app.api.cron import cron_bp- app.register_blueprint(cron_bp, url_prefix='/api/v1/cron')-- # Email Server is now the serverkit-email builtin extension (Phase 4, #32):- # its /api/v1/email blueprint + Postfix/Dovecot/DKIM/SpamAssassin/Roundcube- # services live in builtin-extensions/serverkit-email/ and are registered by- # the plugin loader when installed. The outbound relay (email_relay_service)- # and all email models stay core (notifications SMTP + shared Postfix relay).-- # Register blueprints - Uptime Tracking- from app.api.uptime import uptime_bp- app.register_blueprint(uptime_bp, url_prefix='/api/v1/uptime')-- # Register blueprints - Monitors (synthetic checks + their incidents).- # Core: watching a site must not depend on the status-page extension.- from app.api.monitors import monitors_bp- app.register_blueprint(monitors_bp, url_prefix='/api/v1/monitors')-- # Register blueprints - Environment Variables- from app.api.env_vars import env_vars_bp- app.register_blueprint(env_vars_bp, url_prefix='/api/v1/apps')-- # Register blueprints - Two-Factor Authentication- from app.api.two_factor import two_factor_bp- app.register_blueprint(two_factor_bp, url_prefix='/api/v1/auth/2fa')-- # Register blueprints - SSO / OAuth- from app.api.sso import sso_bp- app.register_blueprint(sso_bp, url_prefix='/api/v1/sso')-- # Register blueprints - Source provider connections- from app.api.source_connections import source_connections_bp- app.register_blueprint(source_connections_bp, url_prefix='/api/v1/source-connections')-- # Register blueprints - Domain registrar connections (portfolio + expiry)- from app.api.registrars import registrars_bp- app.register_blueprint(registrars_bp, url_prefix='/api/v1/registrars')-- # Register blueprints - Unified connection registry (read-only "all connections")- from app.api.connections import connections_bp- app.register_blueprint(connections_bp, url_prefix='/api/v1/connections')-- # Register blueprints - Database Migrations- from app.api.migrations import migrations_bp- app.register_blueprint(migrations_bp, url_prefix='/api/v1/migrations')-- # Register blueprints - API Enhancements- from app.api.api_keys import api_keys_bp- from app.api.api_analytics import api_analytics_bp- from app.api.event_subscriptions import event_subscriptions_bp- from app.api.docs import docs_bp- app.register_blueprint(api_keys_bp, url_prefix='/api/v1/api-keys')- app.register_blueprint(api_analytics_bp, url_prefix='/api/v1/api-analytics')- app.register_blueprint(event_subscriptions_bp, url_prefix='/api/v1/event-subscriptions')- app.register_blueprint(docs_bp, url_prefix='/api/v1/docs')-- # Register blueprints - Admin (User Management, Settings, Audit Logs)- from app.api.admin import admin_bp- app.register_blueprint(admin_bp, url_prefix='/api/v1/admin')-- # Register blueprints - Invitations- from app.api.invitations import invitations_bp- app.register_blueprint(invitations_bp, url_prefix='/api/v1/admin/invitations')-- # Register blueprints - Historical Metrics- from app.api.metrics import metrics_bp- app.register_blueprint(metrics_bp, url_prefix='/api/v1/metrics')-- # The /api/v1/workflows blueprint (React-Flow Workflow Builder) was retired- # in plan 45 Phase 4 -- the Automations extension (tramo) replaces it.-- # Register blueprints - Servers (Multi-server management)- from app.api.servers import servers_bp- app.register_blueprint(servers_bp, url_prefix='/api/v1/servers')-- # Register blueprints - Server Survey (read-only "flights" over a paired agent)- from app.api.survey import survey_bp- app.register_blueprint(survey_bp, url_prefix='/api/v1/servers')-- # Register blueprints - Fleet Monitor (Cross-server monitoring)- from app.api.fleet_monitor import fleet_monitor_bp- app.register_blueprint(fleet_monitor_bp, url_prefix='/api/v1/fleet-monitor')-- # Register blueprints - Fleet (target picker, capability discovery)- from app.api.fleet import fleet_bp- app.register_blueprint(fleet_bp, url_prefix='/api/v1/fleet')-- # Register blueprints - Agent Plugins- from app.api.agent_plugins import agent_plugins_bp- app.register_blueprint(agent_plugins_bp, url_prefix='/api/v1/agent-plugins')-- # Register blueprints - Server Templates- from app.api.server_templates import server_templates_bp- app.register_blueprint(server_templates_bp, url_prefix='/api/v1/server-templates')-- # Register blueprints - Workspaces- from app.api.workspaces import workspaces_bp- app.register_blueprint(workspaces_bp, url_prefix='/api/v1/workspaces')-- # Register blueprints - Advanced SSL- # §5 unification: one SSL surface. The advanced cert operations (wildcard,- # SAN, custom upload, profiles, health, expiry alerts) mount under the same- # /api/v1/ssl prefix as the basic certbot routes (no path collisions). The- # original /api/v1/ssl/advanced prefix is kept as a deprecated alias.- from app.api.advanced_ssl import advanced_ssl_bp- app.register_blueprint(advanced_ssl_bp, url_prefix='/api/v1/ssl/advanced')- app.register_blueprint(advanced_ssl_bp, url_prefix='/api/v1/ssl', name='advanced_ssl_unified')-- # Register blueprints - DNS Zones- from app.api.dns_zones import dns_zones_bp- app.register_blueprint(dns_zones_bp, url_prefix='/api/v1/dns')-- # Register blueprints - Reversible DNS cutover (snapshot/cutover/verify/revert- # a migration's DNS switch; backs the /domains cutover drawer)- from app.api.dns_cutover import dns_cutover_bp- app.register_blueprint(dns_cutover_bp, url_prefix='/api/v1/dns-cutover')-- from app.api.setup_health import setup_health_bp- app.register_blueprint(setup_health_bp, url_prefix='/api/v1/setup-health')-- # Register blueprints - Cloudflare operations (zone settings/cache/WAF on top- # of the existing Cloudflare DNS connection)- # Cloudflare zone-ops moved into the bundled, default-installed- # `serverkit-cloudflare-ops` extension (#36). Its blueprint (kept at- # /api/v1/cloudflare, D9) is registered from the extension by the plugin- # loader — seeded as a flagship in create_app. DNS records + the Cloudflare- # connection stay core (they back /domains); the extension borrows the single- # core CloudflareClient, never a duplicate.-- # Register blueprints - DNS provider connections. Core (they back the- # Settings -> Connections DNS tiles and wildcard TLS), but kept at the- # historical /api/v1/email/dns-providers paths from before the email- # extraction so existing frontends keep working.- from app.api.dns_providers import dns_providers_bp- app.register_blueprint(dns_providers_bp, url_prefix='/api/v1/email')-- # Register blueprints - Dynamic DNS- from app.api.ddns import ddns_bp- app.register_blueprint(ddns_bp, url_prefix='/api/v1/ddns')-- # Register blueprints - Image update checks- from app.api.image_updates import image_updates_bp- app.register_blueprint(image_updates_bp, url_prefix='/api/v1/image-updates')-- # Register blueprints - Per-application WAF (ModSecurity + OWASP CRS)- from app.api.waf import waf_bp- app.register_blueprint(waf_bp, url_prefix='/api/v1/waf')-- # GPU monitoring lives in the standalone serverkit-gpu extension (own repo,- # installed from the registry). Its blueprint mounts at /api/v1/gpu when- # installed; the core app.api.gpu / app.services.gpu_service modules are gone.-- # Register blueprints - Nginx Advanced- from app.api.nginx_advanced import nginx_advanced_bp- app.register_blueprint(nginx_advanced_bp, url_prefix='/api/v1/nginx/advanced')-- # Status Pages is an opt-in builtin extension (serverkit-status, plan 47) —- # its blueprint (public + management routes) loads from builtin-extensions/- # when installed, not from core. The StatusPage/StatusComponent models stay- # core (G2); the WordPress health-check job reaches the extension's sync- # helper via get_installed_extension_attr only when installed.-- # Cloud Provisioning is an opt-in builtin extension (serverkit-cloud-provision,- # plan 47) — its blueprint loads from builtin-extensions/ when installed, not- # from core. The CloudProvider/CloudServer models stay core (G2).-- # Remote Access (WireGuard tunnels) is an opt-in builtin extension- # (serverkit-remote-access, plan 47) — its blueprint loads from- # builtin-extensions/ when installed, not from core. The Tunnel/ExposedService- # models stay core (G2); the agent gateway reaches its reconcile helper via- # get_installed_extension_attr only when the extension is present.-- # Register blueprints - Performance- from app.api.performance import performance_bp- app.register_blueprint(performance_bp, url_prefix='/api/v1/performance')-- # Register blueprints - Mobile- from app.api.mobile import mobile_bp- app.register_blueprint(mobile_bp, url_prefix='/api/v1/mobile')-- # Register blueprints - Marketplace- from app.api.marketplace import marketplace_bp- app.register_blueprint(marketplace_bp, url_prefix='/api/v1/marketplace')-- # Register blueprints - Themes (plan 60)- from app.api.themes import themes_bp- app.register_blueprint(themes_bp, url_prefix='/api/v1/themes')- from app.api.views import views_bp- app.register_blueprint(views_bp, url_prefix='/api/v1/views')-- from app.api.recycle_bin import recycle_bin_bp- app.register_blueprint(recycle_bin_bp, url_prefix='/api/v1/recycle-bin')-- # Register blueprints - Centralized error log tracking- from app.api.error_logs import error_logs_bp- app.register_blueprint(error_logs_bp, url_prefix='/api/v1/error-logs')- # Teach the bin which models it can restore. Import-time registration keeps- # the API type-agnostic: adding a soft-deletable model touches only this list.+ # Core routes are an explicit, ordered manifest. Extension blueprints stay+ # outside this registry and are loaded after migrations below.+ from app.core_blueprints import register_core_blueprints+ register_core_blueprints(app)++ # Register the core restore handlers after their models and API modules+ # have been imported by the blueprint registry.from app.services import recycle_bin_servicerecycle_bin_service.register_builtin_types()- # Register blueprints - Dashboard boards (plan 62, per-user widget grid)- from app.api.dashboards import dashboards_bp- app.register_blueprint(dashboards_bp, url_prefix='/api/v1/dashboards')-- # Register blueprints - Plugins- from app.api.plugins import plugins_bp- app.register_blueprint(plugins_bp, url_prefix='/api/v1/plugins')-- # Register blueprints - Unified entity omnisearch- from app.api.search import search_bp- app.register_blueprint(search_bp, url_prefix='/api/v1/search')-- # Register blueprints - Modules (core-vertical toggles)- from app.api.modules import modules_bp- app.register_blueprint(modules_bp, url_prefix='/api/v1/modules')-- # Register blueprints - Queue Bus- from app.api.queue_bus import queue_bus_bp- app.register_blueprint(queue_bus_bp, url_prefix='/api/v1/queue')-- # Register blueprints - Unified Jobs (work orchestration on the Queue Bus)- from app.api.jobs import jobs_bp- app.register_blueprint(jobs_bp, url_prefix='/api/v1/jobs')-- # Register blueprints - Telemetry / System Event Stream- from app.api.telemetry import telemetry_bp- app.register_blueprint(telemetry_bp, url_prefix='/api/v1/telemetry')-- # §4 unification: one observability namespace. The monitoring / metrics /- # telemetry / uptime / fleet / status-page read surfaces are re-mounted under- # /api/v1/observability/<domain> as true aliases (same blueprints, distinct- # names) so callers have a single front door. The original prefixes remain,- # and the PUBLIC status page route (/api/v1/status/public/<slug>) is- # unchanged — its canonical mount is untouched.- app.register_blueprint(monitoring_bp, url_prefix='/api/v1/observability/monitoring', name='obs_monitoring')- app.register_blueprint(metrics_bp, url_prefix='/api/v1/observability/metrics', name='obs_metrics')- app.register_blueprint(telemetry_bp, url_prefix='/api/v1/observability/events', name='obs_events')- app.register_blueprint(uptime_bp, url_prefix='/api/v1/observability/uptime', name='obs_uptime')- app.register_blueprint(fleet_monitor_bp, url_prefix='/api/v1/observability/fleet', name='obs_fleet')- # status-pages observability alias dropped with the serverkit-status- # extraction (plan 47) — it was unused by the frontend; status pages mount at- # /api/v1/status from the extension when installed.-- # Register blueprints - Agent Pairing (RustDesk-style short-code flow)- from app.api.pairing import pairing_bp- app.register_blueprint(pairing_bp, url_prefix='/api/v1/pairing')-- # Register blueprints - AI Assistant (core primitive, powered by Prompture)- from app.api.ai import ai_bp- app.register_blueprint(ai_bp, url_prefix='/api/v1/ai')-- # Register blueprints - Server speed test (Monitoring card)- from app.api.speed_test import speedtest_bp- app.register_blueprint(speedtest_bp, url_prefix='/api/v1/speedtest')-- # Register blueprints - Site imports (panel migration pipeline)- from app.api.site_imports import site_imports_bp- app.register_blueprint(site_imports_bp, url_prefix='/api/v1/imports')-- # Register blueprints - Drift detection + doctor sweep- from app.api.doctor import doctor_bp- app.register_blueprint(doctor_bp, url_prefix='/api/v1/doctor')-- # Register blueprints - Fleet doctor (the same sweep across the agent fleet)- from app.api.fleet_doctor import fleet_doctor_bp- app.register_blueprint(fleet_doctor_bp, url_prefix='/api/v1/doctor/fleet')-- # Register blueprints - Diagnostic support bundle- from app.api.support_bundle import support_bundle_bp- app.register_blueprint(support_bundle_bp, url_prefix='/api/v1/support-bundle')-- # Register blueprints - Per-site bandwidth accounting- from app.api.bandwidth import bandwidth_bp- app.register_blueprint(bandwidth_bp, url_prefix='/api/v1/bandwidth')-- # Register blueprints - .htaccess -> nginx converter (apps-prefixed tool)- from app.api.htaccess_tools import htaccess_tools_bp- app.register_blueprint(htaccess_tools_bp, url_prefix='/api/v1/apps')-- # Register blueprints - Test Sandbox (distro test matrix in Docker)- from app.api.test_sandbox import test_sandbox_bp- app.register_blueprint(test_sandbox_bp, url_prefix='/api/v1/test-sandbox')-# Handle database migrations (Alembic) — must run before plugin loader# since the loader queries the installed_plugins table.with app.app_context():diff --git a/backend/app/core_blueprints.py b/backend/app/core_blueprints.pynew file mode 100644index 00000000..fdc52ec0--- /dev/null+++ b/backend/app/core_blueprints.py@@ -0,0 +1,284 @@+"""Explicit registry for ServerKit's core API blueprints.++Core routes are deliberately curated here rather than discovered from the+filesystem. Besides making the app factory readable, the ordered manifest+keeps compatibility aliases visible and gives structural tests one stable+surface to guard.++Installed extension blueprints are not part of this registry. They continue+to be registered by :mod:`app.services.plugin_service` after migrations have+prepared the plugin tables.+"""++from dataclasses import dataclass+from importlib import import_module++from flask import Blueprint, Flask+++@dataclass(frozen=True, slots=True)+class BlueprintSpec:+ """One ordered core blueprint mount."""++ module: str+ attribute: str+ url_prefix: str+ name: str | None = None++ def load(self) -> Blueprint:+ """Import and return the configured blueprint."""+ blueprint = getattr(import_module(self.module), self.attribute)+ if not isinstance(blueprint, Blueprint):+ raise TypeError(+ f'{self.module}.{self.attribute} is not a Flask Blueprint'+ )+ return blueprint++ @property+ def manifest_entry(self) -> tuple[str, str, str, str | None]:+ """Return the stable, serializable representation used by tests."""+ return self.module, self.attribute, self.url_prefix, self.name+++# Registration order intentionally matches the historical create_app order.+# Several blueprints are mounted more than once to preserve compatibility+# aliases; each alias must use a distinct Flask registration name.+CORE_BLUEPRINTS: tuple[BlueprintSpec, ...] = (+ BlueprintSpec('app.api.auth', 'auth_bp', '/api/v1/auth'),+ BlueprintSpec('app.api.agent_poll', 'agent_poll_bp', '/api/v1/agent'),+ BlueprintSpec('app.api.linked_panel', 'linked_panel_bp', '/api/v1/linked-panel'),+ BlueprintSpec('app.api.apps', 'apps_bp', '/api/v1/apps'),+ BlueprintSpec('app.api.apps', 'apps_bp', '/api/v1/services', name='services'),+ BlueprintSpec('app.api.domains', 'domains_bp', '/api/v1/domains'),+ BlueprintSpec('app.api.private_urls', 'private_urls_bp', '/api/v1/apps'),+ BlueprintSpec('app.api.app_volumes', 'app_volumes_bp', '/api/v1/apps'),+ BlueprintSpec(+ 'app.api.app_volumes',+ 'app_volumes_bp',+ '/api/v1/services',+ name='app_volumes_services',+ ),+ BlueprintSpec('app.api.system', 'system_bp', '/api/v1/system'),+ BlueprintSpec('app.api.processes', 'processes_bp', '/api/v1/processes'),+ BlueprintSpec('app.api.logs', 'logs_bp', '/api/v1/logs'),+ BlueprintSpec('app.api.nginx', 'nginx_bp', '/api/v1/nginx'),+ BlueprintSpec('app.api.ssl', 'ssl_bp', '/api/v1/ssl'),+ BlueprintSpec('app.api.php', 'php_bp', '/api/v1/php'),+ BlueprintSpec('app.api.python', 'python_bp', '/api/v1/python'),+ BlueprintSpec('app.api.docker', 'docker_bp', '/api/v1/docker'),+ BlueprintSpec('app.api.databases', 'databases_bp', '/api/v1/databases'),+ BlueprintSpec(+ 'app.api.database_engines',+ 'database_engines_bp',+ '/api/v1/databases/engines',+ ),+ BlueprintSpec(+ 'app.api.managed_db_users',+ 'managed_db_users_bp',+ '/api/v1/managed-databases',+ ),+ BlueprintSpec('app.api.db_tuner', 'db_tuner_bp', '/api/v1/db-tuner'),+ BlueprintSpec('app.api.monitoring', 'monitoring_bp', '/api/v1/monitoring'),+ BlueprintSpec(+ 'app.api.container_status',+ 'container_status_bp',+ '/api/v1/status',+ ),+ BlueprintSpec('app.api.buildpacks', 'buildpacks_bp', '/api/v1/buildpacks'),+ BlueprintSpec('app.api.snapshots', 'snapshots_bp', '/api/v1/apps'),+ BlueprintSpec('app.api.manifests', 'manifests_bp', '/api/v1/manifests'),+ BlueprintSpec('app.api.projects', 'projects_bp', '/api/v1/projects'),+ BlueprintSpec('app.api.environments', 'environments_bp', '/api/v1/environments'),+ BlueprintSpec(+ 'app.api.shared_resources',+ 'shared_resources_bp',+ '/api/v1/shared',+ ),+ BlueprintSpec('app.api.previews', 'previews_bp', '/api/v1/apps'),+ BlueprintSpec('app.api.webhooks', 'webhooks_bp', '/api/v1/webhooks'),+ BlueprintSpec('app.api.proxy', 'proxy_bp', '/api/v1/servers'),+ BlueprintSpec(+ 'app.api.notifications',+ 'notifications_bp',+ '/api/v1/notifications',+ ),+ BlueprintSpec('app.api.backups', 'backups_bp', '/api/v1/backups'),+ BlueprintSpec('app.api.deploy', 'deploy_bp', '/api/v1/deploy'),+ BlueprintSpec('app.api.builds', 'builds_bp', '/api/v1/builds'),+ BlueprintSpec(+ 'app.api.deployment_jobs',+ 'deployment_jobs_bp',+ '/api/v1/deployment-jobs',+ ),+ BlueprintSpec('app.api.deployments', 'deployments_bp', '/api/v1/deployments'),+ BlueprintSpec(+ 'app.api.deployment_jobs',+ 'deployment_jobs_bp',+ '/api/v1/deployments/jobs',+ name='deployment_jobs_unified',+ ),+ BlueprintSpec('app.api.templates', 'templates_bp', '/api/v1/templates'),+ BlueprintSpec('app.api.files', 'files_bp', '/api/v1/files'),+ BlueprintSpec('app.api.firewall', 'firewall_bp', '/api/v1/firewall'),+ BlueprintSpec('app.api.git', 'git_bp', '/api/v1/git'),+ BlueprintSpec('app.api.security', 'security_bp', '/api/v1/security'),+ BlueprintSpec('app.api.secrets_webhooks', 'bp', '/api/v1'),+ BlueprintSpec('app.api.cron', 'cron_bp', '/api/v1/cron'),+ BlueprintSpec('app.api.uptime', 'uptime_bp', '/api/v1/uptime'),+ BlueprintSpec('app.api.monitors', 'monitors_bp', '/api/v1/monitors'),+ BlueprintSpec('app.api.env_vars', 'env_vars_bp', '/api/v1/apps'),+ BlueprintSpec('app.api.two_factor', 'two_factor_bp', '/api/v1/auth/2fa'),+ BlueprintSpec('app.api.sso', 'sso_bp', '/api/v1/sso'),+ BlueprintSpec(+ 'app.api.source_connections',+ 'source_connections_bp',+ '/api/v1/source-connections',+ ),+ BlueprintSpec('app.api.registrars', 'registrars_bp', '/api/v1/registrars'),+ BlueprintSpec('app.api.connections', 'connections_bp', '/api/v1/connections'),+ BlueprintSpec('app.api.migrations', 'migrations_bp', '/api/v1/migrations'),+ BlueprintSpec('app.api.api_keys', 'api_keys_bp', '/api/v1/api-keys'),+ BlueprintSpec(+ 'app.api.api_analytics',+ 'api_analytics_bp',+ '/api/v1/api-analytics',+ ),+ BlueprintSpec(+ 'app.api.event_subscriptions',+ 'event_subscriptions_bp',+ '/api/v1/event-subscriptions',+ ),+ BlueprintSpec('app.api.docs', 'docs_bp', '/api/v1/docs'),+ BlueprintSpec('app.api.admin', 'admin_bp', '/api/v1/admin'),+ BlueprintSpec(+ 'app.api.invitations',+ 'invitations_bp',+ '/api/v1/admin/invitations',+ ),+ BlueprintSpec('app.api.metrics', 'metrics_bp', '/api/v1/metrics'),+ BlueprintSpec('app.api.servers', 'servers_bp', '/api/v1/servers'),+ BlueprintSpec('app.api.survey', 'survey_bp', '/api/v1/servers'),+ BlueprintSpec(+ 'app.api.fleet_monitor',+ 'fleet_monitor_bp',+ '/api/v1/fleet-monitor',+ ),+ BlueprintSpec('app.api.fleet', 'fleet_bp', '/api/v1/fleet'),+ BlueprintSpec(+ 'app.api.agent_plugins',+ 'agent_plugins_bp',+ '/api/v1/agent-plugins',+ ),+ BlueprintSpec(+ 'app.api.server_templates',+ 'server_templates_bp',+ '/api/v1/server-templates',+ ),+ BlueprintSpec('app.api.workspaces', 'workspaces_bp', '/api/v1/workspaces'),+ BlueprintSpec(+ 'app.api.advanced_ssl',+ 'advanced_ssl_bp',+ '/api/v1/ssl/advanced',+ ),+ BlueprintSpec(+ 'app.api.advanced_ssl',+ 'advanced_ssl_bp',+ '/api/v1/ssl',+ name='advanced_ssl_unified',+ ),+ BlueprintSpec('app.api.dns_zones', 'dns_zones_bp', '/api/v1/dns'),+ BlueprintSpec('app.api.dns_cutover', 'dns_cutover_bp', '/api/v1/dns-cutover'),+ BlueprintSpec('app.api.setup_health', 'setup_health_bp', '/api/v1/setup-health'),+ BlueprintSpec('app.api.dns_providers', 'dns_providers_bp', '/api/v1/email'),+ BlueprintSpec('app.api.ddns', 'ddns_bp', '/api/v1/ddns'),+ BlueprintSpec(+ 'app.api.image_updates',+ 'image_updates_bp',+ '/api/v1/image-updates',+ ),+ BlueprintSpec('app.api.waf', 'waf_bp', '/api/v1/waf'),+ BlueprintSpec(+ 'app.api.nginx_advanced',+ 'nginx_advanced_bp',+ '/api/v1/nginx/advanced',+ ),+ BlueprintSpec('app.api.performance', 'performance_bp', '/api/v1/performance'),+ BlueprintSpec('app.api.mobile', 'mobile_bp', '/api/v1/mobile'),+ BlueprintSpec('app.api.marketplace', 'marketplace_bp', '/api/v1/marketplace'),+ BlueprintSpec('app.api.themes', 'themes_bp', '/api/v1/themes'),+ BlueprintSpec('app.api.views', 'views_bp', '/api/v1/views'),+ BlueprintSpec(+ 'app.api.recycle_bin',+ 'recycle_bin_bp',+ '/api/v1/recycle-bin',+ ),+ BlueprintSpec('app.api.error_logs', 'error_logs_bp', '/api/v1/error-logs'),+ BlueprintSpec('app.api.dashboards', 'dashboards_bp', '/api/v1/dashboards'),+ BlueprintSpec('app.api.plugins', 'plugins_bp', '/api/v1/plugins'),+ BlueprintSpec('app.api.search', 'search_bp', '/api/v1/search'),+ BlueprintSpec('app.api.modules', 'modules_bp', '/api/v1/modules'),+ BlueprintSpec('app.api.queue_bus', 'queue_bus_bp', '/api/v1/queue'),+ BlueprintSpec('app.api.jobs', 'jobs_bp', '/api/v1/jobs'),+ BlueprintSpec('app.api.telemetry', 'telemetry_bp', '/api/v1/telemetry'),+ BlueprintSpec(+ 'app.api.monitoring',+ 'monitoring_bp',+ '/api/v1/observability/monitoring',+ name='obs_monitoring',+ ),+ BlueprintSpec(+ 'app.api.metrics',+ 'metrics_bp',+ '/api/v1/observability/metrics',+ name='obs_metrics',+ ),+ BlueprintSpec(+ 'app.api.telemetry',+ 'telemetry_bp',+ '/api/v1/observability/events',+ name='obs_events',+ ),+ BlueprintSpec(+ 'app.api.uptime',+ 'uptime_bp',+ '/api/v1/observability/uptime',+ name='obs_uptime',+ ),+ BlueprintSpec(+ 'app.api.fleet_monitor',+ 'fleet_monitor_bp',+ '/api/v1/observability/fleet',+ name='obs_fleet',+ ),+ BlueprintSpec('app.api.pairing', 'pairing_bp', '/api/v1/pairing'),+ BlueprintSpec('app.api.ai', 'ai_bp', '/api/v1/ai'),+ BlueprintSpec('app.api.speed_test', 'speedtest_bp', '/api/v1/speedtest'),+ BlueprintSpec('app.api.site_imports', 'site_imports_bp', '/api/v1/imports'),+ BlueprintSpec('app.api.doctor', 'doctor_bp', '/api/v1/doctor'),+ BlueprintSpec(+ 'app.api.fleet_doctor',+ 'fleet_doctor_bp',+ '/api/v1/doctor/fleet',+ ),+ BlueprintSpec(+ 'app.api.support_bundle',+ 'support_bundle_bp',+ '/api/v1/support-bundle',+ ),+ BlueprintSpec('app.api.bandwidth', 'bandwidth_bp', '/api/v1/bandwidth'),+ BlueprintSpec('app.api.htaccess_tools', 'htaccess_tools_bp', '/api/v1/apps'),+ BlueprintSpec(+ 'app.api.test_sandbox',+ 'test_sandbox_bp',+ '/api/v1/test-sandbox',+ ),+)+++def register_core_blueprints(app: Flask) -> None:+ """Register every curated core API blueprint on ``app`` in order."""+ for spec in CORE_BLUEPRINTS:+ options = {'url_prefix': spec.url_prefix}+ if spec.name is not None:+ options['name'] = spec.name+ app.register_blueprint(spec.load(), **options)diff --git a/backend/tests/test_core_blueprint_registry.py b/backend/tests/test_core_blueprint_registry.pynew file mode 100644index 00000000..8bcec102--- /dev/null+++ b/backend/tests/test_core_blueprint_registry.py@@ -0,0 +1,73 @@+"""Structural guards for the curated core blueprint registry."""++import ast+import hashlib+from pathlib import Path++from app.core_blueprints import CORE_BLUEPRINTS+++EXPECTED_CORE_BLUEPRINT_COUNT = 108+EXPECTED_MANIFEST_SHA256 = (+ '133401be7b9636eaf7cea93a2222fe9e4f85e7dba433eae88d03ac37a351cf7e'+)+++def _manifest_payload() -> bytes:+ entries = tuple(spec.manifest_entry for spec in CORE_BLUEPRINTS)+ return repr(entries).encode()+++def test_core_blueprint_manifest_matches_pre_extraction_snapshot():+ """Guard every module, attribute, prefix, alias, and ordering decision."""+ assert len(CORE_BLUEPRINTS) == EXPECTED_CORE_BLUEPRINT_COUNT+ assert hashlib.sha256(_manifest_payload()).hexdigest() == (+ EXPECTED_MANIFEST_SHA256+ )+++def test_create_app_delegates_blueprint_registration_to_registry():+ """Keep the factory compositional instead of rebuilding the import wall."""+ app_init = Path(__file__).parents[1] / 'app' / '__init__.py'+ module = ast.parse(app_init.read_text(encoding='utf-8'))+ create_app = next(+ node+ for node in module.body+ if isinstance(node, ast.FunctionDef) and node.name == 'create_app'+ )++ direct_registrations = [+ node+ for node in ast.walk(create_app)+ if isinstance(node, ast.Call)+ and isinstance(node.func, ast.Attribute)+ and node.func.attr == 'register_blueprint'+ ]++ assert direct_registrations == []+++def test_app_mounts_every_core_blueprint_at_its_curated_prefix(app):+ """Verify the real app's blueprint objects and URL rules match the registry."""+ rules = tuple(app.url_map.iter_rules())++ for spec in CORE_BLUEPRINTS:+ blueprint = spec.load()+ registration_name = spec.name or blueprint.name+ assert app.blueprints.get(registration_name) is blueprint, (+ f'{registration_name} was not registered from {spec.module}'+ )++ blueprint_rules = tuple(+ rule+ for rule in rules+ if rule.endpoint == registration_name+ or rule.endpoint.startswith(f'{registration_name}.')+ )+ assert blueprint_rules, f'{registration_name} registered no URL rules'++ prefix = spec.url_prefix.rstrip('/')+ assert all(+ rule.rule == prefix or rule.rule.startswith(f'{prefix}/')+ for rule in blueprint_rules+ ), f'{registration_name} has a rule outside {spec.url_prefix}'