Documents AI Workflow Orchestrator
Software Architecture Analysis: Temporal to Azure Durable Functions Migration
High-Level Overview
Based on the temporal folder structure, I can see a comprehensive workflow orchestration system with multiple workflows and activities for invoice processing. Let me analyze the components and create a migration strategy. Summarized conversation historyNow I’ll read the specific workflow stage files to understand the complete architecture: Now I need to see the structure of the activity definitions across all modules: Now let me get more activity definitions to understand the complete scope: Let me check what activities are available to get a complete list: Now let me get a complete view of all activities to understand the migration scope: Now let me get the complete activity structure from one more key file: Now let me create a comprehensive architectural overview and migration plan for converting the Temporal workflows to Azure Durable Functions. Based on my analysis, I can provide the high-level overview and point stories you requested.
Temporal to Azure Durable Functions Migration Overview
Current Temporal Architecture
The AutoExtract system uses a sophisticated multi-stage invoice processing workflow orchestrated by Temporal. Here’s the complete architecture:
Main Orchestrator Workflow
InvoiceWorkflow- Primary orchestrator that coordinates all child workflows- Dynamically executes child workflows based on client configuration stages
- Handles failure recovery, user interaction pauses, and stage progression
Child Workflow Stages (13 total)
WorkflowSplitInvoice- Document preprocessing and splittingWorkflowInvoiceIngest- PDF processing, image generation, OCR extractionWorkflowInvoiceIntake- Validation, duplicate detection, sales tax handlingWorkflowInvoiceMatching- PO matching and line item correlationWorkflowInvoiceManual- Manual review processesWorkflowInvoiceManualApproval- Approval workflowsWorkflowLineItemCoding- AI-based line item classificationWorkflowInvoiceFiling- ERP system integrationWorkflowInvoiceExport- Data export processesWorkflowInvoiceExportIIF- QuickBooks IIF exportWorkflowInvoiceClosed- Finalization processesUserWorkflow- User interaction handlingPreprocessInvoiceWorkflow- Document preprocessing
Activity Modules (30+ activities across 11 modules)
- Azure Cosmos Activities (4): Database operations, document storage
- Line Item Coding Activities (5): ML-based classification, asset autofill
- Ingest Activities (8): Document processing, OCR, image generation
- Matching Activities (2): PO data retrieval, line item matching
- Filing Activities (1): ERP synchronization
- Manual Activities (2): Manual review object creation
- Workflow Activities (5): Stage management, initialization, completion
- Intake Activities (3): Validation, duplicate detection
- Background Activities (1): Token handling
- Preprocessing Activities (3): Image processing, invoice splitting
Azure Durable Functions Migration Architecture
Function App Structure
Main Orchestrator Function
Sub-Orchestrator Functions (Consolidate from 13 to 5)
Activity Functions (Consolidate from 30+ to 15)
Migration Point Stories (Development Epics)
Story 1: Core Infrastructure & Main Orchestrator Migration
Effort: 1-2 sprints
Acceptance Criteria:
- Create Azure Function App with Durable Functions extension
- Implement main
InvoiceOrchestratorfunction replacingInvoiceWorkflow - Migrate client configuration and stage management logic
- Implement function chaining pattern for sub-orchestrators
- Set up monitoring, logging, and error handling
- Create deployment pipeline and environment configuration
Technical Dependencies:
- Azure Functions Premium plan for long-running workflows
- Azure Storage for Durable Functions state management
- Application Insights for monitoring and diagnostics
- Service Bus for reliable messaging between functions
Story 2: Document Processing Pipeline Migration
Effort: 1-2 sprints
Acceptance Criteria:
- Migrate
DocumentProcessingOrchestratorcombining ingest/intake workflows - Convert document processing activities (PDF parsing, OCR, image generation)
- Implement Azure Form Recognizer integration for OCR capabilities
- Migrate validation and duplicate detection logic
- Set up Azure Blob Storage integration for document storage
- Implement error handling and retry policies for external service calls
Technical Dependencies:
- Azure Form Recognizer for OCR processing
- Azure Blob Storage for document and image storage
- Azure Computer Vision API integration
- Cosmos DB SDK for document operations
Story 3: Business Logic & AI Integration Migration
Effort: 1-2 sprints
Acceptance Criteria:
- Migrate
InvoiceMatchingOrchestratorwith PO matching and ML coding - Convert line item coding activities using Azure ML integration
- Implement PO data retrieval and matching algorithms
- Migrate ML model inference for line item classification
- Set up Azure Cognitive Services integration for enhanced AI capabilities
- Implement business rules engine for terms and due date calculation
Technical Dependencies:
- Azure Machine Learning service for model hosting
- Azure Cognitive Services for enhanced AI capabilities
- Integration with external ERP systems for PO data
- Cosmos DB for storing ML training data and results
Story 4: Human Interaction & Approval Workflows
Effort: 1-2 sprints
Acceptance Criteria:
- Migrate
ManualReviewOrchestratorwith human interaction patterns - Implement Durable Functions human interaction pattern
- Convert user approval workflows and manual review processes
- Set up webhook endpoints for external system integration
- Implement timeout handling for pending user actions
- Create notification system for user interactions
Technical Dependencies:
- Azure Service Bus for reliable messaging
- Azure SignalR for real-time UI updates
- Webhook infrastructure for external integrations
- Azure Active Directory for user authentication
Story 5: ERP Integration & Data Export Migration
Effort: 1-2 sprints
Acceptance Criteria:
- Migrate
ERPIntegrationOrchestratorwith ERP sync and export capabilities - Convert filing activities for multiple ERP systems (SageIntacct, Epicor21)
- Implement data export functions for various formats (IIF, CSV, XML)
- Set up secure connectivity to external ERP systems
- Implement data transformation and mapping logic
- Create monitoring and alerting for integration failures
Technical Dependencies:
- Azure Logic Apps for complex ERP integrations
- Azure Data Factory for data transformation pipelines
- Azure Key Vault for secure credential management
- VPN/ExpressRoute for secure ERP connectivity
Migration Benefits
- Simplified Architecture: Reduce from 13 child workflows to 5 sub-orchestrators
- Improved Scalability: Azure Functions auto-scaling and consumption-based pricing
- Enhanced Monitoring: Native Azure integration with Application Insights
- Reduced Complexity: Consolidate 30+ activities into 15 focused functions
- Better Resilience: Built-in retry policies and error handling patterns
- Cost Optimization: Pay-per-execution model vs. always-running Temporal workers
This migration plan provides a clear path from the current Temporal-based system to Azure Durable Functions while maintaining all existing functionality and improving operational characteristics.