Backend
- Supabase project:
scritorio - Project ref:
pyglmeehohtpjimgiuyz - Region:
us-east-1 - Organization:
kevin-personal-assistant-data
Desktop Environment
The desktop app only needs public Supabase config:Account And Authorization
Supabase Auth handles account creation, login, session refresh, and access tokens. The desktop app uses the Supabase publishable key to create an account, sign in, load the current user, update the user’s profile, and call authenticated backend surfaces. Server-side systems derive identity from the Supabase user id rather than from any client-provided user id. Supabase Postgres stores:profilesfor account profile displaybilling_customers,subscriptions,license_keys, andentitlementsfor paid account stateai_user_plansfor managed AI plan and quota periodsai_usage_eventsfor the managed AI usage ledger
Managed AI Gateway
Managed AI requests go through a Cloudflare Worker instead of direct desktop-to-OpenAI calls. The Worker verifies the Supabase access token, checksai_user_plans, sums ai_usage_events, calls OpenAI with Scritorio’s backend key, and writes a usage event. See Managed AI Gateway for the full runtime flow.
Lemon Squeezy Test Mode
Lemon Squeezy approval is not required for this integration pass. Test mode supports checkouts, subscriptions, webhooks, and license keys. Test-mode products, customers, and webhook settings are separate from live mode, so launch requires replacing IDs/secrets and configuring the live webhook endpoint. The first backend billing surface is the Cloudflare Worker webhook:LEMONSQUEEZY_WEBHOOK_SECRET as a Worker secret. Lemon Squeezy signs each webhook request with that secret; the Worker verifies the signature before logging the event to Supabase.
Entitlement Flow
- A signed-in desktop user clicks the account plan action.
- The desktop app will call a Scritorio API checkout endpoint.
- The Worker will create a Lemon Squeezy Test-mode checkout with
custom_data.user_id. - Lemon sends subscription and license webhooks to the Scritorio API webhook endpoint.
- The Worker verifies the webhook signature and writes a durable
billing_webhook_eventsrow in Supabase. - A later pass will process those logged events into billing, subscription, license, and entitlement rows.
- The desktop account panel refreshes and shows subscription, license, and entitlement state.
scritorio_pro.