mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 14:25:02 +00:00
13 KiB
13 KiB
WorkflowUI Implementation Guide
Overview
This guide documents the implementation status and architecture of the WorkflowUI visual workflow editor.
Implementation Status
✅ Completed Phases
Phase 1: Core Infrastructure (Complete)
- Redux state management with 5 slices (workflow, editor, nodes, connection, ui)
- API client with retry logic and error handling
- IndexedDB service layer with Dexie for offline-first support
- Execution service with polling and result caching
- Redux middleware for async API operations
- Custom React hooks (useWorkflow, useExecution, useUI, useEditor)
Phase 2: Styling & Design System (Complete)
- Global SCSS with CSS variables and design tokens
- Component styles (buttons, forms, cards, panels, badges, etc.)
- Light/dark theme support with localStorage persistence
- Responsive design system (mobile/tablet/desktop)
- Animation system (fade, slide, spin)
Phase 3: Layout & Navigation (Complete)
- Main layout with responsive header and sidebar
- Header with logo and theme toggle
- Sidebar with responsive mobile handling
- Root layout with Redux provider
- Dashboard with workflow list view
- Notification system with auto-dismiss
- Loading overlay for async operations
Phase 4: Editor Toolbar (Complete)
- Save button with dirty state tracking
- Execute button with validation
- Validate button with validation results modal
- Zoom controls (in, out, reset with percentage display)
- Loading indicators and disabled states
- Keyboard shortcut hints
🚀 In Progress
Phase 5: React Flow Canvas Integration
- Canvas component with React Flow
- Node renderer and event handling
- Edge/connection renderer
- Pan and zoom controls
- Minimap navigation
Phase 6: Node Components
- CustomNode component wrapper
- Playwright test node
- Storybook node
- Generic parameter editor
- Node templates
Phase 7: Properties Panel
- Properties panel component
- Parameter editing interface
- Type-aware input fields
- Validation and error display
- Template management
Phase 8: Node Library
- Node palette/library component
- Category filtering
- Search functionality
- Drag-and-drop support
- Node preview
📋 Upcoming Phases
Phase 9: Execution & Results
- Execution history view
- Results visualization
- Error debugging panel
- Performance metrics
- Export results
Phase 10: Advanced Features
- Workflow templates
- Import/export workflows
- Workflow versioning
- Collaboration features
- Undo/redo system
Phase 11: Testing & Documentation
- Component tests
- Integration tests
- E2E tests with Playwright
- Storybook documentation
- API documentation
Phase 12: Deployment
- Production build optimization
- Performance profiling
- Bundle analysis
- CI/CD integration
- Monitoring setup
Architecture Overview
┌─────────────────────────────────────────────────────────────┐
│ Next.js Application │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ React Components (TSX) │ │
│ │ - Layout, UI, Editor, Nodes, Panels │ │
│ └─────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Custom React Hooks │ │
│ │ - useWorkflow, useExecution, useUI, useEditor │ │
│ └─────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Redux Store & Middleware │ │
│ │ - 5 slices, apiMiddleware, DevTools │ │
│ └─────────────────────────────────────────────────────┘ │
│ │ │
│ ┌────────────────┼────────────────┐ │
│ ▼ ▼ ▼ │
│ ┌─────────┐ ┌─────────────┐ ┌──────────────┐ │
│ │IndexedDB│ │ API Client │ │ Services │ │
│ │(offline)│ │ (Flask) │ │ (business │ │
│ │ │ │ │ │ logic) │ │
│ └─────────┘ └─────────────┘ └──────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
│
▼
Flask Backend (localhost:5000)
│
▼
MetaBuilder DAG Executor
Component Structure
Pages
src/app/
├── layout.tsx # Root layout with Redux provider
├── page.tsx # Dashboard with workflow list
└── editor/
└── [id]/page.tsx # Workflow editor (TBD)
Components
src/components/
├── Layout/
│ ├── MainLayout.tsx # Main app layout
│ └── MainLayout.module.scss
├── Editor/
│ ├── Toolbar.tsx # Save, execute, validate controls
│ ├── Toolbar.module.scss
│ ├── Canvas.tsx # React Flow canvas (TBD)
│ ├── CustomNode.tsx # Custom node renderer (TBD)
│ ├── NodePanel.tsx # Node library (TBD)
│ └── Properties.tsx # Properties panel (TBD)
└── UI/
├── NotificationContainer.tsx
├── LoadingOverlay.tsx
├── Button.tsx (TBD)
├── Modal.tsx (TBD)
└── ...
Services
src/services/
├── api.ts # HTTP client with retry
├── workflowService.ts # Workflow CRUD + offline-first
└── executionService.ts # Execution management + polling
Hooks
src/hooks/
├── useWorkflow.ts # Workflow state + operations
├── useExecution.ts # Execution state + operations
├── useUI.ts # UI state (modals, notifications, theme)
├── useEditor.ts # Canvas state (zoom, pan, selection)
└── index.ts # Export index
Redux
src/store/
├── store.ts # Store configuration
├── slices/
│ ├── workflowSlice.ts # Workflow data
│ ├── editorSlice.ts # Canvas state
│ ├── nodesSlice.ts # Node registry
│ ├── connectionSlice.ts # Connection drawing
│ └── uiSlice.ts # UI state
└── middleware/
└── apiMiddleware.ts # Async API operations
Styling
src/styles/
├── globals.scss # Global styles + design tokens
├── components.scss # Reusable component styles
└── pages/
└── *.module.scss # Page-specific styles
Key Integrations
Redux Store Slices
workflowSlice
- Current workflow metadata
- Canvas nodes and connections
- Execution history
- Dirty tracking and auto-save
editorSlice
- Canvas zoom and pan
- Node/edge selection
- Drawing state
- Context menu position
nodesSlice
- Available node types registry
- Node templates
- Node categories
connectionSlice
- Active connection drawing state
- Connection validation
- Source/target tracking
uiSlice
- Modal open/close states
- Notifications
- Theme (light/dark)
- Sidebar state
- Loading indicators
Custom Hooks
All hooks provide:
- Convenient access to Redux state
- Memoized callback actions
- Error handling with notifications
- Loading state management
API Endpoints
Workflows
GET /api/workflows- List workflowsPOST /api/workflows- Create workflowGET /api/workflows/<id>- Get workflowPUT /api/workflows/<id>- Update workflowDELETE /api/workflows/<id>- Delete workflowPOST /api/workflows/<id>/validate- Validate workflow
Execution
POST /api/workflows/<id>/execute- Execute workflowGET /api/workflows/<id>/executions- Get execution historyGET /api/executions/<id>- Get execution details
Nodes
GET /api/nodes- List node typesGET /api/nodes/<id>- Get node typeGET /api/nodes/categories- Get categories
Database Schema (IndexedDB)
Tables
-
workflows - Workflow definitions
- Indexes:
id,tenantId,[tenantId+name]
- Indexes:
-
executions - Workflow execution results
- Indexes:
id,workflowId,[tenantId+workflowId]
- Indexes:
-
nodeTypes - Available node types (cache)
- Indexes:
id,[tenantId+category]
- Indexes:
-
drafts - Local workflow drafts
- Indexes:
id,tenantId
- Indexes:
-
syncQueue - Offline change tracking
- Indexes:
++id,[tenantId+action]
- Indexes:
Performance Optimizations
- Code Splitting: Dynamic imports for lazy loading components
- Memoization: Redux selectors with createSelector
- Virtualization: react-window for large lists
- Debouncing: 2-second auto-save delay
- Caching: Multi-level caching with IndexedDB
Development Workflow
Setup
cd workflowui
npm install
npm run dev
Running Backend
npm run backend # Runs on localhost:5000
Both Frontend and Backend
npm run dev:all
Build
npm run build
npm run start
Type Checking
npm run typecheck
Testing Strategy
Unit Tests
- Individual component tests
- Hook tests
- Service tests
- Reducer tests
Integration Tests
- Component + Redux integration
- API client tests
- Service integration tests
E2E Tests
- Full workflow creation
- Execution flow
- Validation workflow
- Error scenarios
Environment Variables
Frontend (.env.local)
NEXT_PUBLIC_API_URL=http://localhost:5000/api
NEXT_PUBLIC_ENABLE_DEVTOOLS=true
Backend (.env)
DEBUG=True
PORT=5000
ALLOWED_ORIGINS=http://localhost:3000
Known Limitations
- Real-time Collaboration: Not yet implemented
- Advanced Debugging: Step-through execution not available
- Custom Nodes: Limited to built-in types
- Workflow Scheduling: No cron scheduling support
- GraphQL: REST API only
Next Immediate Steps
- Implement React Flow Canvas component
- Create CustomNode wrapper component
- Build Properties panel for parameter editing
- Implement Node library/palette
- Add keyboard shortcuts and keybindings
- Implement undo/redo system
- Add workflow templates
- Create E2E test suite
Monitoring & Observability
Frontend
- Redux DevTools enabled in development
- React DevTools support
- Console error logging
- Network request logging
Backend
- Flask request logging
- Error stack traces
- Performance metrics
- Execution logging
Maintenance & Future Work
- Monitor bundle size trends
- Update dependencies regularly
- Implement performance monitoring
- Expand test coverage
- Add accessibility improvements
- Document complex algorithms
- Add more comprehensive logging
Last Updated: 2026-01-23 Status: Phase 4 Complete, Phase 5 In Progress Next Phase: React Flow Canvas Integration