18 Commits

Author SHA1 Message Date
karim 0daf6c393d feat(backup): Konzept (BACKUP.md) + backups-Datenmodell (0004)
Backup-Übersicht/Restore bewusst NICHT als Fake-UI gebaut — im Mock gäbe es
keine echten Kundendaten. Stattdessen:
- 0004_backups.sql: Register-Tabelle (Metadaten: instance/account, trigger,
  status, storage_key, size, sha256, Zeitstempel). Dump-Dateien liegen extern.
- BACKUP.md: Konzept für Modell A (studio-bezogener Export statt Full-Dump),
  Erzeugung (pg_dump/cron/Storage/Rotation), Restore-Sicherheitsregeln,
  geplante API. Bau der Logik, sobald echtes Provisioning steht.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 13:09:53 +02:00
karim ddc04796d5 fix(admin): pastDueSubscriptions ins stats-JSON (Feld hatte gefehlt)
Der Edit im vorigen Commit (7c100e9) hatte die const angelegt, das Feld aber
nicht in die Antwort gehängt → pastDue war im Frontend undefined.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 12:54:37 +02:00
karim 7c100e98fa feat(admin): Zahlungsausfaelle + Instanz-Health-Check
- /admin/stats: pastDueSubscriptions (Abos mit fehlgeschlagener Zahlung)
- /admin/health: pingt aktive Instanz-URLs (HEAD, 4s Timeout) -> up/down;
  im MOCK-Modus ehrlich 'unknown' statt fake 'up'

E2E: past_due fliesst in stats, health gibt im Mock 'unknown'.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 12:47:22 +02:00
karim fb89094b63 feat(billing): Stripe-Code vollständig (Checkout, Portal, Webhooks) — Keys später
- /checkout: Subscription-Session (Karte), Customer-Wiederverwendung, locale de,
  Metadata auf Session+Subscription. TWINT bewusst weg (Stripe: nur Einmalzahlung).
- /portal: Stripe Customer Portal (kündigen/Karte/Rechnungen); Mock → /konto/.
- Webhook: + customer.subscription.updated (Status/Periode spiegeln, Instanz
  sperren/reaktivieren) + invoice.payment_failed (→ past_due).
- .env.example: Stripe-Setup-Anleitung; ADMIN_EMAIL→ADMIN_PASSWORD korrigiert.

Alles MOCK-fähig (CHANGE-ME → kein echtes Stripe). Echt-Test erst mit Keys.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 12:29:55 +02:00
karim 6471221dec feat(admin): CSV-Export der Kunden für die Buchhaltung
GET /admin/export/accounts.csv — eine Zeile pro Kunde (Profil + aktuelles
Abo + Plan-Preis + Instanzen). Semikolon-getrennt, UTF-8 BOM (Excel-CH),
Content-Disposition mit Datum. Nur mit Admin-Token (401 sonst).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 12:15:56 +02:00
karim 4d45cdcba3 feat(admin): erweiterte Kennzahlen + Kunden-Detail-API
- /admin/stats: newAccounts30d, suspendedInstances, ARR, byPlan (count+revenue)
- /admin/accounts/🆔 Voll-Detail (Profil + Abo-Historie + Instanzen, Plan-Preis)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 12:00:03 +02:00
karim 540dd9df5b refactor(admin): separates Admin-Login statt is_admin-Flag
Auf Wunsch: Betreiber-Bereich getrennt von Kundenkonten.
- auth.js: signAdminToken (role:operator), requireAdmin prüft Token-Rolle;
  requireAuth weist Operator-Token ab (saubere Trennung beide Richtungen)
- routes/admin.js: POST /admin/login (ADMIN_PASSWORD → Operator-Token)
- env.js: adminPassword statt adminEmail
- 0003_admin.sql: droppt die nicht mehr genutzte accounts.is_admin-Spalte
- register/login/account/me: is_admin restlos entfernt

E2E: Kunde→403, falsches PW→401, richtiges PW→Token, stats→200,
Admin-Token→Kundenroute→401.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 10:43:47 +02:00
karim 2d850638f2 fix(auth): is_admin in register/login wirklich setzen
Die Edits im Admin-Commit (6a23933) hatten nicht gegriffen — register/login
gaben is_admin nicht zurück (war undefined). Jetzt: returning …, is_admin +
ensureAdminFlag bei beiden. E2E verifiziert: Admin-Promotion=true, Kunde→403,
Stats korrekt (2 Kunden/MRR 49).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 00:09:03 +02:00
karim 6a2393301d feat(admin): Betreiber-Panel (/api/admin) mit is_admin-Flag
- 0003_admin.sql: accounts.is_admin
- auth.js: ensureAdminFlag (Konto = ADMIN_EMAIL wird auto-promoted),
  is_admin im JWT, requireAdmin-Middleware (prüft DB autoritativ)
- routes/admin.js: GET /stats (Kunden/Abos/Instanzen/MRR), GET /accounts,
  GET /accounts/:id/instances, POST /instances/:id/{suspend,reactivate}
- register/login + /account/me liefern is_admin
- ADMIN_EMAIL in .env.example

E2E: Admin-Promotion, Kunde→403, Stats (2 Kunden/MRR 49), Kundenliste.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 00:04:19 +02:00
karim 7e38fc68bd feat(account): Profil-Felder, Instanz-Liste, Profil-Update + Passwort ändern
- 0002_account_profile.sql: company/contact_name/adresse/phone + instances.label
- GET /account/me: alle Profilfelder + instances[] (Multi-Instanz vorbereitet),
  instance einzeln bleibt rückwärtskompatibel
- PATCH /account/me: Profil aktualisieren (Whitelist)
- POST /account/password: Passwort ändern (prüft aktuelles PW → 403 sonst)

E2E verifiziert: Profil speichern, PW-Wechsel (falsch=403/richtig=200),
instances[]=1 nach Checkout.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 23:57:17 +02:00
karim 38ce58dc2f feat(provisioning): echtes Modell-A-Provisioning via create_studio_for_user
studio-adapter ruft jetzt den neuen service_role-RPC (APP 0011): Auth-User
anlegen (oder bei 422 bestehenden holen) → create_studio_for_user → Instanz-URL.
MOCK-Modus bleibt für lokalen Test ohne Rapport-Stack.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 23:16:07 +02:00
karim 37d49f115f fix(build): website immer frisch bauen (rm -rf public resources + --gc)
Ursache des ungestylten Hosting-Frontends war ein veraltetes public/:
der Build überschrieb fingerprinted CSS nicht, sodass die neuen .hosting-*
Klassen nie ausgeliefert wurden. Clean-Build verhindert das. (Auch doppelte
build:website-Zeile entfernt.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 16:53:53 +02:00
karim 2755b3b293 cleanup: obsolete Frontend-Reste entfernt (src/, index.html, vite.config.js, stale lock)
git rm im vorigen Commit brach am fehlenden marketing/ ab, daher waren die
React-Dateien noch im Repo. RAPPORT-HOST ist jetzt wirklich reines Backend.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 16:45:09 +02:00
karim 13173dddc5 refactor: RAPPORT-HOST ist jetzt reines Backend
Das Frontend (Marketing + Login/Konto) ist in RAPPORT-WEBSITE umgezogen
(Hugo + Vanilla-JS). RAPPORT-HOST liefert dessen gebautes public/ statisch
aus und stellt /api bereit.

- server/index.js: serviert RAPPORT-WEBSITE/public + /api (eine Origin)
- server/env.js: websitePublicDir (WEBSITE_PUBLIC_DIR, Default Schwester-Repo);
  PUBLIC_BASE_URL Default auf einheitliche Origin :8787
- billing.js: Checkout-Redirects auf /konto/ bzw. /hosting-preise/
- entfernt: src/ (React), marketing/ (Hugo-Kopie), index.html, vite.config.js
- package.json: nur noch server/migrate/build:website-Scripts

E2E verifiziert: /, /hosting/, /login/, /konto/, /js + Font = 200;
register→checkout(mock)→Instanz; Redirect → /konto/?provisioned=1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 16:41:09 +02:00
karim 07485024cd design: echte RAPPORT-WEBSITE-Tokens + Krungthep-Font übernommen
Aus RAPPORT-WEBSITE/assets/css/custom.css (Hextra-Overrides):
warmes Beige-Grau (#ece9e3), Krungthep-Brand (lokal gebundelt),
Inter-Body, Braun-Akzent #b07848. Hero an Hextra-Home angelehnt.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 16:20:48 +02:00
karim bd37b7f8bc design: HOST-Frontend an rapport.openbureau.ch angeglichen
Echte Design-Tokens aus dem openbureau-Stylesheet übernommen:
- weißer Grund (#fff), warme Off-Whites (#fafafa/#fff8f0)
- near-black Text (#1a1a1a), warmes Braun als Akzent (#b07848)
- System-Font-Stack (-apple-system…) + SF Mono, Brand Krungthep
- Hero-CTA in Akzent-Braun, dunkle Sekundär-Buttons

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 16:11:57 +02:00
karim 4b96e1a6b0 fix: Platzhalter-Keys nicht als echt werten + Crash-Schutz
- env.js: '…CHANGE-ME'-Platzhalter aus .env.example zählen als NICHT gesetzt.
  Vorher galt sk_test_CHANGE-ME als echter Stripe-Key → echter API-Call mit
  ungültigem Key → 401 → unhandledRejection → Server-Crash.
- billing.js: /checkout in try/catch → 502 statt Empty-Reply/Crash.
- index.js: globaler Express-Error-Handler + unhandledRejection-Guard, damit
  ein einzelner async-Fehler nie den ganzen Prozess killt.

E2E verifiziert (Mock): register→checkout→instance, idempotent (1 sub/1 inst),
401 bei falschem PW, Server lebt nach allen Requests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 15:49:47 +02:00
karim 6290475ea3 Initial: RAPPORT-HOST Iteration 1 (proprietär)
Kommerzielle Hosting-/Abo-Plattform für Rapport-Instanzen.

- React-Frontend (Vite/JSX): Landing, Register, Login, Plans, Dashboard
- Node/Express-Backend: Auth (bcrypt+JWT), Stripe-Billing, Provisioning
- HOST-Postgres-Schema: accounts, subscriptions, instances
- Provisioning-Interface + Modell-A-Adapter (Studio im geteilten Stack)
- MOCK-Modus: voller End-to-End-Flow ohne Stripe/Rapport-Stack testbar
- Idempotentes Fulfillment (Upsert auf stripe_subscription_id)
- docker-compose für lokale host-db; identisch auf Hetzner deploybar

E2E lokal verifiziert: Register -> Checkout(mock) -> Instanz -> Idempotenz.

Lizenz: proprietär (kein AGPL-Code eingebunden, nur Netzwerk-API zur Familie).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 15:37:33 +02:00