Feelcouch ProjectsHandbook · v1.47.0

Product

Feelcouch platform: corrected architecture and redesign proposal

Read-only source review, 30 September 2026. This supersedes the earlier interpretation of the platform as merely a demo. Feelcouch SaaS is the owner's product; the psychologist's course is one tenant. No repository edits, merges, deployment, live authentication attempts or heavy tests were performed. Image ae44e63 was supplied as context and was not independently inspected or matched to live ingress configuration.

Final surface map

Host Purpose Audience Root behavior
feelcouch.tech Public family/project hub Everyone Existing hub; no SaaS card, link, name or navigation entry. Generic project-creation copy is allowed.
saas.feelcouch.tech Beautiful public direct-link SaaS showcase Anyone with the direct URL Existing showroom/product page, redesigned. No real operator entry.
psicho.feelcouch.tech Friend's tenant/course Its participants and staff Existing tenant login/Today/staff flows; preserve course identity and operation.
lagrange.feelcouch.tech Lagrange product Public product audience Existing product site.
status.feelcouch.tech Anonymous global service health Everyone Existing status page adapted to connected services/tenant aggregate.
admin.feelcouch.tech Real private platform operation Explicitly provisioned real operators Actual login or operator console; never public demo identity.

No SaaS links in the hub, public family navigation, Lagrange footer or public status navigation. Direct-link does not mean confidential; noindex can reduce indexing but is not access control. Keep the exact spelling admin.

Immediate priority: prevent demo-to-operator access

Confirmed in the optional SaaS worktree the optional hosted-demo worktree:

  1. components/projects-demo/saas-role-launcher.tsx in the staged product exposes a role admin form to demoLogin.
  2. Worktree app/actions/auth.ts::demoLogin accepts that role, selects DEMO_ADMIN_USERNAME with role: ADMIN, isDemo: true, calls the normal setSession, and redirects to /admin.
  3. Worktree lib/platform/admin-gate.ts::canAccessPlatformAdmin has a hosted-preview branch granting access to an active unblocked actor.role === ADMIN && actor.isDemo on the configured preview request.
  4. Worktree canAccessPlatformAdminRequest supplies that actor from the tenant database getCurrentUser.

That is a code-level authorization path from public demo selection into the component/API namespace intended for platform operation. It violates the requested boundary even if many console tabs currently contain synthetic rows. It is not evidence that the live production host is presently exposed; effective deployment and ingress were not inspected.

Main checkout is different: lib/platform/admin-gate.ts checks production host dev.feelcouch.tech plus x-feelcouch-admin-gate secret; app/admin/page.tsx and app/api/platform/admin/operations/route.ts depend on this gate. It does not authenticate a platform identity in the application. components/site-header.tsx::roleLabel also calls tenant role ADMIN “Operator”, incorrectly conflating two roles.

Do first: deny /admin, /admin/* and /api/platform/admin/* on every public/demo/tenant host. Remove the hosted-preview ADMIN exception. Remove real admin links from SaaS navigation/role launcher; the existing client-side AdminPreview can remain, explicitly named “Project management preview”. It must never mint an operator session. Cover the API and every future operator server action, not just a hidden link or page layout.

What authentication actually exists

Capability Source evidence Status and reuse
Telegram Mini App signed-data validation lib/telegram/initData.ts::validateInitData; lib/telegram/authenticate.ts::authenticateTelegram Real existing tenant authentication. Reuse signature/age validation for a separately configured platform login; do not reuse tenant ADMIN as permission.
Telegram authentication endpoint app/api/telegram/auth/route.ts Existing trusted-origin check, bounded input, rate limiting, authentication and session issuance. Tenant-specific destination/invitation logic must not become operator provisioning.
Signed session primitive lib/auth/session.ts::createSessionToken, verifySessionToken Real HMAC token with issue/expiry; current cookie is tenant identichnost_session, host-only because no Domain is set. Reuse the mechanism, not its identity namespace/secret/cookie.
Real username/password at ingress compose.dev.yaml, scripts/deploy-dev.sh Existing Caddy username and bcrypt-hash secret configuration; deploy checks expect anonymous /admin to receive 401. This is a real password boundary, not an in-app login form. Effective generated Caddy config was not reviewed.
In-app username/password Examined tenant/platform schemas and auth modules Not found. Do not label email links or demo role buttons as password authentication.
Email/recovery login Optional worktree lib/auth/email-auth.ts, app/login/email/page.tsx Email magic-link challenges and recovery codes, with hosted demo-mailbox restrictions. Not password auth and not platform operator enrollment.
Platform operator registry/session prisma/platform/schema.prisma currently contains Tenant metadata only Dedicated operator membership/session authorization was not found in this review. Needs a small explicit addition or private configured allowlist; no self-registration.

Smallest secure rollout

Step A: contain access immediately. Separate admin.feelcouch.tech ingress; reuse real Caddy Basic Auth with the owner's provisioned username and bcrypt hash, TLS and secrets files. The app only accepts the admin host and a trusted assertion injected after successful ingress authentication. Strip inbound copies of every assertion header, deny direct public app access, and overwrite forwarded host. This can provide real password-protected operator access without inventing an application password subsystem. Do not call the current browser password dialog a polished login page.

Step B: deliver the requested friendly choice, Telegram OR username/password. Add a small platform-specific login/session adapter. Keep the existing tenant auth unchanged. For Telegram, validate current platform-bot initData and map the numeric Telegram ID to explicitly provisioned platform operators; never trust a submitted username or tenant role. For password, either use a real app credential verifier with modern password hashing or let a narrowly scoped Caddy-authenticated password endpoint exchange its verified identity for the same operator session. The latter reuses the existing password secret and needs no public registration/reset product.

Both methods produce a dedicated host-only __Host-feelcouch-operator cookie with Secure, HttpOnly, Path=/, SameSite and a separate signing secret/audience. Validate current operator membership/disabled state on every protected request. The current token primitive does not encode an audience; extend it in a separate platform helper or bind it cryptographically through a separate key and strict platform-only resolver. Do not spread an operator cookie to .feelcouch.tech. Keep tenant/demo session cookies incapable of satisfying the operator guard.

Centralize requirePlatformOperator(request) for page, APIs and server actions: exact trusted admin host → valid dedicated operator session → active explicit operator → scoped action. Origin/CSRF protection, failed-login throttling and redacted auth audit apply to both methods. If Caddy asserts an authenticated username, the app must verify the protected proxy channel/header secret before accepting it; an untrusted client header is not identity.

A fully branded password form and dual-method session are proposed new work, not currently implemented. If both methods are required at initial public launch, complete Step B before presenting either as a finished product. There is no need for an external IdP, extra auth service or tenancy rewrite.

Access matrix

Actor SaaS showcase Own tenant Course /f/access Public status Real operator UI/API Privileged health details
Anonymous Read/click synthetic preview Existing login only No Aggregate only Login only on admin host No
Demo visitor Synthetic preview/isolated demo data Demo only Only existing isolated course-admin demo, if deliberately provided Aggregate only Never No
Customer participant Showcase if linked directly Own scoped participant features No Aggregate only No No
Customer facilitator Showcase if linked directly Managed groups No unless course ADMIN Aggregate only No No
Course ADMIN Showcase if linked directly Tenant-wide course administration Existing permission Aggregate only No No global details
Platform operator Showcase No implicit diary access; any support action must be explicit and audited Not automatically a tenant identity Aggregate Authenticated admin host only Yes, operational scope

Do not expose personal course content, private diary counts or tenant database credentials in operator health. The friend's functioning tenant must not gain new entitlement restrictions as part of this correction.

Separate hosts with minimal routing changes

Paths alone would be the smallest mechanical change, but would leave public demo and private operator login visually adjacent and invite future permission confusion. Use the user's selected separate hosts and retain existing internal Next routes. This adds host routing, not new applications.

External URL Existing internal route to reuse Notes
saas.feelcouch.tech/ /saas staged or /projects-demo Product hero plus interactive previews. /projects-demo, /docs, /api-docs remain under SaaS host as needed.
admin.feelcouch.tech/ /admin Public unauthenticated request sees actual login; protected response never returns console data.
admin.feelcouch.tech/login New small platform-login UI Avoid tenant demo /login; safe local returnTo only.
admin.feelcouch.tech/api/platform/admin/* Existing operator APIs Every handler enforces real operator guard.
status.feelcouch.tech/ /status Aggregate public screen.
status.feelcouch.tech/api/platform/status Existing public status route Stable anonymized contract/cache.
psicho.feelcouch.tech/* Existing tenant routes Existing tenant database/role, Telegram bot, sessions and course identity.

Caddy should rewrite only the exact root for each surface, preserve path/query/assets and deny mismatched administrative paths on all other hosts. Or use one explicit server host-to-surface resolver in the existing root/layout; do not blindly change Host to force tenant selection. Set a small trusted surface value from an allowlisted host mapping and use it for header/root selection. Server-side auth remains authoritative even if ingress is bypassed internally.

Same repository and immutable image digest can run multiple configured instances/containers with existing deployment templates. One image does not require one process or one database connection. Reuse compose.tenant.base.yaml, lib/tenancy/registry.ts, lib/tenancy/provisioning.ts and the current control-plane Tenant table. Tenant data stays in separate databases with least-privilege roles; control-plane metadata remains separate. Never pick a database from unchecked browser input, give a showcase tenant the platform database role, or introduce a friend's code fork. Existing image promotion/rollback workflow stays intact.

Status: reuse aggregation, fix scope and uncertainty

Existing lib/monitoring/probe-history.ts and /api/platform/status already produce grouped live status without individual tenant identity. Staged lib/monitoring/tenant-health.ts::getTenantHealthAggregate returns only healthy/total from recent tenant:* observations. Good starting point; it does not prove that every connected site is probed. Register/check all approved connected services privately, preferably from the existing tenant registry and explicit product-service manifest, and publish only safe groups, counts, history and freshness.

The staged lib/monitoring/public-probes.ts currently targets saas.feelcouch.tech/api/platform/admin/operations. After separation this is the wrong host. A public 401/403 proves the boundary responds, not that private operational data is healthy. Keep a private synthetic authorized probe or a separate safe readiness probe for operator service health; do not label a refused public request as end-to-end operational success.

Staged aggregate catches database failure and returns the same zero rows as no observations. Preserve explicit unknown/stale/unavailable freshness so an outage does not become “0 connected tenants” or healthy. Public output must not expose hostnames, tenant names, IDs, rollout cohorts or raw diagnostics. Detailed per-site probes, errors, latency and operational events belong on admin host behind requirePlatformOperator. The public status header must not resolve/show a tenant person's account or link to SaaS/admin.

SaaS redesign: a useful showroom, not an administration doorway

Reuse existing components/projects-demo/projects-demo.tsx: template selection, participant/admin/automation preview, branding and module preview already exist. The new page should curate these into a clear progression instead of presenting a dense generic SaaS console, small technical labels and a grid of unrelated destinations.

Visual direction: Feelcouch family canvas, calm ink/spruce palette, restrained serif display headings and legible system-font controls; generous whitespace and one working preview as the dominant object. Keep course Ψ/author identity inside its own tenant preview; platform branding should be Feelcouch. Both light/dark, visible focus, 44px targets, no ambient animation or heavy illustration/video dependency. Preserve tenant accent customization.

saas.feelcouch.tech — direct URL only

Feelcouch                  Возможности   Шаблоны   Документация

Ваш проект — в одном пространстве.
Участники, контент, сообщения и работа команды.
[ Попробовать возможности ]       [ Посмотреть шаблоны ]

Один конкретный рабочий пример             Что можно проверить
┌─────────────────────────────────────┐   • Запись и приватность
│ Участник | Команда | Автоматизация   │   • Программа и встречи
│ Реально переключаемый preview       │   • Уведомления/рассылки
│ Демо-данные, локальные изменения     │   • Внешний вид проекта
└─────────────────────────────────────┘

Шаблоны под разные задачи — существующие 10, без новой инфраструктуры
Что работает сейчас / что только показано в демо
Документация · API · status.feelcouch.tech

The word “Команда” in a preview means customer project management. A marketing preview may show synthetic project administration but never a real operator role switch or /admin link. Preserve exact descriptions of email/demo-mailbox, payment and provisioning stubs. No “create a production project” or “pay now” claim until that backend is real.

admin.feelcouch.tech — private

Feelcouch / Управление платформой
Вход для операторов
[ Войти через Telegram ]
или
Имя пользователя [__________]
Пароль            [__________]
[ Войти ]

After actual authentication:
Клиенты/проекты | Состояние | События | Релизы | Данные | Настройки
Actual data source + freshness. No tenant-role selector, no demo sign-in.

status.feelcouch.tech — public
Состояние сервисов       Обновлено ...
Публичные продукты / Клиентские приложения / Доставка сообщений
State + recent history + safe totals; no private names or hostnames.

Ordered implementation tasks with exact reuse points

  1. P0 auth containment: lib/platform/admin-gate.ts, app/admin/page.tsx, all app/api/platform/admin/*, optional app/actions/auth.ts, components/projects-demo/saas-role-launcher.tsx, Caddy/generated upstream rules. Remove demo permission path and deny wrong hosts. Tests: anonymous, demo ADMIN and course ADMIN cannot open operator UI/API; spoofed host/gate headers fail; real ingress credential succeeds only on admin host.
  2. Surface/nav mapping: existing app/page.tsx, components/site-header.tsx, components/platform-ui/site-header.tsx, site-nav.ts, Caddy config. Add trusted host-aware root/header selection, replace tenant ADMIN → Operator label, keep SaaS absent from hub/family nav. Test the six host/root combinations, assets and old internal routes; no open redirect or cross-host cookie sharing.
  3. Real operator login: new bounded platform-auth helper/login UI plus reuse validateInitData, token crypto, rate-limit and trusted-origin modules. Start with provisioned real Caddy password if speed is essential; complete Telegram OR password app session explicitly. Add operator allowlist/metadata separate from tenant User role; if schema changes are needed use the repository's current approved migration/expand contract. Test expired/tampered/different-audience sessions, revoked operator, wrong Telegram ID, brute-force throttling and logout. Do not issue admin sessions from demo/email test mailbox.
  4. Global status: existing status page, public status API, probe-history, staged tenant-health/public-probes, monitoring registry. Correct admin hostname and authorized readiness meaning, add connected services and unknown/freshness distinction, private details under operator gate. Tests: no private fields, stale/missing samples distinguishable, all configured services represented internally, public output aggregate only.
  5. SaaS redesign: staged /saas/page.tsx, existing showroom, platform UI recipes and versioned catalogs. Implement the wireframe using actual preview capabilities; shrink JS through server-rendered hero/catalog and one isolated interactive preview. No new font/motion/carousel dependency. Test mobile/light/dark/keyboard/reduced motion and each real preview flow; no public operator link or fake live integration.
  6. Promotion verification: verify actual image/config before any publication. Same immutable runtime digest, correct database/role per deployment, friend tenant auth/course unchanged, no new entitlements on friend, rollback remains available. This report does not authorize or perform promotion.

Actual, proposed and incomplete

Actual: shared runtime; separate tenant registry/DB roles; tenant Telegram auth and signed sessions; Caddy password-secret provisioning; course flows; template/role previews; synthetic operator snapshots; protected operational-events endpoint; public grouped status.

Proposed: final admin/status host separation; dedicated operator membership/session and two-method branded login; curated SaaS redesign; all-connected-sites monitoring completeness; host-specific public navigation with SaaS deliberately absent from hub.

Incomplete/stubs: in-app username/password; real control-plane operator enrollment; most operator action surfaces; preview commerce/provisioning; demonstrated coverage of every live site. No production benchmark or live security conclusion was made. Existing source limits and small stable components are enough; no major platform rebuild is necessary.