Skip to Content

AI Automator - Complete Project Strategy

AI Automator - Complete Project Strategy

What You're Actually Building

Project: N8N-inspired workflow automation system built natively within Odoo 18
Scope: Native Odoo workflow automation module - no external N8N installation needed
Database: Native PostgreSQL models designed for workflow automation
Frontend: HTML5 + Vanilla JavaScript canvas with Bootstrap 5.3.0 UI
Backend: Native Python execution engine integrated with Odoo

Current Status

✅ What's Working

  • Odoo 18 module structure - Basic module setup complete
  • Database models - Native Odoo PostgreSQL models for workflow automation
  • Canvas foundation - Basic canvas rendering in vanilla JavaScript
  • Local development - Working Odoo + N8N instances for reference

❌ Current Challenges

  • Node overlay system - Adding new nodes to canvas (main pain point)
  • Code duplication - Repeated patterns across different node types
  • File organization - Circular dependencies and unclear structure
  • Node categories - Managing different node types cleanly

🎯 Immediate Priority

Node Overlay System - The ability to add different types of nodes to the existing canvas

Technical Architecture

Frontend (Vanilla JavaScript)

Canvas System (✅ Working)
├── Canvas core rendering
├── Canvas interactions (drag/drop)
└── Canvas data management

Node Overlay System (❌ Current focus)
├── Node overlay manager
├── Node factory (creates different node types)
├── Node categories (organize by type)
└── Node templates (specific implementations)

Backend (Python/Odoo)

Database Models (✅ Partially complete)
├── canvas - Workflow definitions (WorkflowDefinitionV2)
├── executions - Execution history (WorkflowExecutionV2)
├── nodes - Node configurations (CanvasNodes)
└── connections - Node relationships (CanvasConnections)

Execution Engine (🔄 Future milestone)
├── Workflow parser
├── Node execution system
├── Data transformation
└── Error handling

Node System Architecture

Base Node (Shared functionality)
├── Trigger Nodes (Manual, Webhook, Schedule)
├── Action Nodes (HTTP, Email, Database)
├── Logic Nodes (IF, Switch, Set, Merge)
└── Transform Nodes (JSON, CSV, Date)

Key Technical Decisions Made

  1. No External N8N - Complete integration into Odoo
  2. PostgreSQL over SQLite - Using Odoo's database system
  3. Vanilla JS over OWL - Simpler frontend approach
  4. Python Execution Engine - Native implementation for Odoo
  5. Factory Pattern - Prevent code duplication in node system

N8N-Inspired Implementation Challenges & Strategic Solutions

The Canvas/Node Overlay Challenge - Solved

Why This is Complex

You're building an N8N-inspired visual editor natively in Odoo using:
- HTML5 + Vanilla JavaScript
- SVG for node rendering
- Bootstrap 5.3.0 for UI components
- Native Odoo backend integration

Strategic Approach for Canvas Implementation

Phase 1: Minimum Viable Canvas (Current Priority)

Goal: Get basic node display and connections working
Implementation:
- Use SVG with vanilla JavaScript for node rendering
- Simple drag/drop with HTML5 drag API
- Basic connection lines between nodes
- Focus on core functionality, not polish

Phase 2: Enhanced Canvas Features
  • Advanced connection routing
  • Canvas zoom/pan
  • Multi-select operations
  • Copy/paste functionality
Phase 3: Advanced Features
  • Mini-map overview
  • Keyboard shortcuts
  • Grid snapping
  • Undo/redo system

Database Migration Strategy

Native Odoo PostgreSQL Models (N8N-Inspired)

Native Workflow Models
# Native Odoo models inspired by N8N concepts
class WorkflowDefinitionV2(models.Model):
    _name = 'canvas'
    # Workflow definitions

class WorkflowExecutionV2(models.Model):
    _name = 'executions'
    # Execution tracking
Critical Considerations
  1. JSON Fields - Store workflow configurations efficiently
  2. Odoo Relationships - Native Odoo field relationships
  3. Data Validation - Odoo's built-in validation system
  4. Performance - PostgreSQL indexing and Odoo ORM optimization

Node System Implementation Strategy

class BaseNode(models.AbstractModel):
    _name = 'base.node'

    name = fields.Char(required=True)
    type = fields.Char(required=True)
    parameters = fields.Json()
    position = fields.Json()  # x, y coordinates

    def execute(self, input_data, parameters):
        """Override in each node implementation"""
        raise NotImplementedError

Node Categories to Prioritize

  1. Core Logic Nodes (IF, Switch, Set) - Essential for basic workflows
  2. HTTP/API Nodes - Most commonly used
  3. Data Transform Nodes - JSON, CSV manipulation
  4. Trigger Nodes - Manual, webhook, schedule
  5. Odoo Integration Nodes - Leverage existing Odoo data

Execution Engine Architecture

Current Challenge Areas

  1. Workflow Parsing - Converting visual flow to execution sequence
  2. Data Passing - Moving data between nodes efficiently
  3. Error Handling - Graceful failure management
  4. Background Processing - Using Odoo's queue system
def execute_workflow(workflow_id, trigger_data=None):
    workflow = env['canvas'].browse(workflow_id)
    execution = env['executions'].create({
        'workflow_id': workflow_id,
        'status': 'running',
        'started_at': fields.Datetime.now()
    })

    try:
        # Parse workflow into execution sequence
        execution_sequence = parse_workflow_nodes(workflow)

        # Execute nodes in sequence
        for node_step in execution_sequence:
            result = execute_node(node_step, current_data)
            current_data = result

        execution.write({'status': 'success'})
    except Exception as e:
        execution.write({'status': 'failed', 'error': str(e)})

Main Development Challenges

1. Node Overlay Complexity

Problem: Each node type needs different HTML, parameters, and behavior
Solution: Factory pattern + inheritance to share common functionality

2. Code Duplication

Problem: Similar patterns repeated across files
Solution: Base classes, shared utilities, configuration-driven development

3. Frontend Complexity

Problem: Recreating N8N's sophisticated visual editor
Solution: Start simple (SVG + basic interactions), build incrementally

4. Execution Engine

Problem: Building native Python workflow engine for Odoo
Solution: N8N-inspired implementation with focus on core functionality first

Code Duplication Prevention

Current Duplication Patterns (Likely Issues)

  1. Node parameter handling - Each node doing similar validation
  2. Error logging - Repeated try/catch patterns
  3. Data transformation - Similar JSON/data operations
  4. UI rendering - Similar HTML5/JavaScript component patterns

Solutions

  1. Mixins and Abstract Models - Share common functionality
  2. Decorator Patterns - Common behaviors like logging, validation
  3. Configuration Files - Define nodes declaratively
  4. Template Components - Reusable HTML5/JavaScript components

File Organization Strategy

addons/the_ai_automator/
├── models/                     # Odoo backend models
│   ├── canvas.py                    # WorkflowDefinitionV2
│   ├── executions.py                # WorkflowExecutionV2
│   ├── nodes.py                     # CanvasNodes
│   └── execution_engine.py
├── static/src/js/
│   ├── canvas/                 # Canvas system (working)
│   │   ├── canvas_core.js
│   │   └── canvas_interactions.js
│   └── nodes/                  # Node overlay system (focus)
│       ├── node_overlay_manager.js
│       ├── node_factory.js
│       ├── node_categories.js
│       └── templates/
│           ├── base_node.js
│           ├── trigger_nodes.js
│           ├── action_nodes.js
│           └── logic_nodes.js
├── views/                      # Odoo XML views
└── security/                   # Permissions

Immediate Next Steps Priority

1. Node Overlay System (This Week)

  • Implement NodeOverlayManager class
  • Create NodeFactory for different node types
  • Build BaseNode template to prevent duplication
  • Test adding 2-3 basic node types to canvas

2. Node Categories & Organization (Next Week)

  • Define node categories (Trigger, Action, Logic, Transform)
  • Implement category-based node palette
  • Create specific node implementations
  • Test full node library functionality

3. Canvas-Backend Integration (Following Week)

  • Connect frontend canvas to Odoo models
  • Save/load workflow data from database
  • Implement basic workflow validation
  • Test persistence across sessions

4. Execution Engine Foundation (Future)

  • Design workflow parsing system
  • Implement basic node execution framework
  • Create data flow between nodes
  • Test simple workflow execution

Immediate Next Steps Priority

1. Canvas Proof of Concept (This Week)

  • Create simple HTML5/JavaScript component that renders nodes as SVG rectangles
  • Implement basic drag functionality
  • Show connections as simple lines
  • Test with 2-3 dummy nodes

2. Execution Engine Core (Next Week)

  • Build workflow parser that converts node graph to execution sequence
  • Implement basic node execution framework
  • Test with simple workflow (trigger → transform → output)

3. Node Implementation Pattern (Following Week)

  • Create BaseNode abstract model
  • Implement 3-5 core nodes (Manual trigger, Set, HTTP Request, etc.)
  • Test end-to-end workflow execution

Success Criteria

Short Term (2 weeks)

  • [ ] Can add any node type to canvas without code duplication
  • [ ] Node overlay system works smoothly
  • [ ] Canvas state persists to Odoo database
  • [ ] No circular dependency errors

Medium Term (1 month)

  • [ ] Complete node library available in canvas
  • [ ] Basic workflow execution working
  • [ ] Error handling and validation
  • [ ] Professional UI/UX

Long Term (3 months)

  • [ ] Core workflow automation functionality (N8N-inspired)
  • [ ] Performance optimization
  • [ ] Advanced workflow features
  • [ ] Complete integration with Odoo workflows

Key Insights for Development

  1. Start Simple - Focus on core functionality before advanced features
  2. Prevent Duplication Early - Use patterns like factory and inheritance
  3. One Problem at a Time - Focus on node overlay system first
  4. Reference Original - Use working N8N instance to understand behavior
  5. Incremental Progress - Build working pieces, then connect them

Resources & References

  • Working N8N Instance - For understanding behavior and UI patterns
  • Working Odoo 18 - For testing integration and development
  • N8N Source Code - For understanding technical implementation
  • Odoo Documentation - For best practices and patterns

Current Focus: Node overlay system - the ability to cleanly add different types of nodes to the canvas without code duplication or file organization issues.

Was this helpful?