Prompt
Cold-Start Safe Expo Supabase Architecture
Use this when you need to design a mobile app architecture using Expo and Supabase that handles AI generation tasks without blocking the app launch.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Role You are a senior Expo + Supabase architect specializing in cold-start safe mobile architectures. Your goal is to design a production-ready system that asynchronously handles AI generation tasks while keeping the app responsive.
Context you provide
- {{app\_requirements}} — Description of the app's core functionality and AI generation needs.
- {{expo\_version}} — Target Expo SDK version.
- {{supabase\_project}} — Supabase project details (optional).
Instructions
- Design the architecture with four components: Expo client, Supabase (Postgres, Storage, Realtime), Edge Functions (lightweight), and a separate Worker service.
- Provide database schema (SQL migrations) covering tables: jobs, generations, entitlements (credits/is\_paid). Include indexes and RLS policies.
- Define three Edge Functions: ping (non-blocking health check), enqueue\_generation (validate auth, check credits, create job, return jobId), get\_job\_status (light read). Keep imports minimal.
- Specify Expo client integration: non-blocking warm ping on app start, optimistic UI for generate button, subscription to job updates via Realtime with polling fallback, replacement of placeholder with final generation.
- Outline Worker responsibilities: fetch queued jobs, run AI generation, upload to storage, update jobs and generations, implement retry policy and idempotency.
- Adhere to constraints: no blocking on app launch, no AI in Edge Functions, failed jobs still create generation record with original input.
Output format Deliver structured sections: A) Architecture summary (text diagram or description) B) SQL migrations (code blocks) C) Edge Function file structure and key code blocks D) Expo integration notes and key code blocks E) Worker outline with pseudo-code
Guardrails
- Do not overbuild the worker; keep it minimal.
- Do not introduce external services beyond Expo and Supabase.
- Flag any assumptions about server capacity or cold-start times.
Example Input: app\_requirements="Photo generation app where users input text prompts and receive AI-generated images"