NextFlow is a production-grade visual workflow builder for creating and executing complex LLM pipelines. This guide walks you through the complete setup process.
-
Database Schema (Supabase/PostgreSQL)
workflowstable with JSONB storage for nodes/edgesworkflow_executionstable for history tracking- Row Level Security (RLS) policies configured
- Indexes on user_id, workflow_id, and status
-
6 Node Types (All Implemented)
- ✅ Text Node - Text input/output
- ✅ Upload Image Node - Image upload with preview
- ✅ Upload Video Node - Video upload with preview
- ✅ LLM Node - Gemini AI integration with result display
- ✅ Crop Image Node - FFmpeg image cropping
- ✅ Extract Frame Node - FFmpeg frame extraction
-
Workflow Engine
- ✅ DAG validation (cycle detection)
- ✅ Topological sorting for execution order
- ✅ Parallel execution of independent branches
- ✅ Type-safe connection validation
- ✅ Real-time status updates
-
UI Components
- ✅ React Flow canvas with dot grid background
- ✅ Node sidebar with drag-and-drop
- ✅ History sidebar with execution details
- ✅ Toolbar with Run/Save/Undo/Redo
- ✅ Minimap and controls
- ✅ Animated edges
-
API Routes
- ✅
/api/workflows- CRUD operations - ✅
/api/executions- Execution history - ✅
/api/execute/llm- LLM execution - ✅
/api/execute/crop-image- Image cropping - ✅
/api/execute/extract-frame- Frame extraction - ✅
/api/upload/image- Image upload - ✅
/api/upload/video- Video upload
- ✅
-
Authentication
- ✅ Clerk integration
- ✅ Protected routes via middleware
- ✅ Sign-in/Sign-up pages
- ✅ User-scoped data
-
State Management
- ✅ Zustand store
- ✅ History management (undo/redo)
- ✅ Execution tracking
- ✅ Node selection
-
Sample Workflow
- ✅ Product Marketing Generator example
- ✅ Load Sample button in toolbar
Copy the environment file:
cp .env.example .env.local- Go to https://clerk.com
- Create application
- Add to
.env.local:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_...
CLERK_SECRET_KEY=sk_test_...
The database is already set up with:
- Tables created
- RLS policies enabled
- Indexes configured
Just add your credentials to .env.local.
- Go to https://makersuite.google.com/app/apikey
- Create API key
- Add to
.env.local:
GOOGLE_GENERATIVE_AI_API_KEY=AIza...
npm install
npm run devnextflow/
├── app/
│ ├── api/
│ │ ├── execute/
│ │ │ ├── llm/route.ts # LLM execution
│ │ │ ├── crop-image/route.ts # Image cropping
│ │ │ └── extract-frame/route.ts # Frame extraction
│ │ ├── upload/
│ │ │ ├── image/route.ts # Image upload
│ │ │ └── video/route.ts # Video upload
│ │ ├── workflows/
│ │ │ ├── route.ts # List/Create workflows
│ │ │ └── [id]/route.ts # Get/Update/Delete workflow
│ │ └── executions/
│ │ ├── route.ts # List/Create executions
│ │ └── [id]/route.ts # Update execution
│ ├── workflow/page.tsx # Main workflow builder
│ ├── sign-in/[[...sign-in]]/page.tsx
│ ├── sign-up/[[...sign-up]]/page.tsx
│ ├── layout.tsx # Root layout with Clerk
│ └── page.tsx # Redirect to /workflow
│
├── components/
│ ├── nodes/
│ │ ├── TextNode.tsx # Text input node
│ │ ├── UploadImageNode.tsx # Image upload node
│ │ ├── UploadVideoNode.tsx # Video upload node
│ │ ├── LLMNode.tsx # LLM processing node
│ │ ├── CropImageNode.tsx # Image cropping node
│ │ └── ExtractFrameNode.tsx # Frame extraction node
│ ├── WorkflowCanvas.tsx # React Flow canvas
│ ├── NodeSidebar.tsx # Left sidebar (node palette)
│ ├── HistorySidebar.tsx # Right sidebar (execution history)
│ ├── WorkflowToolbar.tsx # Top toolbar (run/save/undo)
│ └── LoadSampleButton.tsx # Load sample workflow
│
├── lib/
│ ├── types.ts # TypeScript definitions
│ ├── store.ts # Zustand state management
│ ├── validation.ts # DAG validation & topological sort
│ ├── execution-engine.ts # Workflow execution logic
│ ├── supabase.ts # Supabase client
│ └── sample-workflow.ts # Sample workflow definition
│
├── trigger/
│ └── tasks.ts # Trigger.dev tasks (optional)
│
├── middleware.ts # Clerk middleware
├── .env.local # Environment variables
└── README.md # Documentation
User → Canvas → Zustand Store → Execution Engine → API Routes → Database
↓
Node Execution
↓
Google AI / FFmpeg
-
Node Creation
- User clicks node in sidebar
- Node added to Zustand store
- React Flow renders node component
-
Connection
- User drags from output to input handle
- Validation checks output type matches input type
- Edge added to store if valid
-
Execution
- User clicks "Run All/Selected/Single"
- Execution engine validates DAG
- Topological sort determines execution order
- Nodes execute sequentially/parallel based on dependencies
- Results stored in database
- UI updates in real-time
-
History
- Each execution creates record in
workflow_executions - Node-level results stored in JSONB
- History sidebar displays all executions
- Click execution to see detailed results
- Each execution creates record in
// Only matching types can connect:
Text → Text ✅
Image → Image ✅
Video → Video ✅
Text → Image ❌ (prevented)
Image → Video ❌ (prevented)Before execution:
- Check for cycles
- Build dependency graph
- Topological sort
- Parallel execution where possible
Each node shows real-time status:
idle- Gray borderrunning- Blue border, animated pulsesuccess- Green bordererror- Red border with error message
- Full Workflow - All nodes
- Partial Run - Selected nodes only
- Single Node - One node
The included "Product Marketing Generator" demonstrates:
Upload Image → Crop Image → LLM (Analysis)
↑ ↑
└──────────────┘
(cropped + text)
Upload Video → Extract Frame
Branch A Output + Frame → LLM (Marketing Copy)
Execution Flow:
- Branches A & B run in parallel
- LLM waits for both branches
- Final marketing post generated
- Define type in
lib/types.ts - Create component in
components/nodes/ - Register in
WorkflowCanvas.tsx - Add execution logic in
execution-engine.ts - Create API route if needed
Modify lib/execution-engine.ts:
- Add new node execution logic
- Implement custom validation
- Add pre/post execution hooks
Already configured in netlify.toml:
git push origin main- Connect repo to Netlify
- Add environment variables
- Deploy automatically
vercelAdd environment variables in Vercel dashboard.
If you see Turbopack errors:
rm -rf .next node_modules
npm install
npm run dev- Verify keys start with
pk_andsk_ - Check middleware is not blocking routes
- Ensure redirect URLs match
- Check Supabase connection
- Verify RLS policies
- Check user authentication
- Review execution history
- Check node configurations
- Verify API keys (Google AI)
- Check browser console
- Add each node type
- Connect nodes with valid types
- Try invalid connections (should fail)
- Run full workflow
- Run selected nodes
- Run single node
- Check history updates
- Save workflow
- Load workflow
- Undo/Redo operations
- Sign out/in
- React Flow handles 1000+ nodes efficiently
- Parallel execution reduces total time
- JSONB storage for flexible schemas
- Indexed queries for fast lookups
- Zustand prevents unnecessary re-renders
- Memoized components
- Lazy loading of execution results
- Database indexes on hot paths
- ✅ Row Level Security (RLS)
- ✅ User-scoped data access
- ✅ Authentication on all routes
- ✅ Type-safe API endpoints
- ✅ Input validation
- ✅ Secure file uploads
- Never expose API keys in client code
- Validate all inputs server-side
- Use HTTPS in production
- Regular security audits
- Keep dependencies updated
-
Trigger.dev Integration
- Implement async task execution
- Add webhook support
- Enable long-running tasks
-
Transloadit Integration
- Production file uploads
- Image optimization
- Video transcoding
-
Advanced Features
- Workflow templates
- Team collaboration
- Version control
- Workflow marketplace
-
UI Improvements
- Node search
- Bulk operations
- Keyboard shortcuts
- Dark mode
- Documentation: README.md
- Sample Workflows: Load Sample button
- Type Definitions: lib/types.ts
- API Reference: app/api/
MIT License - See LICENSE file for details
Built with ❤️ using Next.js, React Flow, Supabase, and Google Generative AI