# langflow-ai/langflow architecture

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

- Interactive diagram: https://gitdiagram.com/langflow-ai/langflow
- Repository: https://github.com/langflow-ai/langflow

## Overview

Langflow is a visual platform for authoring, testing, and deploying AI workflows and agents. A user builds or opens a flow in the web application, invokes it through chat, an API, or MCP, and receives model/tool results. The runtime prepares and validates the graph, executes components, and persists flow, job, knowledge-base, and session state. Major documented branches include multi-agent orchestration, retrieval, custom components, observability, API deployment, and MCP exposure. Some links are inferred from module responsibilities because most implementation files were not sampled.

Main entry points: [`src/backend/base/langflow/api/router.py`](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/api/router.py) (API Router), [`src/backend/base/langflow/agentic/services/flow_run.py`](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/agentic/services/flow_run.py) (Flow Run), [`src/backend/base/langflow/agentic/services/flow_executor.py`](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/agentic/services/flow_executor.py) (Flow Executor), [`src/backend/base/langflow/services/database/factory.py`](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/services/database/factory.py) (Application Database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client Experience"]
  node_web_routes["Web Application<br/>[routes.tsx]"]
  node_assistant_sessions["Assistant Sessions<br/>[session-storage.ts]"]
  node_api_router["API Router<br/>[router.py]"]
  node_flow_endpoints["Flow Endpoints<br/>[flows.py]"]
  node_chat_api["Chat API<br/>[chat.py]"]
  node_mcp_server["MCP Server<br/>[server.py]"]
end

subgraph group_runtime["Flow Runtime"]
  node_flow_preparation["Flow Preparation"]
  node_flow_validation["Flow Validation<br/>[flow_validation.py]"]
  node_flow_run["Flow Run<br/>[flow_run.py]"]
  node_flow_executor["Flow Executor<br/>[flow_executor.py]"]
  node_component_runtime["Component Runtime<br/>[run.py]"]
  node_conditional_router["LLM Router"]
end

subgraph group_platform["Platform Services"]
  node_auth_service["Authentication<br/>[service.py]"]
  node_authorization["Authorization<br/>[service.py]"]
  node_database[("Application Database<br/>[factory.py]")]
  node_ingestion["KB Ingestion"]
  node_file_storage["File Storage<br/>[storage_utils.py]"]
  node_background_jobs["Background Jobs<br/>[service.py]"]
end

subgraph group_integrations["External Integrations"]
  node_deployment_service["Deployment Service<br/>[service.py]"]
  node_observability_api["Trace API<br/>[traces.py]"]
end

node_developer(("Developer/User"))
node_llm_provider["LLM Providers"]
node_object_storage[("Object Storage")]
node_mcp_clients(("MCP Clients"))
node_deployment_target["Deployment Target"]
node_observability_service["Observability Services"]

node_developer -->|"authors flows"| node_web_routes
node_developer -->|"uses assistant"| node_assistant_sessions
node_developer -->|"calls API"| node_api_router
node_mcp_clients -->|"invokes tools"| node_mcp_server
node_api_router -->|"authenticates"| node_auth_service
node_api_router -->|"checks access"| node_authorization
node_api_router -->|"dispatches flows"| node_flow_endpoints
node_flow_endpoints -->|"reads/writes"| node_database
node_chat_api -->|"starts run"| node_flow_run
node_mcp_server -->|"starts run"| node_flow_run
node_flow_run -->|"prepares graph"| node_flow_preparation
node_flow_preparation -->|"validates graph"| node_flow_validation
node_flow_run -->|"executes flow"| node_flow_executor
node_flow_executor -->|"runs components"| node_component_runtime
node_conditional_router -->|"invokes model"| node_llm_provider
node_flow_executor -->|"runs router"| node_conditional_router
node_ingestion -->|"updates jobs"| node_database
node_file_storage -.->|"reads/writes files"| node_object_storage
node_background_jobs -->|"tracks jobs"| node_database
node_deployment_service -.->|"deploys flows"| node_deployment_target
node_observability_api -.->|"exports traces"| node_observability_service

click node_web_routes "https://github.com/langflow-ai/langflow/blob/main/src/frontend/src/routes.tsx"
click node_assistant_sessions "https://github.com/langflow-ai/langflow/blob/main/src/frontend/src/components/core/assistantPanel/helpers/session-storage.ts"
click node_api_router "https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/api/router.py"
click node_flow_endpoints "https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/api/v1/flows.py"
click node_chat_api "https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/api/v1/chat.py"
click node_mcp_server "https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/agentic/mcp/server.py"
click node_flow_preparation "https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/agentic/services/flow_preparation.py"
click node_flow_validation "https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/agentic/services/flow_validation.py"
click node_flow_run "https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/agentic/services/flow_run.py"
click node_flow_executor "https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/agentic/services/flow_executor.py"
click node_component_runtime "https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/interface/run.py"
click node_conditional_router "https://github.com/langflow-ai/langflow/blob/main/src/lfx/src/lfx/components/llm_operations/llm_conditional_router.py"
click node_auth_service "https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/services/auth/service.py"
click node_authorization "https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/services/authorization/service.py"
click node_database "https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/services/database/factory.py"
click node_ingestion "https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/api/utils/ingestion_run_service.py"
click node_file_storage "https://github.com/langflow-ai/langflow/blob/main/src/lfx/src/lfx/base/data/storage_utils.py"
click node_background_jobs "https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/services/background_execution/service.py"
click node_deployment_service "https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/services/adapters/deployment/watsonx_orchestrate/service.py"
click node_observability_api "https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/api/v1/traces.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_web_routes,node_assistant_sessions,node_api_router,node_flow_endpoints,node_chat_api,node_mcp_server,node_developer,node_mcp_clients toneBlue
class node_flow_preparation,node_flow_validation,node_flow_run,node_flow_executor,node_component_runtime,node_conditional_router,node_object_storage toneAmber
class node_auth_service,node_authorization,node_database,node_ingestion,node_file_storage,node_background_jobs toneMint
class node_deployment_service,node_observability_api toneRose
class node_llm_provider,node_deployment_target,node_observability_service toneIndigo
```

## Components

### Client Experience

- [Web Application](https://github.com/langflow-ai/langflow/blob/main/src/frontend/src/routes.tsx): `src/frontend/src/routes.tsx`
- [Assistant Sessions](https://github.com/langflow-ai/langflow/blob/main/src/frontend/src/components/core/assistantPanel/helpers/session-storage.ts): `src/frontend/src/components/core/assistantPanel/helpers/session-storage.ts`
- [API Router](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/api/router.py): `src/backend/base/langflow/api/router.py`
- [Flow Endpoints](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/api/v1/flows.py): `src/backend/base/langflow/api/v1/flows.py`
- [Chat API](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/api/v1/chat.py): `src/backend/base/langflow/api/v1/chat.py`
- [MCP Server](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/agentic/mcp/server.py): `src/backend/base/langflow/agentic/mcp/server.py`

### Flow Runtime

- [Flow Preparation](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/agentic/services/flow_preparation.py): `src/backend/base/langflow/agentic/services/flow_preparation.py`
- [Flow Validation](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/agentic/services/flow_validation.py): `src/backend/base/langflow/agentic/services/flow_validation.py`
- [Flow Run](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/agentic/services/flow_run.py): `src/backend/base/langflow/agentic/services/flow_run.py`
- [Flow Executor](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/agentic/services/flow_executor.py): `src/backend/base/langflow/agentic/services/flow_executor.py`
- [Component Runtime](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/interface/run.py): `src/backend/base/langflow/interface/run.py`
- [LLM Router](https://github.com/langflow-ai/langflow/blob/main/src/lfx/src/lfx/components/llm_operations/llm_conditional_router.py): `src/lfx/src/lfx/components/llm_operations/llm_conditional_router.py`

### Platform Services

- [Authentication](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/services/auth/service.py): `src/backend/base/langflow/services/auth/service.py`
- [Authorization](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/services/authorization/service.py): `src/backend/base/langflow/services/authorization/service.py`
- [Application Database](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/services/database/factory.py): `src/backend/base/langflow/services/database/factory.py`
- [KB Ingestion](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/api/utils/ingestion_run_service.py): `src/backend/base/langflow/api/utils/ingestion_run_service.py`
- [File Storage](https://github.com/langflow-ai/langflow/blob/main/src/lfx/src/lfx/base/data/storage_utils.py): `src/lfx/src/lfx/base/data/storage_utils.py`
- [Background Jobs](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/services/background_execution/service.py): `src/backend/base/langflow/services/background_execution/service.py`

### External Integrations

- [Deployment Service](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/services/adapters/deployment/watsonx_orchestrate/service.py): `src/backend/base/langflow/services/adapters/deployment/watsonx_orchestrate/service.py`
- [Trace API](https://github.com/langflow-ai/langflow/blob/main/src/backend/base/langflow/api/v1/traces.py): `src/backend/base/langflow/api/v1/traces.py`

### Other components

- **Developer/User**
- **LLM Providers**
- **Object Storage**
- **MCP Clients**
- **Deployment Target**
- **Observability Services**

## Connections

- Developer/User → Web Application: authors flows
- Developer/User → Assistant Sessions: uses assistant
- Developer/User → API Router: calls API
- MCP Clients → MCP Server: invokes tools
- API Router → Authentication: authenticates
- API Router → Authorization: checks access
- API Router → Flow Endpoints: dispatches flows
- Flow Endpoints → Application Database: reads/writes
- Chat API → Flow Run: starts run
- MCP Server → Flow Run: starts run
- Flow Run → Flow Preparation: prepares graph
- Flow Preparation → Flow Validation: validates graph
- Flow Run → Flow Executor: executes flow
- Flow Executor → Component Runtime: runs components
- LLM Router → LLM Providers: invokes model
- Flow Executor → LLM Router: runs router
- KB Ingestion → Application Database: updates jobs
- File Storage → Object Storage: reads/writes files
- Background Jobs → Application Database: tracks jobs
- Deployment Service → Deployment Target: deploys flows
- Trace API → Observability Services: exports traces
