pgflow

Workflow orchestration that runs in your Supabase project

This demo runs a 4-step DAG: fetch → (summarize + extractKeywords in parallel) → publish.

Postgres handles orchestration, state management, output persistence, retries, and queue management.

Auto-respawning Edge Function worker executes your handlers.

TypeScript Client wraps RPC and Realtime for starting flows and observing state changes.

Click any step to inspect inputs, outputs, and dependencies

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

Processes web articles by fetching content, generating summaries and keywords in parallel, then publishing the results. Demonstrates parallel execution, automatic retries, and dependency management.

Orchestration in Postgres

The pgflow client calls SQL function start_flow() via Supabase RPC, which creates a run and initializes state for each step. Root steps (no dependencies) get tasks queued immediately.

Edge Function worker polls the queue, calls SQL function start_tasks() to reserve tasks, executes handlers, then calls complete_task() to save outputs.

complete_task() checks dependencies after each completion, creates tasks for steps with all dependencies met, and marks the run complete when remaining_steps = 0.

Supabase Realtime streams database events. The pgflow client transforms these into a developer-friendly API with promises for completion and reactive state updates.

Configuration options
slug: "article_flow"
Unique identifier for this flow. Must be ≤128 characters, containing only letters, numbers, and underscores.
maxAttempts: 2
Maximum total attempts allowed. With 2 attempts: 1 initial try + 1 retry on failure.
baseDelay: 1
Base delay for retries in seconds. With exponential backoff, first retry waits 1s (subsequent retries would wait 2s, 4s, etc).
Steps