# dafthunk-com/dafthunk architecture

> Architecture diagram of the GitHub repository dafthunk-com/dafthunk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dafthunk-com/dafthunk
- Repository: https://github.com/dafthunk-com/dafthunk

## Overview

Dafthunk is a browser-based visual workflow automation platform: users build workflows from connected nodes, configure triggers and integrations, then execute and monitor them. Its API coordinates execution and generation, while Cloudflare-backed runtime services provide workflow execution, AI, and persistent resources. The README establishes the main platform capabilities; sampled source confirms the execution manager’s validation and dispatch, the generator pipeline’s synthesis helpers, and the browser’s WebSocket protocol. Some subsystem links below reflect documented capabilities rather than inspected implementation wiring.

Main entry points: [`apps/api/src/runtime/cloudflare-worker-runtime.ts`](https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/runtime/cloudflare-worker-runtime.ts) (Worker runtime), [`apps/api/src/services/execution-manager.ts`](https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/services/execution-manager.ts) (Execution manager), [`apps/app/src/services/workflow-session-service.ts`](https://github.com/dafthunk-com/dafthunk/blob/main/apps/app/src/services/workflow-session-service.ts) (Live workflow session), [`apps/api/src/agents/workflow-generator/pipeline.ts`](https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/agents/workflow-generator/pipeline.ts) (Workflow generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Workflow authoring"]
  node_editor["Visual editor"]
  node_session["Live workflow session"]
  node_generator["Workflow generator<br/>[pipeline.ts]"]
end

subgraph group_orchestration["API orchestration"]
  node_api["API routes<br/>[index.ts]"]
  node_workflow_routes["Workflow routes<br/>[workflows.ts]"]
  node_execution_manager["Execution manager"]
  node_executor["Workflow executor"]
  node_monitoring["Live execution updates<br/>[ws.ts]"]
end

subgraph group_runtime["Workflow runtime"]
  node_runtime_entry["Runtime entrypoint"]
  node_worker_runtime["Worker runtime"]
  node_ai["AI model services"]
end

subgraph group_resources["Platform resources"]
  node_execution_store[("Execution state")]
  node_database_service[("Database service")]
  node_object_store[("Object storage")]
  node_db[("Application records<br/>[index.ts]")]
end

subgraph group_integrations["Triggers and integrations"]
  node_triggers["Workflow triggers<br/>[http-triggers.ts]"]
  node_oauth["Integration OAuth<br/>[index.ts]"]
  node_integrations_api["Integration endpoints<br/>[integrations.ts]"]
end

node_user(("Workflow user"))
node_external{{"Cloudflare services"}}

node_user -->|"designs workflow"| node_editor
node_editor -->|"updates and executes"| node_session
node_session -->|"sends commands"| node_monitoring
node_monitoring -->|"streams updates"| node_session
node_user -->|"uses platform"| node_api
node_api -->|"dispatches requests"| node_workflow_routes
node_workflow_routes -->|"starts execution"| node_execution_manager
node_execution_manager -->|"reads organization and billing"| node_db
node_execution_manager -->|"dispatches workflow"| node_executor
node_executor -->|"runs workflow"| node_runtime_entry
node_runtime_entry -->|"executes nodes"| node_worker_runtime
node_worker_runtime -->|"persists execution data"| node_execution_store
node_worker_runtime -->|"accesses databases"| node_database_service
node_worker_runtime -->|"stores workflow objects"| node_object_store
node_worker_runtime -->|"invokes AI nodes"| node_ai
node_database_service -->|"uses D1"| node_external
node_object_store -->|"uses R2"| node_external
node_execution_store -->|"uses Cloudflare storage"| node_external
node_triggers -->|"initiates workflow"| node_execution_manager
node_user -->|"connects accounts"| node_oauth
node_integrations_api -->|"manages connections"| node_oauth
node_generator -->|"requests model synthesis"| node_external
node_generator -->|"previews generated workflow"| node_execution_manager

click node_editor "https://github.com/dafthunk-com/dafthunk/blob/main/apps/app/src/components/workflow/workflow-builder.tsx"
click node_session "https://github.com/dafthunk-com/dafthunk/blob/main/apps/app/src/services/workflow-session-service.ts"
click node_generator "https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/agents/workflow-generator/pipeline.ts"
click node_api "https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/index.ts"
click node_workflow_routes "https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/routes/workflows.ts"
click node_execution_manager "https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/services/execution-manager.ts"
click node_executor "https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/services/workflow-executor.ts"
click node_runtime_entry "https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/runtime/workflow-runtime-entrypoint.ts"
click node_worker_runtime "https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/runtime/cloudflare-worker-runtime.ts"
click node_execution_store "https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/runtime/cloudflare-execution-store.ts"
click node_database_service "https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/runtime/cloudflare-database-service.ts"
click node_object_store "https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/runtime/cloudflare-object-store.ts"
click node_db "https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/db/index.ts"
click node_triggers "https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/routes/http-triggers.ts"
click node_oauth "https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/oauth/index.ts"
click node_integrations_api "https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/routes/integrations.ts"
click node_monitoring "https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/routes/ws.ts"
click node_ai "https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/runtime/cloudflare-model-catalog.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_editor,node_session,node_generator,node_user toneBlue
class node_api,node_workflow_routes,node_execution_manager,node_executor,node_monitoring toneAmber
class node_runtime_entry,node_worker_runtime,node_ai toneMint
class node_execution_store,node_database_service,node_object_store,node_db toneRose
class node_triggers,node_oauth,node_integrations_api,node_external toneIndigo
```

## Components

### Workflow authoring

- [Visual editor](https://github.com/dafthunk-com/dafthunk/blob/main/apps/app/src/components/workflow/workflow-builder.tsx): `apps/app/src/components/workflow/workflow-builder.tsx`
- [Live workflow session](https://github.com/dafthunk-com/dafthunk/blob/main/apps/app/src/services/workflow-session-service.ts): `apps/app/src/services/workflow-session-service.ts`
- [Workflow generator](https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/agents/workflow-generator/pipeline.ts): `apps/api/src/agents/workflow-generator/pipeline.ts`

### API orchestration

- [API routes](https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/index.ts): `apps/api/src/index.ts`
- [Workflow routes](https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/routes/workflows.ts): `apps/api/src/routes/workflows.ts`
- [Execution manager](https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/services/execution-manager.ts): `apps/api/src/services/execution-manager.ts`
- [Workflow executor](https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/services/workflow-executor.ts): `apps/api/src/services/workflow-executor.ts`
- [Live execution updates](https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/routes/ws.ts): `apps/api/src/routes/ws.ts`

### Workflow runtime

- [Runtime entrypoint](https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/runtime/workflow-runtime-entrypoint.ts): `apps/api/src/runtime/workflow-runtime-entrypoint.ts`
- [Worker runtime](https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/runtime/cloudflare-worker-runtime.ts): `apps/api/src/runtime/cloudflare-worker-runtime.ts`
- [AI model services](https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/runtime/cloudflare-model-catalog.ts): `apps/api/src/runtime/cloudflare-model-catalog.ts`

### Platform resources

- [Execution state](https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/runtime/cloudflare-execution-store.ts): `apps/api/src/runtime/cloudflare-execution-store.ts`
- [Database service](https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/runtime/cloudflare-database-service.ts): `apps/api/src/runtime/cloudflare-database-service.ts`
- [Object storage](https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/runtime/cloudflare-object-store.ts): `apps/api/src/runtime/cloudflare-object-store.ts`
- [Application records](https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/db/index.ts): `apps/api/src/db/index.ts`

### Triggers and integrations

- [Workflow triggers](https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/routes/http-triggers.ts): `apps/api/src/routes/http-triggers.ts`
- [Integration OAuth](https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/oauth/index.ts): `apps/api/src/oauth/index.ts`
- [Integration endpoints](https://github.com/dafthunk-com/dafthunk/blob/main/apps/api/src/routes/integrations.ts): `apps/api/src/routes/integrations.ts`

### Other components

- **Workflow user**
- **Cloudflare services**

## Connections

- Workflow user → Visual editor: designs workflow
- Visual editor → Live workflow session: updates and executes
- Live workflow session → Live execution updates: sends commands
- Live execution updates → Live workflow session: streams updates
- Workflow user → API routes: uses platform
- API routes → Workflow routes: dispatches requests
- Workflow routes → Execution manager: starts execution
- Execution manager → Application records: reads organization and billing
- Execution manager → Workflow executor: dispatches workflow
- Workflow executor → Runtime entrypoint: runs workflow
- Runtime entrypoint → Worker runtime: executes nodes
- Worker runtime → Execution state: persists execution data
- Worker runtime → Database service: accesses databases
- Worker runtime → Object storage: stores workflow objects
- Worker runtime → AI model services: invokes AI nodes
- Database service → Cloudflare services: uses D1
- Object storage → Cloudflare services: uses R2
- Execution state → Cloudflare services: uses Cloudflare storage
- Workflow triggers → Execution manager: initiates workflow
- Workflow user → Integration OAuth: connects accounts
- Integration endpoints → Integration OAuth: manages connections
- Workflow generator → Cloudflare services: requests model synthesis
- Workflow generator → Execution manager: previews generated workflow
