rsocials-online/backlog/tasks/task-2 - Multi-tenant-provi...

36 lines
2.0 KiB
Markdown

---
id: TASK-2
title: Multi-tenant provisioning platform
status: Done
assignee: []
created_date: '2026-02-24 03:54'
updated_date: '2026-02-25 05:30'
labels: []
dependencies: []
priority: medium
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
Self-service API for communities to provision their own Postiz instance at <space>.rsocials.online. CRDT token gating, x402 micropayment metering, Sablier hibernation. Full plan at ~/.claude/plans/greedy-skipping-dahl.md. Phases: 1) Provisioning API Core, 2) CRDT Token Gating, 3) Landing Page + Provision UI, 4) x402 Usage Metering, 5) Sablier + Hardening.
<!-- SECTION:DESCRIPTION:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
Starting Phase 1: Provisioning API Core (Hono/Bun)
Phase 1 complete: Provisioning API scaffold with all core services. Compiles clean, starts on port 3001. Next: Phase 2 (CRDT token gating) or deploy Phase 1 to Netcup for testing.
Phase 2 complete: SIWE wallet auth + CRDT token gate + x402 middleware ported. Sablier removed (breaks scheduled posts). Auth supports both API key (admin) and wallet SIWE. Token gate configurable via CRDT_GATE_ENABLED env var.
Phase 3 complete: Provision wizard at /provision (wallet connect → subdomain picker → confirm → deploy). Dashboard at /dashboard (instance list, status, delete). wagmi + viem + react-query integrated. Navbar updated with Deploy + Dashboard links.
Phase 4 complete: Usage metrics service (Docker container stats, PG post count, volume storage). Billing calculator with pro-rated monthly base ($5), per-post ($0.01), per-GB storage ($0.50 above 1GB free). Usage + payment routes wired. x402 middleware applied to POST /v1/spaces when X402_PAY_TO is set.
Phase 5 complete: In-memory rate limiter (general 10/min, provision 2/hour, admin bypass). Admin routes: force teardown, suspend/resume. Dockerfile hardened: non-root user, healthcheck, NODE_ENV=production. Suspended status added to types + frontend.
All 5 phases implemented. Ready for deployment to Netcup.
<!-- SECTION:NOTES:END -->