# 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) - [x] Redux state management with 5 slices (workflow, editor, nodes, connection, ui) - [x] API client with retry logic and error handling - [x] IndexedDB service layer with Dexie for offline-first support - [x] Execution service with polling and result caching - [x] Redux middleware for async API operations - [x] Custom React hooks (useWorkflow, useExecution, useUI, useEditor) #### Phase 2: Styling & Design System (Complete) - [x] Global SCSS with CSS variables and design tokens - [x] Component styles (buttons, forms, cards, panels, badges, etc.) - [x] Light/dark theme support with localStorage persistence - [x] Responsive design system (mobile/tablet/desktop) - [x] Animation system (fade, slide, spin) #### Phase 3: Layout & Navigation (Complete) - [x] Main layout with responsive header and sidebar - [x] Header with logo and theme toggle - [x] Sidebar with responsive mobile handling - [x] Root layout with Redux provider - [x] Dashboard with workflow list view - [x] Notification system with auto-dismiss - [x] Loading overlay for async operations #### Phase 4: Editor Toolbar (Complete) - [x] Save button with dirty state tracking - [x] Execute button with validation - [x] Validate button with validation results modal - [x] Zoom controls (in, out, reset with percentage display) - [x] Loading indicators and disabled states - [x] 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 workflows - `POST /api/workflows` - Create workflow - `GET /api/workflows/` - Get workflow - `PUT /api/workflows/` - Update workflow - `DELETE /api/workflows/` - Delete workflow - `POST /api/workflows//validate` - Validate workflow ### Execution - `POST /api/workflows//execute` - Execute workflow - `GET /api/workflows//executions` - Get execution history - `GET /api/executions/` - Get execution details ### Nodes - `GET /api/nodes` - List node types - `GET /api/nodes/` - Get node type - `GET /api/nodes/categories` - Get categories ## Database Schema (IndexedDB) ### Tables 1. **workflows** - Workflow definitions - Indexes: `id`, `tenantId`, `[tenantId+name]` 2. **executions** - Workflow execution results - Indexes: `id`, `workflowId`, `[tenantId+workflowId]` 3. **nodeTypes** - Available node types (cache) - Indexes: `id`, `[tenantId+category]` 4. **drafts** - Local workflow drafts - Indexes: `id`, `tenantId` 5. **syncQueue** - Offline change tracking - Indexes: `++id`, `[tenantId+action]` ## Performance Optimizations 1. **Code Splitting**: Dynamic imports for lazy loading components 2. **Memoization**: Redux selectors with createSelector 3. **Virtualization**: react-window for large lists 4. **Debouncing**: 2-second auto-save delay 5. **Caching**: Multi-level caching with IndexedDB ## Development Workflow ### Setup ```bash cd workflowui npm install npm run dev ``` ### Running Backend ```bash npm run backend # Runs on localhost:5000 ``` ### Both Frontend and Backend ```bash npm run dev:all ``` ### Build ```bash npm run build npm run start ``` ### Type Checking ```bash 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 1. **Real-time Collaboration**: Not yet implemented 2. **Advanced Debugging**: Step-through execution not available 3. **Custom Nodes**: Limited to built-in types 4. **Workflow Scheduling**: No cron scheduling support 5. **GraphQL**: REST API only ## Next Immediate Steps 1. Implement React Flow Canvas component 2. Create CustomNode wrapper component 3. Build Properties panel for parameter editing 4. Implement Node library/palette 5. Add keyboard shortcuts and keybindings 6. Implement undo/redo system 7. Add workflow templates 8. 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