$ show langflow-ai/langflow
Langflow is a full-stack, open-source platform for building and deploying AI-powered agents and workflows. It provides a visual flow builder (React frontend), a Python backend (FastAPI/SQLModel), a CLI executor (LFX), an MCP server for AI tool integration, and a Python SDK. The codebase is a monorepo with multiple packages: the main `langflow` distribution, `langflow-base` (core backend), `lfx` (lightweight executor/CLI), `langflow-sdk` (API client), `langflow-stepflow` (step-based execution), and extension bundles (e.g., lfx-duckduckgo, lfx-arxiv, lfx-ibm, lfx-docling). The backend uses SQLModel with Alembic migrations, Celery for background tasks, FastAPI for REST endpoints, and a plugin/extension system for bundles. The frontend is a React/TypeScript app built with Vite, React Flow, Zustand, and Tailwind. The architecture supports multi-worker deployments, auto-login, JWT auth, rate limiting, MCP server integration, and a rich component library for LLMs, vector stores, tools, and data processing.
The LLM identified 10 files worth highlighting for reuse:
Custom Gunicorn application with LangflowUvicornWorker that handles proxy headers, graceful shutdown with progress tracking, Sentry initialization, and pre-fork hooks that detect ghost threads/TCP connections and run GC. The lifespan manages full startup/shutdown sequences including bundle loading, component caching, MCP servers, and telemetry. Production-grade async server lifecycle management.
FastAPI app factory with comprehensive middleware stack (CORS, locale detection, request cancellation, content size limits, forwarded prefix), lifespan manager for startup/shutdown, Sentry middleware, rate limiting via SlowAPI, and plugin route loading. Handles multipart boundary validation, query string flattening, and OTel instrumentation patching.
FastMCP server exposing Langflow operations as MCP tools for AI agents. Provides flow CRUD, component management (add/remove/configure/search), connection management, execution (run/validate/build), batch operations with result references, and starter project templates. Enables AI assistants to build and modify Langflow flows programmatically.
ASGI app factory for serving LFX flows via FastAPI. Features FlowRegistry with in-memory caching and filesystem-backed persistence for multi-worker deployments, API key verification, streaming SSE endpoints, flow upload with UUID validation, and per-request stale checks for cross-worker consistency. Supports no-env-fallback mode for credential isolation.
Runs assistant-built flows in-process with security scanning of component code before execution, token usage extraction from graph vertices, timeout handling with metrics, and friendly error messages. Measures wall-clock duration (not ResultData.timedelta which is never populated) and returns size-capped output text. Includes canonical code exemption for trusted built-in components.
Comprehensive startup setup that loads starter projects and bundles from URLs (GitHub repos), syncs component versions, migrates legacy flows, copies profile pictures, and manages folder creation. Handles flow upsertion by endpoint_name/id/name matching, edge reconciliation for missing nodes, and agentic flow creation. Uses file locking for multi-worker safety.
Main flow canvas component using React Flow with comprehensive keyboard shortcuts (undo/redo, copy/paste, group, delete, cut), drag-and-drop from sidebar, auto-save, helper lines for alignment, node context menus, selection handling, and agent badge overlay. Integrates with Zustand stores for flow state management.
Generic node component for React Flow with dynamic handle rendering, node toolbar (code, freeze, share, delete, tool mode), build status display with token usage and duration, output selection dropdown, minimize/expand, and update component banner. Supports emoji icons, Lucide icons, and custom node types.
Dynamic parameter renderer that dispatches to specific input components based on field type (text, int, float, bool, file, prompt, mustache, dropdown, model, MCP, code, table, slider, etc.). Handles tool mode, node information metadata, refresh buttons, and validation. Central to the component configuration UI.
Agentic MCP server providing template search/creation, component search/retrieval, flow graph visualization (ASCII + text), and assistant execution. Enables AI agents to search templates, create flows, explore components, and run assistant instructions with result persistence.