How tonikiri666/langflow works
Project type and purpose
• Langflow is a full-stack AI workflow builder. It consists of:
• A React/TypeScript single-page application (src/frontend)
• A Python/FastAPI Uvicorn server (src/backend/base/langflow + server.py)
• Background workers (Celery) for executing flows
• A relational database (Postgres via SQLAlchemy + Alembic migrations)
• An optional object storage (local disk or S3)
• External integrations (LLM APIs, vector DBs, telemetry, etc.)
• The README highlights visual flow authoring, built-in API server, multi-agent orchestration, and “deploy as API” capabilities.
File structure
• Top level:
• src/frontend → React SPA, Vite, custom nodes/components, Cypress/Playwright tests
• src/backend → FastAPI app, routers, services, models, Celery config, workers, scripts
• deploy/docker/docker_example → Docker Compose files for self-managed deployment
• scripts/aws and scripts/gcp → IaC (AWS CDK, GCP shell scripts)
• Patterns:
• MVC-like layering: routers → services → database models
• Asynchronous tasks via Celery (core/celery_app.py + services/task/backends)
• Infrastructure as code (CDK) and containerization (Dockerfiles per component).
README for additional insights
• Docs refer to “visual builder” (frontend), “built-in API server” (backend FastAPI), “background tasks” (flow execution), and “vector databases”/“LLM providers” (external services).
Main components
a. Frontend SPA
• React/TypeScript app served by Nginx (docker/frontend/nginx.conf)
• Communicates over REST/WebSocket with backend
b. API Server
• FastAPI app (main.py, server.py)
• Exposes HTTP endpoints (api/v1, api/v2) and WebSocket for playground
• Handles authentication, file management, user management, flow CRUD
c. Task Queue & Workers
• Celery broker (Redis or RabbitMQ)
• Celery workers (celery_app.py, core tasks) execute flow graphs
d. Database
• Postgres (SQLAlchemy models in services/database/models + Alembic migrations)
e. Storage
• Local disk or AWS S3 for file uploads (services/storage)
f. External Services
• LLM providers (OpenAI, Anthropic, etc.)
• Vector stores (Chroma, Pinecone, etc.)
• Telemetry/tracing (LangSmith, LangFuse)
Relationships and interactions
• Frontend → Backend: HTTP/HTTPS requests & WebSocket
• Backend → Database: SQL queries via ORM
• Backend → Broker: publish tasks to Celery broker
• Workers → External LLMs/Vector DBs: HTTP/SDK calls
• Backend → Storage: read/write file objects
• Backend/Workers → Telemetry APIs
Architectural patterns and design principles
• Layered architecture: Controllers (routers) → Domain services → Data access
• Asynchronous processing: Task queue pattern for long-running flows
• Containerized micro-services: Separate containers for frontend, API, workers, broker, database
• Infrastructure as Code: CDK stacks define VPC, ECS/ECR or Lambda deployments
Relevant technologies
• Frontend: React, Zustand, React-Flow, TypeScript, Vite, Playwright/Cypress
• Backend: Python 3.10+, FastAPI, Uvicorn, Pydantic, SQLAlchemy, Alembic, Celery
• Broker: Redis or RabbitMQ
• Database: Postgres
• Storage: Local FS or S3
• IaC: AWS CDK (TypeScript), GCP deploy scripts
• Containerization: Docker, Docker Compose
Essential details
• API’s dual role: responding synchronously and dispatching asynchronous flows
• Pluggable integrations layer (components/*.py) and vector store abstractions