@company-manager/docs

Workflows Domain

UML diagrams for workflow automation, execution engine, and job processing

Workflows Domain

The Workflows domain provides visual workflow building, automated execution, AI agent integration, and job queue processing.

Domain Overview

graph TB
    subgraph "Workflow Building"
        BUILDER[Visual Builder]
        NODES[Node Types]
        EDGES[Connections]
        TEMPLATES[Templates]
    end

    subgraph "Execution"
        ENGINE[Execution Engine]
        STATE[State Management]
        QUEUE[Job Queue]
    end

    subgraph "Node Types"
        TRIGGER[Triggers]
        ACTION[Actions]
        AGENT[AI Agents]
        FLOW[Flow Control]
    end

    subgraph "Integrations"
        WEBHOOK[Webhooks]
        SCHEDULE[Scheduler]
        API[External APIs]
    end

    BUILDER --> NODES
    NODES --> EDGES
    TEMPLATES --> BUILDER

    ENGINE --> STATE
    ENGINE --> QUEUE

    TRIGGER --> ENGINE
    ACTION --> ENGINE
    AGENT --> ENGINE
    FLOW --> ENGINE

    WEBHOOK --> TRIGGER
    SCHEDULE --> TRIGGER
    API --> ACTION

    style ENGINE fill:#e1f5fe
    style QUEUE fill:#fff3e0

Entity Relationship Diagram

erDiagram
    TENANT ||--o{ WORKFLOW : has
    WORKFLOW ||--o{ WORKFLOW_EXECUTION : runs

    WORKFLOW {
        string id PK
        string tenantId FK
        string name
        string description
        int version
        enum status
        enum category
        json bubbles
        json triggers
        json permissions
        string[] tags
        json metadata
        string createdBy FK
    }

    WORKFLOW_EXECUTION {
        string id PK
        string workflowId FK
        string tenantId FK
        string userId FK
        enum status
        json input
        json output
        string error
        timestamp startedAt
        timestamp completedAt
        int duration
        json tokenUsage
        float cost
    }

Workflow States

stateDiagram-v2
    [*] --> DRAFT: Create Workflow

    DRAFT --> ACTIVE: Activate
    DRAFT --> DRAFT: Edit

    ACTIVE --> PAUSED: Pause
    ACTIVE --> ACTIVE: Running

    PAUSED --> ACTIVE: Resume
    PAUSED --> ARCHIVED: Archive

    ARCHIVED --> DRAFT: Clone & Edit

    note right of ACTIVE
        Processing triggers
        and executing
    end note

Execution States

stateDiagram-v2
    [*] --> PENDING: Execution Triggered

    PENDING --> RUNNING: Start Execution
    RUNNING --> PAUSED: Breakpoint/Input Required
    RUNNING --> COMPLETED: All Nodes Complete
    RUNNING --> FAILED: Error Occurred

    PAUSED --> RUNNING: Resume/Input Provided
    PAUSED --> CANCELLED: User Cancels

    FAILED --> [*]
    COMPLETED --> [*]
    CANCELLED --> [*]

Key Business Processes

Execution Engine

Workflow execution, node processing, and state management. View Engine Details

Node Types

Trigger, action, agent, and flow control nodes. View Node Types

Job Processing

Queue-based workflow and node processing. View Job Processing

Workflow Architecture

flowchart TB
    subgraph "Trigger Layer"
        MANUAL[Manual Trigger]
        WEBHOOK[Webhook Trigger]
        SCHEDULE[Schedule Trigger]
        EVENT[Event Trigger]
    end

    subgraph "Execution Layer"
        QUEUE[Job Queue]
        ENGINE[Workflow Engine]
        STATE[State Storage]
    end

    subgraph "Processing Layer"
        WORKER[Job Workers]
        EXECUTOR[Node Executors]
        AGENT_REG[Agent Registry]
    end

    subgraph "Storage Layer"
        DB[(Database)]
        CACHE[(Redis Cache)]
    end

    MANUAL --> QUEUE
    WEBHOOK --> QUEUE
    SCHEDULE --> QUEUE
    EVENT --> QUEUE

    QUEUE --> WORKER
    WORKER --> ENGINE
    ENGINE --> STATE
    ENGINE --> EXECUTOR

    EXECUTOR --> AGENT_REG
    STATE --> CACHE
    ENGINE --> DB

    style ENGINE fill:#e1f5fe
    style QUEUE fill:#fff3e0

Node Categories

CategoryNode TypesDescription
Triggersmanual, schedule, webhook, eventStart workflow execution
Actionshttp, database, file, notification, codePerform operations
Agentsanalysis, code-fixer, test-generator, browserAI-powered tasks
Flow Controlcondition, switch, loop, parallel, waitControl execution flow