Overview
Thebackends module provides a multi-backend architecture for workflow execution. It defines a protocol that enables integration with different workflow engines (currently includes Nadoo Native backend, extensible for LangGraph, CrewAI, etc.) while maintaining a consistent API.
Key Concepts:
- Protocol:
IWorkflowBackenddefines the interface all backends must implement - Registry: Factory pattern for creating and managing backend instances
- Native Backend: Nadoo’s default implementation using
WorkflowExecutor
Protocols
IWorkflowBackend
Protocol defining the interface for workflow execution backends.Methods
execute
Execute the workflow with given context and input.workflow_context- Workflow execution contextinitial_input- Optional initial input data
WorkflowContext- Updated context with execution results
validate
Validate the workflow configuration.bool- True if valid, False otherwise
Implementing IWorkflowBackend
Classes
BackendRegistry
Factory for creating and managing workflow backend instances.Class Methods
register
Register a new backend.name- Name to register the backend underbackend_class- Backend class or factory function
unregister
Unregister a backend.name- Backend name to unregister
ValueError- If trying to unregister ‘native’ backend
create
Create a backend instance.name- Backend name (if None, uses default)
IWorkflowBackend- Backend instance
ValueError- If backend not registered
set_default
Set the default backend.name- Backend name
ValueError- If backend not registered
get_default
Get the default backend name.str- Default backend name
list_backends
List all registered backends.list[str]- List of backend names
NadooBackend
Nadoo’s native workflow execution backend.Constructor
WorkflowExecutor.
Methods
add_node
Add a node to the workflow.node- Node to add
get_node
Get a node by ID.node_id- Node identifier
IStepNode | None- Node if found, None otherwise
execute
Execute the workflow.workflow_context- Execution contextinitial_input- Initial input data
WorkflowContext- Updated context
validate
Validate the workflow.bool- Validation result
Properties
start_node_id
Get the start node ID.str | None- Start node ID or None
Usage Patterns
Using Native Backend
Registering Custom Backend
Switching Backends
Factory Pattern
Multi-Backend Workflow
Backend Validation
Custom Backend with Configuration
Best Practices
Use Native Backend for Most Cases
Use Native Backend for Most Cases
The native backend is optimized and has no overhead:
Implement Protocol Methods
Implement Protocol Methods
Always implement both execute() and validate():
Register Once at Startup
Register Once at Startup
Register custom backends during app initialization:
Validate Before Execution
Validate Before Execution
Always validate backends before running workflows:
Handle Backend Errors Gracefully
Handle Backend Errors Gracefully
Wrap backend execution in try/except:
Document Custom Backends
Document Custom Backends
Provide clear documentation for custom backends:
Backend Comparison
| Feature | Native | Custom | Notes |
|---|---|---|---|
| Performance | ⚡ Fastest | Varies | Native has zero overhead |
| Flexibility | ✅ Full | ✅ Full | Both fully customizable |
| Integration | ❌ None | ✅ Yes | Custom can integrate external frameworks |
| Learning Curve | ⭐ Easy | ⭐⭐ Medium | Native is simpler |
| Maintenance | ✅ Maintained | ❌ Your responsibility | Native updated by Nadoo team |