Main flow map
Auth and basic onboarding flow
The user signs up or logs in
/auth/login or /auth/sign-up.Supabase creates or verifies the session
/auth/confirm.Database triggers create the baseline user data
auth.users, migrations also prepare default rows in profiles, subscriptions, and user_roles.Login-aware product areas read session claims
- Supabase public env,
- redirect URLs,
- the
/auth/confirmcallback, - admin access rules in
user_roles.
Checkout to active subscription flow
The user chooses a plan in dashboard billing
config/subscriptions.ts.The client calls POST /api/payments
payments row with PENDING status.The server creates a provider checkout session
The user completes payment in the provider flow
/order/[id] or the fallback /payment/callback.The provider calls the webhook
webhook_events, and updates the payment status.The subscription becomes active
PAID, the webhook route activates or updates subscriptions. An audit log is also written.paymentssubscriptionswebhook_eventsaudit_logs
Profile and avatar flow
The user opens dashboard settings
The client requests a signed upload URL
POST /api/profile/avatar receives fileSize and fileType, then returns an upload token if valid.The browser uploads the file to the avatars bucket
${userId}/avatar inside Supabase Storage.The client saves the avatar reference back to the profile
POST /api/profile updates full_name, avatar_path, and avatar_url.The old avatar is cleaned up
- auth is not available,
SUPABASE_SERVICE_ROLE_KEYis not ready for the relevant writes,- file size is too large,
- the MIME type is not supported.
Waitlist and contact flow
Waitlist
Waitlist
- the user submits email in
/waitlist, POST /api/waitlistpasses through IP-based rate limiting,- the payload is validated,
- the row is inserted into
waitlist, - duplicate email attempts return a response the UI can handle.
Contact form
Contact form
- the user submits name, email, and message in
/contact, POST /api/contactpasses through IP-based rate limiting,- the payload is validated,
- the server sends email through Resend,
- the destination inbox is taken from
CONTACT_EMAILor falls back toEMAIL_FROM.
AI request flow
The client calls an AI route
POST /api/ai/chat or POST /api/ai/generate.The server authorizes the request
Rate limiting is applied
The request goes to the selected model
Usage is recorded
ai_usage.401usually means the user is not authenticated,429can mean request rate limit or monthly usage limit,503usually means the AI provider is not configured.