SQL Core
Pure SQL implementation that handles workflow definitions, state transitions, and ACID-compliant processing directly in your Postgres database.
const WebsiteFlow = new Flow<{ url: string }>({ slug: 'website' }) .step({ slug: 'fetch' }, input => scrape(input.run.url)) .step({ slug: 'sentiment', dependsOn: ['fetch'] }, input => analyzeSentiment(input.fetch)) .step({ slug: 'summary', dependsOn: ['fetch'] }, input => summarize(input.fetch)) .step({ slug: 'save', dependsOn: ['sentiment', 'summary'] }, input => save({ ...input.sentiment, ...input.summary }));
pgflow is a workflow orchestration system with its core state management in your database, combining:
SQL Core
Pure SQL implementation that handles workflow definitions, state transitions, and ACID-compliant processing directly in your Postgres database.
TypeScript DSL
Type-safe API for defining workflows that automatically infers input/output types between steps, providing compile-time safety.
Edge Worker
Self-restarting worker that processes tasks with built-in retries and error handling, designed for Supabase Edge Functions.
CLI Tools
One-command setup with npx pgflow install
that handles migrations, configuration, and deployment.
Define complex workflows with parallel execution and dependencies using a simple, type-safe API:
// Define a workflow with parallel stepsnew Flow<{ url: string }>() .step("website", async ({ url }) => { const response = await fetch(url); return { content: await response.text() }; }) .step("sentiment", ["website"], async ({ website }) => { return await analyzeSentiment(website.content); }) .step("summary", ["website"], async ({ website }) => { return await summarizeWithAI(website.content); }) .step("saveToDb", ["sentiment", "summary"], async (input) => { return await saveResults({ url: input.run.url, sentiment: input.sentiment.score, summary: input.summary }); });
Single source of truth
All workflow definitions, state, and execution history stored in your Postgres database—simplifying monitoring and debugging.
Reliable task processing
Built on PGMQ for at-least-once delivery with automatic retries, timeouts, and dead-letter handling.
Supabase-native
Deploy as Edge Functions with automatic restarts and zero-config integration with your existing Supabase project.
Developer experience
Full type inference between workflow steps with IDE autocompletion and compile-time safety for your entire workflow DAG.
Create and run workflows with a straightforward process:
The execution system handles the rest—scheduling steps when dependencies complete, retrying failed tasks, and aggregating results automatically.
Install pgflow in your Supabase project with a single command:
npx pgflow install