Skip to content

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.

chore: clean root and docs — drop recovery artifacts, relocate stale audits

Juan Denisb5160e90bf18
diff --git a/.gitignore b/.gitignore
index c6ce3a5a..ab94cbd7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -156,7 +156,7 @@ docs/PLAN_AGENT_FLEET.md
/.claude
/.github/skills
/.playwright-mcp
-docs/UI_CONSISTENCY_AUDIT.md
+docs/audits/UI_CONSISTENCY_AUDIT.md
docs/REMOTE_ACCESS_ROADMAP.md
docs/NOTIFICATIONS_ROADMAP.md
docs/ORCHESTRATION_ROADMAP.md
diff --git a/RECOVERY.md b/RECOVERY.md
deleted file mode 100644
index 49b8181b..00000000
--- a/RECOVERY.md
+++ /dev/null
@@ -1,61 +0,0 @@
-# ServerKit — data-loss recovery record (2026-07-07)
-
-This repository was reconstructed after an accidental `rm -rf` (a staging test
-run from the wrong directory) deleted the working tree **and** `.git`. This file
-documents exactly what was recovered, from where, and what could not be
-restored — so the history and code can be trusted for what they are.
-
-## Sources
-
-| Source | Date | Role |
-|--------|------|------|
-| GitHub `origin/dev` | 2026-07-04 (`07baefb`) | **Full commit history — 1,130 commits.** The baseline everything sits on. |
-| VSS shadow copy | 2026-07-06 22:49 | Working tree; ~half its files were corrupted (zeroed blocks). Held 14 recoverable loose commit objects (plans 29–31). |
-| File-undelete (winfr) | deleted 2026-07-07 | Frontend/docs/scripts — current (July-7), mostly clean. No `.py`, no git. |
-| winfr `/extensive` | — | 18k files; 0 real `.py`, no git data. Ruled out. |
-
-## What was recovered
-
-- **Git history through 2026-07-04** — intact and complete (1,130 commits).
-- **Frontend** — current (July-7 from the undelete, verified clean).
-- **Backend** — CLEAN recovered files were applied; the many that the shadow
- backup had **corrupted (zeroed) fell back to their July-4 baseline version.**
- So a large part of the backend is at July-4, not July-6/7.
-- **14 original commit objects** (July-6, plans 29–31) preserved as reference
- (see `docs/RECOVERED_COMMITS.txt`).
-
-## What was LOST (unrecoverable — the git objects were destroyed everywhere)
-
-- The discrete commits for plans ~32–36 (July-6 night → July-7, ending
- `bea4373`) — code partly reconstructed, original commit granularity gone.
-- **New July-5–7 backend files that the shadow corrupted, with no July-4
- fallback, were dropped**, including: `dns_cutover*`, `fleet_doctor*` /
- `fleet_repair`, `survey_service`, `backup_drill_service`, `chat_webhook_service`,
- `setup_health_service` / `setup_reconcile_service`, `security_policy_service`,
- `cron_run_service`, migrations 056–068, `cloudflare.py` /
- `cloudflare_service.py`, and their tests. These features must be re-done.
-- Backend files that changed July-5–7 but were corrupt in the backup now show
- their **July-4** content (their recent edits are lost).
-
-## History layout
-
-- `07baefb` (July-4) and earlier — **real GitHub history, untouched.**
-- ~14 commits above it — **reconstruction**: grouped by plan (keyword-matched,
- best-effort messages) + a catch-all. These are approximate, built only from
- the CLEAN recovered files; corrupt/lost content is NOT in them.
-- Tag `recovery-blob` — an earlier single-commit snapshot (pre-cleanup; ignore).
-
-## ⚠️ Before trusting this repo
-
-Run the test suites — they will surface anything that reverted to July-4 or is
-missing, so you know what to re-do:
-
-```sh
-cd frontend && npm install && npm run lint && npm run build
-cd backend && python -m venv venv && source venv/bin/activate \
- && pip install -r requirements.txt && pytest
-```
-
-Raw recovered data is preserved on `D:\` (the shadow copy under
-`ServerKit_RECOVERED`, undelete output under `SK_Recovery` / `SK_ext`) until you
-confirm this repo is good.
diff --git a/docs/RECOVERED_COMMITS.txt b/docs/RECOVERED_COMMITS.txt
deleted file mode 100644
index b860a524..00000000
--- a/docs/RECOVERED_COMMITS.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-# Recovered original commit objects (from the July-6 shadow copy)
-# Real pre-loss commits whose objects survived. Messages exact.
-
-2026-07-06 18:16:45 -0400 97fafc7 test(authz): generic structural per-app gate + seal leftover reads (plan 29 Phase 3)
-2026-07-06 18:23:49 -0400 9c88119 docs(security): 4-tier authz model + member-actions admin toggle (plan 29 Phase 5)
-2026-07-06 19:12:19 -0400 b4c0e65 fix(backup): vacuous WordPress drill fails + re-flag old vacuous 'drilled' runs (plan 30 Phase 1)
-2026-07-06 19:15:08 -0400 5dc71d8 feat(backup): stamp drill expectations at backup time + compare at drill (plan 30 Phase 2)
-2026-07-06 19:20:23 -0400 9f559e4 feat(backup): container-aware DB drills + real WordPress DB leg (plan 30 Phase 3)
-2026-07-06 19:23:57 -0400 421b1cb feat(backup): enqueue-time single-flight, WP drill via edit-gate, per-destination sampling (plan 30 Phase 4)
-2026-07-06 19:30:46 -0400 fee4f5c docs(backup): honesty passes — POSIX-only drill note, shallow-verify claim (plan 30 Phase 5)
-2026-07-06 19:49:14 -0400 fff856d feat(dns-cutover): reachable cutover+verify endpoints, server-sourced snapshots, world-restoring revert (plan 31 Phase 1)
diff --git a/docs/AGENT_AUDIT.md b/docs/audits/AGENT_AUDIT.md
similarity index 100%
rename from docs/AGENT_AUDIT.md
rename to docs/audits/AGENT_AUDIT.md
diff --git a/docs/COMPETITIVE_ANALYSIS.md b/docs/audits/COMPETITIVE_ANALYSIS.md
similarity index 100%
rename from docs/COMPETITIVE_ANALYSIS.md
rename to docs/audits/COMPETITIVE_ANALYSIS.md
diff --git a/docs/EXTRACTION_EMAIL_AUDIT.md b/docs/audits/EXTRACTION_EMAIL_AUDIT.md
similarity index 100%
rename from docs/EXTRACTION_EMAIL_AUDIT.md
rename to docs/audits/EXTRACTION_EMAIL_AUDIT.md
diff --git a/docs/FEATURE_GAPS.md b/docs/audits/FEATURE_GAPS.md
similarity index 100%
rename from docs/FEATURE_GAPS.md
rename to docs/audits/FEATURE_GAPS.md
diff --git a/docs/MARKET_POSITIONING.md b/docs/audits/MARKET_POSITIONING.md
similarity index 100%
rename from docs/MARKET_POSITIONING.md
rename to docs/audits/MARKET_POSITIONING.md
diff --git a/patch_localhost.py b/patch_localhost.py
deleted file mode 100644
index 419249e8..00000000
--- a/patch_localhost.py
+++ /dev/null
@@ -1,294 +0,0 @@
-import os
-
-def replace_in_file(path, old, new):
- if not os.path.exists(path):
- print(f'SKIP (not found): {path}')
- return False
- with open(path, 'r') as f:
- content = f.read()
- if old not in content:
- print(f'PATTERN NOT FOUND: {path}')
- return False
- content = content.replace(old, new)
- with open(path, 'w') as f:
- f.write(content)
- print(f'Patched: {path}')
- return True
-
-# 1. site_domain_service.py - add panel_origin helper
-replace_in_file(
- '/opt/serverkit/backend/app/services/site_domain_service.py',
- """ @classmethod
- def server_ip(cls):
- \"\"\"Public IP that wildcard/custom A-records should point at (Phase 3).\"\"\"
- return SystemSettings.get('server_public_ip') or current_app.config.get('SERVER_PUBLIC_IP') or None
-
- @classmethod
- def https_enabled(cls):""",
- """ @classmethod
- def server_ip(cls):
- \"\"\"Public IP that wildcard/custom A-records should point at (Phase 3).\"\"\"
- return SystemSettings.get('server_public_ip') or current_app.config.get('SERVER_PUBLIC_IP') or None
-
- @classmethod
- def panel_origin(cls):
- \"\"\"Canonical public origin of the ServerKit panel, or None when no
- canonical domain is configured.
-
- Uses the persisted canonical_domain / canonical_https_enabled settings.
- Falls back to PUBLIC_URL / SERVERKIT_PUBLIC_URL env vars, then to the
- sites base domain. Returns None if nothing usable is configured.
- \"\"\"
- domain = SystemSettings.get('canonical_domain')
- if domain:
- https = bool(SystemSettings.get('canonical_https_enabled', False))
- return f'https://{domain}' if https else f'http://{domain}'
-
- url = current_app.config.get('PUBLIC_URL') or current_app.config.get('SERVERKIT_PUBLIC_URL')
- if url:
- return url.rstrip('/')
-
- base = cls.base_domain()
- if base:
- return f'https://{base}' if cls.https_enabled() else f'http://{base}'
-
- return None
-
- @classmethod
- def https_enabled(cls):"""
-)
-
-# 2. git_service.py - Gitea URL
-replace_in_file(
- '/opt/serverkit/backend/app/services/git_service.py',
- """ return {
- 'installed': True,
- 'running': running,
- 'http_port': app.port or config.get('http_port'),
- 'ssh_port': config.get('ssh_port'),
- 'url_path': '/gitea', # Slug-based URL path
- 'url': f\"http://localhost:{app.port}\" if app.port else None, # Legacy port-based URL
- 'app_id': app.id,
- 'version': config.get('version', '1.21')
- }""",
- """ # Prefer the panel's canonical origin so the link works through a domain
- # and Cloudflare; fall back to the local port only when no domain is set.
- from app.services.site_domain_service import SiteDomainService
- panel_origin = SiteDomainService.panel_origin()
- if panel_origin:
- public_url = f\"{panel_origin}/gitea\"
- elif app.port:
- public_url = f\"http://localhost:{app.port}\"
- else:
- public_url = None
-
- return {
- 'installed': True,
- 'running': running,
- 'http_port': app.port or config.get('http_port'),
- 'ssh_port': config.get('ssh_port'),
- 'url_path': '/gitea',
- 'url': public_url,
- 'app_id': app.id,
- 'version': config.get('version', '1.21')
- }"""
-)
-
-# 3. wordpress_service.py - standalone WordPress status URL
-replace_in_file(
- '/opt/serverkit/backend/app/services/wordpress_service.py',
- """ return {
- 'installed': True,
- 'running': running,
- 'http_port': app.port or config.get('http_port'),
- 'url_path': '/wordpress',
- 'url': f\"http://localhost:{app.port}\" if app.port else None,
- 'app_id': app.id,
- 'version': config.get('version', '6.4')
- }""",
- """ # Prefer the panel's canonical origin so the link works through a domain
- # and Cloudflare; fall back to the local port only when no domain is set.
- from app.services.site_domain_service import SiteDomainService
- panel_origin = SiteDomainService.panel_origin()
- if panel_origin:
- public_url = f\"{panel_origin}/wordpress\"
- elif app.port:
- public_url = f\"http://localhost:{app.port}\"
- else:
- public_url = None
-
- return {
- 'installed': True,
- 'running': running,
- 'http_port': app.port or config.get('http_port'),
- 'url_path': '/wordpress',
- 'url': public_url,
- 'app_id': app.id,
- 'version': config.get('version', '6.4')
- }"""
-)
-
-# 4. wordpress_service.py - _canonical_site_url fallback
-replace_in_file(
- '/opt/serverkit/backend/app/services/wordpress_service.py',
- """ @classmethod
- def _canonical_site_url(cls, app) -> str:
- \"\"\"The URL WordPress serves under — its primary domain if one exists,
- else the legacy localhost:<port> address. Used to build correct
- search-replace pairs when cloning.\"\"\"
- from app.models.domain import Domain
- d = (Domain.query.filter_by(application_id=app.id, is_primary=True).first()
- or Domain.query.filter_by(application_id=app.id).first())
- if d:
- return f'http://{d.name}'
- if app.port:
- return f'http://localhost:{app.port}'
- return None""",
- """ @classmethod
- def _canonical_site_url(cls, app) -> str:
- \"\"\"The URL WordPress serves under — its primary domain if one exists,
- else the panel's canonical origin, else the legacy localhost:<port>
- address. Used to build correct search-replace pairs when cloning.\"\"\"
- from app.models.domain import Domain
- from app.services.site_domain_service import SiteDomainService
- d = (Domain.query.filter_by(application_id=app.id, is_primary=True).first()
- or Domain.query.filter_by(application_id=app.id).first())
- if d:
- scheme = 'https' if d.ssl_enabled else 'http'
- return f'{scheme}://{d.name}'
- panel_origin = SiteDomainService.panel_origin()
- if panel_origin:
- return panel_origin
- if app.port:
- return f'http://localhost:{app.port}'
- return None"""
-)
-
-# 5. roundcube_service.py - install signature + URL
-replace_in_file(
- '/opt/serverkit/backend/app/services/roundcube_service.py',
- """ @classmethod
- def install(cls, imap_host: str = 'host.docker.internal',
- smtp_host: str = 'host.docker.internal') -> Dict:""",
- """ @classmethod
- def install(cls, imap_host: str = 'host.docker.internal',
- smtp_host: str = 'host.docker.internal',
- domain: str = None) -> Dict:"""
-)
-
-replace_in_file(
- '/opt/serverkit/backend/app/services/roundcube_service.py',
- """ return {
- 'success': True,
- 'message': 'Roundcube installed successfully',
- 'port': cls.HOST_PORT,
- 'url': f'http://localhost:{cls.HOST_PORT}',
- }""",
- """ # Build a public URL: prefer a supplied domain, then auto-generate
- # webmail.<panel_domain>, and only fall back to localhost:port.
- from app.services.site_domain_service import SiteDomainService
- public_url = None
- warning = None
- if domain:
- public_url = f'http://{domain}'
- proxy_res = cls.configure_nginx_proxy(domain)
- if not proxy_res.get('success'):
- warning = proxy_res.get('error')
- else:
- panel_origin = SiteDomainService.panel_origin()
- panel_host = None
- if panel_origin:
- from urllib.parse import urlparse
- panel_host = urlparse(panel_origin).hostname
- if panel_host:
- webmail_domain = f'webmail.{panel_host}'
- public_url = f'http://{webmail_domain}'
- proxy_res = cls.configure_nginx_proxy(webmail_domain)
- if not proxy_res.get('success'):
- warning = proxy_res.get('error')
-
- if not public_url:
- public_url = f'http://localhost:{cls.HOST_PORT}'
-
- result = {
- 'success': True,
- 'message': 'Roundcube installed successfully',
- 'port': cls.HOST_PORT,
- 'url': public_url,
- }
- if warning:
- result['warning'] = warning
- return result"""
-)
-
-# 6. email.py - pass domain to roundcube install
-replace_in_file(
- '/opt/serverkit/backend/app/api/email.py',
- """ result = RoundcubeService.install(
- imap_host=data.get('imap_host', 'host.docker.internal'),
- smtp_host=data.get('smtp_host', 'host.docker.internal'),
- )""",
- """ result = RoundcubeService.install(
- imap_host=data.get('imap_host', 'host.docker.internal'),
- smtp_host=data.get('smtp_host', 'host.docker.internal'),
- domain=(data.get('domain') or '').strip() or None,
- )"""
-)
-
-# 7. python_service.py - Django ALLOWED_HOSTS
-replace_in_file(
- '/opt/serverkit/backend/app/services/python_service.py',
- """ # Create .env file
- env_content = f'''DEBUG=False
-SECRET_KEY={secrets.token_hex(32)}
-ALLOWED_HOSTS=localhost,127.0.0.1
-'''
- with open(os.path.join(app_path, '.env'), 'w') as f:
- f.write(env_content)""",
- """ # Build ALLOWED_HOSTS: local addresses plus the panel domain and its
- # subdomains so Django accepts requests behind nginx on a real domain.
- from app.services.site_domain_service import SiteDomainService
- allowed_hosts = ['localhost', '127.0.0.1']
- panel_origin = SiteDomainService.panel_origin()
- if panel_origin:
- from urllib.parse import urlparse
- panel_host = urlparse(panel_origin).hostname
- if panel_host:
- allowed_hosts.append(panel_host)
- # Permit subdomains of the panel domain (e.g. app.serverkit.example.com)
- if '.' in panel_host:
- allowed_hosts.append('.' + panel_host)
- allowed_hosts_str = ','.join(allowed_hosts)
-
- # Create .env file
- env_content = f'''DEBUG=False
-SECRET_KEY={secrets.token_hex(32)}
-ALLOWED_HOSTS={allowed_hosts_str}
-'''
- with open(os.path.join(app_path, '.env'), 'w') as f:
- f.write(env_content)"""
-)
-
-# 8. environment_domain_service.py - fallback
-replace_in_file(
- '/opt/serverkit/backend/app/services/environment_domain_service.py',
- """ if not production_domain:
- # Fallback for sites without a domain
- slug = cls.slugify(branch_name) if branch_name else env_type
- return f'{env_type}-{slug}.localhost'""",
- """ if not production_domain:
- # Fallback for sites without a domain: use the managed-sites base domain
- # or the panel domain instead of a useless .localhost address.
- from app.services.site_domain_service import SiteDomainService
- base = SiteDomainService.base_domain() or SiteDomainService.panel_origin()
- if base:
- from urllib.parse import urlparse
- base_host = urlparse(base).hostname or base
- slug = cls.slugify(branch_name) if branch_name else env_type
- return f'{env_type}-{slug}.{base_host}'
- # Last resort only when absolutely no domain is configured
- slug = cls.slugify(branch_name) if branch_name else env_type
- return f'{env_type}-{slug}.localhost'"""
-)
-
-print('All backend patches applied.')