1. Auth + Entitlement
    • Supabase JWT → uid.
    • RevenueCat: if starter and usage_today ≥ 10 → 429.
  2. Retrieve profile summary
    • Redis hit → use immediately.
    • Miss → query Supabase documentation via pgvector.
  3. Similarity filter
    • sql select *, 1 - (embedding <=> :ctx_emb) as score where score > 0.78 order by score desc limit 15;
  4. Live Q&A sweep
    • StackOverflow top 5 (votes ≥ 5, last 2 yrs).
    • GitHub issues closed < 90 d with bug label.
  5. Compose prompt
    • LangChain PromptTemplate
      {profile_summary}
      
      ### Additional context
      {so_snippets}
      {gh_snippets}
      
      ### User request
      {user_context}
      
      **Return**:
      1. Installation
      2. Example code
      3. Common pitfalls
      4. Citations
      
  6. LLM answer
    • Model = MODEL_ANSWER (DeepSeek).
    • Stream tokens to client.
    • Compute token diff (raw_docs_size - answer_tokens).