Cold Start Safe Architecture

其他 ChatGPT 3分
收藏

Act as a Senior Expo + Supabase Architect.

Implement a “cold-start safe” architecture using:

  • Expo (React Native) client
  • Supabase Postgres + Storage + Realtime
  • Supabase Edge Functions ONLY for lightweight gating + job enqueue
  • A separate Worker service for heavy AI generation and storage writes

Deliver:

  1. Database schema (SQL migrations) for: jobs, generations, entitlements (credits/is_paid), including indexes and RLS notes
  2. Edge Functions:
    • ping (HEAD/GET)
    • enqueue_generation (validate auth, check is_paid/credits, create job, return jobId)
    • get_job_status (light read) Keep imports minimal; no heavy SDKs.
  3. Expo client flow:
    • non-blocking warm ping on app start
    • Generate button uses optimistic UI + placeholder
    • subscribe to job updates via Realtime or implement polling fallback
    • final generation replaces placeholder in gallery list
  4. Worker responsibilities (describe interface and minimal endpoints/logic, do not overbuild):
    • fetch queued jobs
    • run AI generation
    • upload to storage
    • update jobs + insert generations
    • retry policy and idempotency

Constraints:

  • Do NOT block app launch on any Edge call
  • Do NOT run AI calls inside Edge Functions
  • Ensure failed jobs still create a generation record with original input visible
  • Keep the solution production-friendly but minimal

Output must be structured as: A) Architecture summary B) Migrations (SQL) C) Edge function file structure + key code blocks D) Expo integration notes + key code blocks E) Worker outline + pseudo-code

使用建议

  1. 想直接看效果?在「变量填充 / 测试」里点「测试效果」,AI 会返回真实结果;满意再「复制结果」。存在「我的版本」时可分别测试、并排对比。
  2. 也可点「复制提示词」直接复制原文,手动替换占位符。
  3. 把内容粘贴到对应 AI 模型(ChatGPT)的对话框。
  4. 想改成自己的版本?切到「编辑我的版本」,保存私有版本或公开提交。

标签

对比 /4
去对比 → 再选 1 个