# RAGFlow Project Instructions for GitHub Copilot This file provides context, build instructions, and coding standards for the RAGFlow project. It is structured to follow GitHub Copilot's [customization guidelines](https://docs.github.com/en/copilot/concepts/prompting/response-customization). ## 1. Project Overview RAGFlow is an open-source RAG (Retrieval-Augmented Generation) engine based on deep document understanding. It is a full-stack application with a Python backend and a React/TypeScript frontend. - **Backend**: Python 3.10+ (Flask/Quart) - **Frontend**: TypeScript, React, UmiJS - **Architecture**: Microservices based on Docker. - `api/`: Backend API server. - `rag/`: Core RAG logic (indexing, retrieval). - `deepdoc/`: Document parsing and OCR. - `web/`: Frontend application. ## 2. Directory Structure - `api/`: Backend API server (Flask/Quart). - `apps/`: API Blueprints (Knowledge Base, Chat, etc.). - `db/`: Database models and services. - `rag/`: Core RAG logic. - `llm/`: LLM, Embedding, and Rerank model abstractions. - `deepdoc/`: Document parsing and OCR modules. - `agent/`: Agentic reasoning components. - `web/`: Frontend application (React + UmiJS). - `docker/`: Docker deployment configurations. - `sdk/`: Python SDK. - `test/`: Backend tests. ## 3. Build Instructions ### Backend (Python) The project uses **uv** for dependency management. 1. **Setup Environment**: ```bash uv sync --python 3.11 --all-extras uv run download_deps.py ``` 2. **Run Server**: - **Pre-requisite**: Start dependent services (MySQL, ES/Infinity, Redis, MinIO). ```bash docker compose -f docker/docker-compose-base.yml up -d ``` - **Launch**: ```bash source .venv/bin/activate export PYTHONPATH=$(pwd) bash docker/launch_backend_service.sh ``` ### Frontend (TypeScript/React) Located in `web/`. 1. **Install Dependencies**: ```bash cd web npm install ``` 2. **Run Dev Server**: ```bash npm run dev ``` Runs on port 8000 by default. ### Docker Deployment To run the full stack using Docker: ```bash cd docker docker compose -f docker-compose.yml up -d ``` ## 4. Testing Instructions ### Backend Tests - **Run All Tests**: ```bash uv run pytest ``` - **Run Specific Test**: ```bash uv run pytest test/test_api.py ``` ### Frontend Tests - **Run Tests**: ```bash cd web npm run test ``` ## 5. Coding Standards & Guidelines - **Python Formatting**: Use `ruff` for linting and formatting. ```bash ruff check ruff format ``` - **Frontend Linting**: ```bash cd web npm run lint ``` - **Pre-commit**: Ensure pre-commit hooks are installed. ```bash pre-commit install pre-commit run --all-files ```