4.2 KiB
4.2 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
This is Langflow - a low-code app builder for RAG and multi-agent AI applications. It's a Python-based visual IDE that allows users to build, test, and deploy AI workflows through a drag-and-drop interface. The project combines a FastAPI backend with a React frontend.
Architecture
Backend Structure
- Main Backend:
src/backend/langflow/- Entry point and versioning - Core Backend:
src/backend/base/langflow/- Main application logic with these key modules:api/- REST API endpoints and WebSocket handlersgraph/- Flow graph processing and execution enginecomponents/- Custom component definitions and implementationsservices/- Business logic services (database, auth, etc.)processing/- Data processing utilitiesschema/- Pydantic models and data structuresserialization/- Flow import/export functionality
Frontend Structure
- Main Frontend:
src/frontend/- React application with:- Modern React 18 with TypeScript
- Vite build system
- Tailwind CSS for styling
- React Flow for workflow visualization
- Chakra UI and Radix UI components
Key Technologies
- Backend: FastAPI, SQLAlchemy, Pydantic, Celery (for async tasks)
- Frontend: React 18, TypeScript, Vite, React Flow, Zustand (state management)
- Package Management: UV (Python), NPM (Node.js)
Development Commands
Backend Development
# Install backend dependencies
make install_backend
# Run backend in development mode
make backend
# Run backend with specific settings
make backend log_level=debug host=0.0.0.0 port=7860
# Run backend tests
make unit_tests
make integration_tests
make tests
# Lint and format backend
make format_backend
make lint
Frontend Development
# Install frontend dependencies
make install_frontend
# Run frontend in development mode
make frontend
# Build frontend for production
make build_frontend
# Run frontend tests
make tests_frontend
# Lint and format frontend
make format_frontend
Full Development Workflow
# Initialize the entire development environment
make init
# Run both frontend and backend
make run_frontend
make run_backend
# Build and run the complete application
make build_and_run
# Format all code
make format
Testing and Quality
# Run all tests with coverage
make coverage
# Run linters
make lint
# Format code
make format
# Check spelling
make codespell
Environment Setup
- Python: Requires Python 3.10-3.12
- Node.js: Required for frontend development
- Virtual Environment: Activated via
.venv/bin/activate - Environment Variables: Copy from
.env.exampleto.env
Database and Storage
- Database: SQLAlchemy with PostgreSQL/SQLite support
- Migrations: Alembic for database migrations
- Cache: Redis for caching and session storage
Key Features
- Visual IDE: Drag-and-drop workflow builder using React Flow
- Multi-agent Support: Orchestrates multiple AI agents and conversations
- RAG Pipelines: Complete RAG implementation with various vector stores
- API Publish: Export flows as APIs
- Observability: Integration with LangSmith, LangFuse, LangWatch
- Component System: Extensible component architecture for custom integrations
Testing Structure
- Unit Tests:
src/backend/tests/unit/ - Integration Tests:
src/backend/tests/integration/ - Frontend Tests:
src/frontend/__tests__/ - Test Framework: pytest with async support
- Coverage: Generated coverage reports with
make coverage
Custom Components
The project supports custom components through:
src/backend/base/langflow/custom/- Custom component definitions- Component registry system for dynamic loading
- Support for Python-based and API-based components
Deployment
- Docker: Multi-stage Docker builds for production
- Cloud: DataStax Langflow cloud service integration
- Self-hosted: Complete Docker Compose setup available
数据库
- 当使用sqlite时,数据库路径为src/backend/base/langflow/langflow.db
- 数据库路径为src/backend/base/langflow/langflow.db
- 使用中文回答