# slbytes15/workflow-orchestration-engine architecture

> Architecture diagram of the GitHub repository slbytes15/workflow-orchestration-engine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/slbytes15/workflow-orchestration-engine
- Repository: https://github.com/slbytes15/workflow-orchestration-engine

## Overview

This is a multi-tenant workflow and Saga orchestration engine. Teams author and validate DAG workflows in the React studio, persist and manage their lifecycle through the API, then execute and inspect runs in dashboards with live updates. Backend stages include tenant authentication, graph validation and workflow persistence, execution with compensation and durable idempotency, and event-triggered dispatch; MongoDB stores tenant, workflow, and execution state. The README documents major capabilities not fully visible in sampled code; those links are cited to it, and unsampled implementation details are not inferred beyond that documentation.

Main entry points: [`backend/src/services/execution.service.ts`](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/services/execution.service.ts) (Execution service), [`frontend/src/api/executionApi.ts`](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/api/executionApi.ts) (Execution API client), [`frontend/src/App.tsx`](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/App.tsx) (React application), [`backend/src/routes/workflow.routes.ts`](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/routes/workflow.routes.ts) (Workflow routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_studio["Workflow Studio"]
  node_browser["React application<br/>[App.tsx]"]
  node_catalog["Workflow catalog<br/>[WorkflowsPage.tsx]"]
  node_canvas["Graph editor<br/>[NodePreview.tsx]"]
  node_graphcheck["Graph validation<br/>[graphValidation.ts]"]
  node_workflowstate["Workflow state mapping<br/>[workflowState.ts]"]
  node_workflowclient["Workflow API client<br/>[workflowApi.ts]"]
end

subgraph group_api["Tenant API"]
  node_tenantauth["Tenant authentication"]
  node_tenantresolve["Tenant resolver<br/>[tenantResolver.ts]"]
  node_workflowroutes["Workflow routes<br/>[workflow.routes.ts]"]
  node_workflowservice["Workflow service"]
  node_validators["Workflow validators"]
end

subgraph group_orchestration["Orchestration"]
  node_executionroutes["Execution routes"]
  node_executionservice["Execution service"]
  node_runtime["Saga runtime"]
  node_idempotency["Durable idempotency"]
  node_eventwatcher["Change stream watcher"]
end

subgraph group_observability["Monitoring"]
  node_executionclient["Execution API client<br/>[executionApi.ts]"]
  node_executionspage["Execution dashboard<br/>[ExecutionsPage.tsx]"]
  node_analytics["Analytics dashboard<br/>[AnalyticsPage.tsx]"]
  node_realtime["WebSocket event hub"]
  node_ticket["WebSocket ticket service"]
end

subgraph group_persistence["Persistence"]
  node_workflowsdb[("Workflow records<br/>[workflow.model.ts]")]
  node_executionsdb[("Execution records")]
  node_tenantsdb[("Tenant and API key records<br/>[tenant.model.ts]")]
end

node_team(("Workflow team"))
node_mongodb[("MongoDB")]

node_team -->|"authors workflows"| node_browser
node_browser -->|"opens catalog"| node_catalog
node_browser -->|"opens dashboard"| node_executionspage
node_catalog -->|"edits graph"| node_canvas
node_canvas -->|"validates graph"| node_graphcheck
node_catalog -->|"requests workflows"| node_workflowclient
node_browser -->|"manages lifecycle"| node_workflowclient
node_workflowclient -->|"sends REST requests"| node_workflowroutes
node_workflowroutes -->|"authenticates tenant"| node_tenantauth
node_tenantauth -->|"resolves API key"| node_tenantresolve
node_tenantresolve -->|"reads tenant keys"| node_tenantsdb
node_workflowroutes -->|"validates input"| node_validators
node_workflowroutes -->|"delegates workflow actions"| node_workflowservice
node_workflowservice -->|"persists workflows"| node_workflowsdb
node_workflowstate -->|"maps API data"| node_workflowclient
node_executionspage -->|"requests execution data"| node_executionclient
node_executionclient -->|"sends REST requests"| node_executionroutes
node_executionroutes -->|"authenticates tenant"| node_tenantauth
node_executionroutes -->|"reserves run key"| node_idempotency
node_executionroutes -->|"delegates execution"| node_executionservice
node_executionservice -->|"loads workflow"| node_workflowsdb
node_executionservice -->|"executes graph"| node_runtime
node_executionservice -->|"stores run results"| node_executionsdb
node_executionservice -->|"publishes updates"| node_realtime
node_eventwatcher -->|"matches active workflows"| node_workflowsdb
node_eventwatcher -->|"dispatches matching events"| node_executionservice
node_mongodb -->|"streams inserts"| node_eventwatcher
node_executionclient -->|"requests socket ticket"| node_ticket
node_ticket -->|"requires tenant auth"| node_tenantauth
node_executionclient -->|"opens authenticated socket"| node_realtime
node_realtime -->|"streams run status"| node_executionspage
node_analytics -.->|"loads run metrics"| node_executionclient

click node_browser "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/App.tsx"
click node_catalog "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/pages/WorkflowsPage.tsx"
click node_canvas "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/components/workflow/nodes/NodePreview.tsx"
click node_graphcheck "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/graphValidation.ts"
click node_workflowstate "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/workflowState.ts"
click node_workflowclient "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/api/workflowApi.ts"
click node_tenantauth "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/middleware/tenantAuth.middleware.ts"
click node_tenantresolve "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/services/tenantResolver.ts"
click node_workflowroutes "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/routes/workflow.routes.ts"
click node_workflowservice "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/services/workflow.service.ts"
click node_validators "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/validators/workflow-graph.validator.ts"
click node_executionclient "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/api/executionApi.ts"
click node_executionspage "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/pages/ExecutionsPage.tsx"
click node_analytics "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/pages/AnalyticsPage.tsx"
click node_executionroutes "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/routes/execution.routes.ts"
click node_executionservice "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/services/execution.service.ts"
click node_runtime "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/services/execution.runtime.ts"
click node_idempotency "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/services/executionIdempotency.ts"
click node_eventwatcher "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/services/changeStreamWatcher.service.ts"
click node_realtime "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/services/executionWebSocket.ts"
click node_ticket "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/services/executionTicket.service.ts"
click node_workflowsdb "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/models/workflow.model.ts"
click node_executionsdb "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/models/WorkflowExecution.ts"
click node_tenantsdb "https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/models/tenant.model.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser,node_catalog,node_canvas,node_graphcheck,node_workflowstate,node_workflowclient toneBlue
class node_tenantauth,node_tenantresolve,node_workflowroutes,node_workflowservice,node_validators,node_mongodb toneAmber
class node_executionroutes,node_executionservice,node_runtime,node_idempotency,node_eventwatcher toneMint
class node_executionclient,node_executionspage,node_analytics,node_realtime,node_ticket toneRose
class node_workflowsdb,node_executionsdb,node_tenantsdb,node_team toneIndigo
```

## Components

### Workflow Studio

- [React application](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Workflow catalog](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/pages/WorkflowsPage.tsx): `frontend/src/pages/WorkflowsPage.tsx`
- [Graph editor](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/components/workflow/nodes/NodePreview.tsx): `frontend/src/components/workflow/nodes/NodePreview.tsx`
- [Graph validation](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/graphValidation.ts): `frontend/src/graphValidation.ts`
- [Workflow state mapping](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/workflowState.ts): `frontend/src/workflowState.ts`
- [Workflow API client](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/api/workflowApi.ts): `frontend/src/api/workflowApi.ts`

### Tenant API

- [Tenant authentication](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/middleware/tenantAuth.middleware.ts): `backend/src/middleware/tenantAuth.middleware.ts`
- [Tenant resolver](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/services/tenantResolver.ts): `backend/src/services/tenantResolver.ts`
- [Workflow routes](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/routes/workflow.routes.ts): `backend/src/routes/workflow.routes.ts`
- [Workflow service](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/services/workflow.service.ts): `backend/src/services/workflow.service.ts`
- [Workflow validators](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/validators/workflow-graph.validator.ts): `backend/src/validators/workflow-graph.validator.ts`

### Orchestration

- [Execution routes](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/routes/execution.routes.ts): `backend/src/routes/execution.routes.ts`
- [Execution service](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/services/execution.service.ts): `backend/src/services/execution.service.ts`
- [Saga runtime](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/services/execution.runtime.ts): `backend/src/services/execution.runtime.ts`
- [Durable idempotency](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/services/executionIdempotency.ts): `backend/src/services/executionIdempotency.ts`
- [Change stream watcher](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/services/changeStreamWatcher.service.ts): `backend/src/services/changeStreamWatcher.service.ts`

### Monitoring

- [Execution API client](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/api/executionApi.ts): `frontend/src/api/executionApi.ts`
- [Execution dashboard](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/pages/ExecutionsPage.tsx): `frontend/src/pages/ExecutionsPage.tsx`
- [Analytics dashboard](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/frontend/src/pages/AnalyticsPage.tsx): `frontend/src/pages/AnalyticsPage.tsx`
- [WebSocket event hub](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/services/executionWebSocket.ts): `backend/src/services/executionWebSocket.ts`
- [WebSocket ticket service](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/services/executionTicket.service.ts): `backend/src/services/executionTicket.service.ts`

### Persistence

- [Workflow records](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/models/workflow.model.ts): `backend/src/models/workflow.model.ts`
- [Execution records](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/models/WorkflowExecution.ts): `backend/src/models/WorkflowExecution.ts`
- [Tenant and API key records](https://github.com/slbytes15/workflow-orchestration-engine/blob/main/backend/src/models/tenant.model.ts): `backend/src/models/tenant.model.ts`

### Other components

- **Workflow team**
- **MongoDB**

## Connections

- Workflow team → React application: authors workflows
- React application → Workflow catalog: opens catalog (evidence: `frontend/src/App.tsx`)
- React application → Execution dashboard: opens dashboard (evidence: `frontend/src/App.tsx`)
- Workflow catalog → Graph editor: edits graph (evidence: `frontend/src/pages/WorkflowsPage.tsx`)
- Graph editor → Graph validation: validates graph (evidence: `frontend/src/components/workflow/nodes/NodePreview.tsx`)
- Workflow catalog → Workflow API client: requests workflows (evidence: `frontend/src/pages/WorkflowsPage.tsx`)
- React application → Workflow API client: manages lifecycle (evidence: `frontend/src/App.tsx`)
- Workflow API client → Workflow routes: sends REST requests
- Workflow routes → Tenant authentication: authenticates tenant (evidence: `backend/src/routes/workflow.routes.ts`)
- Tenant authentication → Tenant resolver: resolves API key (evidence: `backend/src/middleware/tenantAuth.middleware.ts`)
- Tenant resolver → Tenant and API key records: reads tenant keys (evidence: `backend/src/services/tenantResolver.ts`)
- Workflow routes → Workflow validators: validates input (evidence: `backend/src/routes/workflow.routes.ts`)
- Workflow routes → Workflow service: delegates workflow actions (evidence: `backend/src/routes/workflow.routes.ts`)
- Workflow service → Workflow records: persists workflows (evidence: `backend/src/services/workflow.service.ts`)
- Workflow state mapping → Workflow API client: maps API data (evidence: `frontend/src/workflowState.ts`)
- Execution dashboard → Execution API client: requests execution data (evidence: `frontend/src/pages/ExecutionsPage.tsx`)
- Execution API client → Execution routes: sends REST requests
- Execution routes → Tenant authentication: authenticates tenant (evidence: `backend/src/routes/execution.routes.ts`)
- Execution routes → Durable idempotency: reserves run key (evidence: `backend/src/routes/execution.routes.ts`)
- Execution routes → Execution service: delegates execution (evidence: `backend/src/routes/execution.routes.ts`)
- Execution service → Workflow records: loads workflow (evidence: `backend/src/services/execution.service.ts`)
- Execution service → Saga runtime: executes graph (evidence: `backend/src/services/execution.service.ts`)
- Execution service → Execution records: stores run results (evidence: `backend/src/services/execution.service.ts`)
- Execution service → WebSocket event hub: publishes updates (evidence: `backend/src/services/execution.service.ts`)
- Change stream watcher → Workflow records: matches active workflows (evidence: `backend/src/services/changeStreamWatcher.service.ts`)
- Change stream watcher → Execution service: dispatches matching events (evidence: `backend/src/services/changeStreamWatcher.service.ts`)
- MongoDB → Change stream watcher: streams inserts
- Execution API client → WebSocket ticket service: requests socket ticket
- WebSocket ticket service → Tenant authentication: requires tenant auth (evidence: `backend/src/routes/executionWsTicket.routes.ts`)
- Execution API client → WebSocket event hub: opens authenticated socket
- WebSocket event hub → Execution dashboard: streams run status
- Analytics dashboard → Execution API client: loads run metrics
