Skip to content

Organize Flow code

This guide outlines best practices for organizing your pgflow codebase to improve maintainability, reusability, and clarity.

Following the pattern from Create Flow, organize flows and tasks in underscore-prefixed folders using Supabase’s pattern for shared code:

mkdir -p supabase/functions/_flows supabase/functions/_tasks
  • Directorysupabase
    • Directoryfunctions
      • Directory_flows
        • analyze_website.ts
      • Directory_tasks
        • scrapeWebsite.ts
        • summarizeWithAI.ts
        • extractTags.ts
        • saveWebsite.ts
      • Directoryanalyze_website_worker
        • index.ts
        • deno.json

This structure enables:

  • Sharing tasks across multiple flows
  • Running multiple workers for the same flow (horizontal scaling)
  • Clear separation of flow definitions from execution
  • Standard Supabase pattern for shared code