# kafein-technology/kai-flow architecture

> Architecture diagram of the GitHub repository kafein-technology/kai-flow, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kafein-technology/kai-flow
- Repository: https://github.com/kafein-technology/kai-flow

## Overview

KAI Flow is a visual platform for building, testing, and deploying AI-powered workflow assistants. Users configure workflows on the React canvas, then invoke them through the backend’s workflow execution APIs or documented triggers; the engine builds and runs graphs of registered nodes, which cover agents, models, tools, document processing, memory, vectors, and integrations. The platform also documents an embeddable chat widget and model-security scanning. Edges are limited to relationships shown in excerpts, indexed imports, or README statements; several capabilities are represented by their exact source directories because their implementation was not sampled.

Main entry points: [`backend/main.py`](https://github.com/kafein-technology/kai-flow/blob/main/backend/main.py) (FastAPI application), [`backend/app/core/engine.py`](https://github.com/kafein-technology/kai-flow/blob/main/backend/app/core/engine.py) (Workflow engine), [`backend/app/api/workflows.py`](https://github.com/kafein-technology/kai-flow/blob/main/backend/app/api/workflows.py) (Workflow endpoints), [`backend/app/core/graph_builder`](https://github.com/kafein-technology/kai-flow/tree/main/backend/app/core/graph_builder) (Graph builder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Workflow interface"]
  node_canvas["Workflow canvas"]
  node_client_app["Web application<br/>[App.tsx]"]
  node_client_services["Client API services<br/>[workflows.ts]"]
  node_widget["Embeddable chat widget<br/>[KaiChatWidget.tsx]"]
end

subgraph group_api["Backend product APIs"]
  node_backend["FastAPI application<br/>[main.py]"]
  node_workflow_api["Workflow endpoints<br/>[workflows.py]"]
  node_execution_api["Execution endpoints<br/>[executions.py]"]
  node_webhook_api["Webhook management<br/>[webhooks.py]"]
  node_ai_builder_api["AI builder endpoint<br/>[ai_builder.py]"]
  node_webhook_service["Webhook service<br/>[webhook_service.py]"]
end

subgraph group_runtime["Workflow runtime"]
  node_engine["Workflow engine<br/>[engine.py]"]
  node_graph_builder["Graph builder"]
  node_dynamic_engine["Dynamic workflow engine"]
  node_registry["Node registry<br/>[node_registry.py]"]
  node_node_base["Node execution contract<br/>[base.py]"]
end

subgraph group_capabilities["AI and data capabilities"]
  node_node_catalog["Workflow node catalog"]
  node_vector["Vector search and storage"]
  node_documents["Document processing<br/>[documents.py]"]
  node_chat["Chat and memory<br/>[chat.py]"]
  node_triggers["Workflow triggers"]
  node_model_security["Model security scanning"]
end

subgraph group_platform["Identity and security"]
  node_auth["Authentication<br/>[dependencies.py]"]
  node_database[("PostgreSQL data store<br/>[database.py]")]
  node_tracing["Workflow tracing<br/>[tracing.py]"]
end

node_user(("Workflow author"))
node_external_site(("Host website"))

node_user -->|"uses"| node_client_app
node_client_app -->|"routes to"| node_canvas
node_canvas -.->|"configures"| node_client_services
node_client_services -.->|"calls API"| node_backend
node_backend -->|"registers"| node_workflow_api
node_backend -->|"registers"| node_execution_api
node_backend -->|"registers"| node_webhook_api
node_backend -->|"registers"| node_ai_builder_api
node_workflow_api -.->|"executes workflow"| node_engine
node_execution_api -.->|"runs workflow"| node_engine
node_webhook_api -->|"delegates to"| node_webhook_service
node_ai_builder_api -.->|"builds workflows"| node_node_catalog
node_engine -->|"discovers nodes"| node_registry
node_engine -->|"constructs graphs"| node_graph_builder
node_graph_builder -->|"executes nodes"| node_node_base
node_graph_builder -->|"traces execution"| node_tracing
node_registry -->|"registers types"| node_node_base
node_dynamic_engine -->|"builds on"| node_graph_builder
node_dynamic_engine -->|"resolves instances"| node_node_base
node_node_catalog -.->|"includes"| node_vector
node_triggers -->|"starts workflows"| node_engine
node_backend -->|"initializes"| node_database
node_backend -->|"configures"| node_tracing
node_widget -->|"embeds in"| node_external_site
node_user -.->|"scans artifacts"| node_model_security
node_workflow_api -.->|"authenticates"| node_auth
node_workflow_api -.->|"stores workflows"| node_database

click node_canvas "https://github.com/kafein-technology/kai-flow/blob/main/client/app/components/canvas/ReactFlowCanvas.tsx"
click node_client_app "https://github.com/kafein-technology/kai-flow/blob/main/client/app/App.tsx"
click node_client_services "https://github.com/kafein-technology/kai-flow/blob/main/client/app/services/workflows.ts"
click node_widget "https://github.com/kafein-technology/kai-flow/blob/main/widget/src/KaiChatWidget.tsx"
click node_backend "https://github.com/kafein-technology/kai-flow/blob/main/backend/main.py"
click node_workflow_api "https://github.com/kafein-technology/kai-flow/blob/main/backend/app/api/workflows.py"
click node_execution_api "https://github.com/kafein-technology/kai-flow/blob/main/backend/app/api/executions.py"
click node_webhook_api "https://github.com/kafein-technology/kai-flow/blob/main/backend/app/api/webhooks.py"
click node_ai_builder_api "https://github.com/kafein-technology/kai-flow/blob/main/backend/app/api/ai_builder.py"
click node_webhook_service "https://github.com/kafein-technology/kai-flow/blob/main/backend/app/services/webhook_service.py"
click node_engine "https://github.com/kafein-technology/kai-flow/blob/main/backend/app/core/engine.py"
click node_graph_builder "https://github.com/kafein-technology/kai-flow/tree/main/backend/app/core/graph_builder"
click node_dynamic_engine "https://github.com/kafein-technology/kai-flow/blob/main/backend/app/core/dynamic_workflow_engine.py"
click node_registry "https://github.com/kafein-technology/kai-flow/blob/main/backend/app/core/node_registry.py"
click node_node_base "https://github.com/kafein-technology/kai-flow/blob/main/backend/app/nodes/base.py"
click node_node_catalog "https://github.com/kafein-technology/kai-flow/tree/main/backend/app/nodes"
click node_vector "https://github.com/kafein-technology/kai-flow/tree/main/backend/app/nodes/vector_stores"
click node_documents "https://github.com/kafein-technology/kai-flow/blob/main/backend/app/api/documents.py"
click node_chat "https://github.com/kafein-technology/kai-flow/blob/main/backend/app/api/chat.py"
click node_triggers "https://github.com/kafein-technology/kai-flow/tree/main/backend/app/nodes/triggers"
click node_model_security "https://github.com/kafein-technology/kai-flow/blob/main/backend/app/services/llm_model_scanner_service.py"
click node_auth "https://github.com/kafein-technology/kai-flow/blob/main/backend/app/auth/dependencies.py"
click node_database "https://github.com/kafein-technology/kai-flow/blob/main/backend/app/core/database.py"
click node_tracing "https://github.com/kafein-technology/kai-flow/blob/main/backend/app/core/tracing.py"

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_canvas,node_client_app,node_client_services,node_widget toneBlue
class node_backend,node_workflow_api,node_execution_api,node_webhook_api,node_ai_builder_api,node_webhook_service toneAmber
class node_engine,node_graph_builder,node_dynamic_engine,node_registry,node_node_base toneMint
class node_node_catalog,node_vector,node_documents,node_chat,node_triggers,node_model_security toneRose
class node_auth,node_database,node_tracing,node_user,node_external_site toneIndigo
```

## Components

### Workflow interface

- [Workflow canvas](https://github.com/kafein-technology/kai-flow/blob/main/client/app/components/canvas/ReactFlowCanvas.tsx): `client/app/components/canvas/ReactFlowCanvas.tsx`
- [Web application](https://github.com/kafein-technology/kai-flow/blob/main/client/app/App.tsx): `client/app/App.tsx`
- [Client API services](https://github.com/kafein-technology/kai-flow/blob/main/client/app/services/workflows.ts): `client/app/services/workflows.ts`
- [Embeddable chat widget](https://github.com/kafein-technology/kai-flow/blob/main/widget/src/KaiChatWidget.tsx): `widget/src/KaiChatWidget.tsx`

### Backend product APIs

- [FastAPI application](https://github.com/kafein-technology/kai-flow/blob/main/backend/main.py): `backend/main.py`
- [Workflow endpoints](https://github.com/kafein-technology/kai-flow/blob/main/backend/app/api/workflows.py): `backend/app/api/workflows.py`
- [Execution endpoints](https://github.com/kafein-technology/kai-flow/blob/main/backend/app/api/executions.py): `backend/app/api/executions.py`
- [Webhook management](https://github.com/kafein-technology/kai-flow/blob/main/backend/app/api/webhooks.py): `backend/app/api/webhooks.py`
- [AI builder endpoint](https://github.com/kafein-technology/kai-flow/blob/main/backend/app/api/ai_builder.py): `backend/app/api/ai_builder.py`
- [Webhook service](https://github.com/kafein-technology/kai-flow/blob/main/backend/app/services/webhook_service.py): `backend/app/services/webhook_service.py`

### Workflow runtime

- [Workflow engine](https://github.com/kafein-technology/kai-flow/blob/main/backend/app/core/engine.py): `backend/app/core/engine.py`
- [Graph builder](https://github.com/kafein-technology/kai-flow/tree/main/backend/app/core/graph_builder): `backend/app/core/graph_builder`
- [Dynamic workflow engine](https://github.com/kafein-technology/kai-flow/blob/main/backend/app/core/dynamic_workflow_engine.py): `backend/app/core/dynamic_workflow_engine.py`
- [Node registry](https://github.com/kafein-technology/kai-flow/blob/main/backend/app/core/node_registry.py): `backend/app/core/node_registry.py`
- [Node execution contract](https://github.com/kafein-technology/kai-flow/blob/main/backend/app/nodes/base.py): `backend/app/nodes/base.py`

### AI and data capabilities

- [Workflow node catalog](https://github.com/kafein-technology/kai-flow/tree/main/backend/app/nodes): `backend/app/nodes`
- [Vector search and storage](https://github.com/kafein-technology/kai-flow/tree/main/backend/app/nodes/vector_stores): `backend/app/nodes/vector_stores`
- [Document processing](https://github.com/kafein-technology/kai-flow/blob/main/backend/app/api/documents.py): `backend/app/api/documents.py`
- [Chat and memory](https://github.com/kafein-technology/kai-flow/blob/main/backend/app/api/chat.py): `backend/app/api/chat.py`
- [Workflow triggers](https://github.com/kafein-technology/kai-flow/tree/main/backend/app/nodes/triggers): `backend/app/nodes/triggers`
- [Model security scanning](https://github.com/kafein-technology/kai-flow/blob/main/backend/app/services/llm_model_scanner_service.py): `backend/app/services/llm_model_scanner_service.py`

### Identity and security

- [Authentication](https://github.com/kafein-technology/kai-flow/blob/main/backend/app/auth/dependencies.py): `backend/app/auth/dependencies.py`
- [PostgreSQL data store](https://github.com/kafein-technology/kai-flow/blob/main/backend/app/core/database.py): `backend/app/core/database.py`
- [Workflow tracing](https://github.com/kafein-technology/kai-flow/blob/main/backend/app/core/tracing.py): `backend/app/core/tracing.py`

### Other components

- **Workflow author**
- **Host website**

## Connections

- Workflow author → Web application: uses (evidence: `README.md`)
- Web application → Workflow canvas: routes to (evidence: `client/app/App.tsx`)
- Workflow canvas → Client API services: configures
- Client API services → FastAPI application: calls API
- FastAPI application → Workflow endpoints: registers (evidence: `backend/main.py`)
- FastAPI application → Execution endpoints: registers (evidence: `backend/main.py`)
- FastAPI application → Webhook management: registers (evidence: `backend/main.py`)
- FastAPI application → AI builder endpoint: registers (evidence: `backend/main.py`)
- Workflow endpoints → Workflow engine: executes workflow
- Execution endpoints → Workflow engine: runs workflow
- Webhook management → Webhook service: delegates to (evidence: `backend/app/api/webhooks.py`)
- AI builder endpoint → Workflow node catalog: builds workflows
- Workflow engine → Node registry: discovers nodes (evidence: `backend/app/core/engine.py`)
- Workflow engine → Graph builder: constructs graphs (evidence: `backend/app/core/engine.py`)
- Graph builder → Node execution contract: executes nodes (evidence: `backend/app/core/graph_builder/__init__.py`)
- Graph builder → Workflow tracing: traces execution (evidence: `backend/app/core/graph_builder/__init__.py`)
- Node registry → Node execution contract: registers types (evidence: `backend/app/core/node_registry.py`)
- Dynamic workflow engine → Graph builder: builds on (evidence: `backend/app/core/dynamic_workflow_engine.py`)
- Dynamic workflow engine → Node execution contract: resolves instances (evidence: `backend/app/core/dynamic_workflow_engine.py`)
- Workflow node catalog → Vector search and storage: includes (evidence: `README.md`)
- Workflow triggers → Workflow engine: starts workflows (evidence: `backend/app/nodes/triggers/webhook_trigger.py`)
- FastAPI application → PostgreSQL data store: initializes (evidence: `backend/main.py`)
- FastAPI application → Workflow tracing: configures (evidence: `backend/main.py`)
- Embeddable chat widget → Host website: embeds in (evidence: `README.md`)
- Workflow author → Model security scanning: scans artifacts (evidence: `README.md`)
- Workflow endpoints → Authentication: authenticates
- Workflow endpoints → PostgreSQL data store: stores workflows
