How biglanmao/lightrag works
LightRAG is a knowledge-graph-enhanced retrieval-augmented generation system, exposed through an API and a web interface. Its main user workflow is to submit documents for parsing, chunking, and indexing, then query the resulting knowledge using retrieval and LLM generation; users can also inspect and manage documents and the graph. The repository supports multiple parser, chunker, LLM, and storage options. Some connections below are dashed because the relevant runtime call sites were not included in the excerpts; those links are architectural inferences, not verified calls.
Main entry points: pipeline.py Ingestion Pipeline · lightrag_server.py API Server · lightrag.py LightRAG Core · routing.py Parser Routing
Components 25
API and Web UI
- API Server
lightrag/api/lightrag_server.py - Document Routes
lightrag/api/routers/document_routes.py - Query Routes
lightrag/api/routers/query_routes.py - Graph Routes
lightrag/api/routers/graph_routes.py - Web Interface
lightrag_webui/src/features/DocumentManager.tsx
Document Ingestion
- LightRAG Core
lightrag/lightrag.py - Ingestion Pipeline
lightrag/pipeline.py - Parser Routing
lightrag/parser/routing.py - Parser Registry
lightrag/parser/registry.py - Chunker Registry
lightrag/chunker/registry.py - Recursive Chunker
lightrag/chunker/recursive_character.py
Retrieval and Generation
- Query Operations
lightrag/operate.py
Storage and Coordination
- Storage Contracts
lightrag/base.py - Storage Factory
lightrag/kg/factory.py - Key-Value Storage
lightrag/kg/json_kv_impl.py - Configuration Store
lightrag/config_store.py - Shared Coordination
lightrag/kg/shared_storage.py - Pipeline Ingress
lightrag/kg/pipeline_ingress.py - Workspace Namespaces
lightrag/namespace.py - Pipeline Metrics
lightrag/pipeline_metrics.py
Pluggable Engines
- LLM Adapters
lightrag/llm/openai.py - Docling Parser
lightrag/parser/external/docling/client.py - MinerU Parser
lightrag/parser/external/mineru/client.py
Other components
- User
- LLM Service
Connections 28
- User → Web Interface: uses
README.md - User → API Server: submits requests
README.md - Web Interface → API Server: calls API
- API Server → Document Routes: routes documents
- API Server → Query Routes: routes queries
- API Server → Graph Routes: routes graph
- Document Routes → LightRAG Core: invokes document operations
lightrag/api/routers/document_routes.py - Query Routes → LightRAG Core: runs queries
- Graph Routes → LightRAG Core: reads graph
- LightRAG Core → Ingestion Pipeline: mixes in
lightrag/pipeline.py - Ingestion Pipeline → Parser Routing: selects parser
lightrag/pipeline.py - Parser Routing → Parser Registry: resolves parser
lightrag/parser/routing.py - Parser Routing → Docling Parser: dispatches parsing
- Parser Routing → MinerU Parser: dispatches parsing
- Ingestion Pipeline → Chunker Registry: selects chunker
lightrag/pipeline.py - Chunker Registry → Recursive Chunker: provides strategy
lightrag/chunker/registry.py - Ingestion Pipeline → Query Operations: uses operations
lightrag/pipeline.py - Query Operations → LLM Adapters: requests generation
- LLM Adapters → LLM Service: calls model
- LightRAG Core → Storage Factory: selects storage
- Storage Factory → Storage Contracts: implements contracts
lightrag/kg/factory.py - Storage Factory → Key-Value Storage: creates backend
lightrag/kg/factory.py - Configuration Store → Workspace Namespaces: uses namespaces
lightrag/config_store.py - Configuration Store → Shared Coordination: coordinates storage
lightrag/config_store.py - Shared Coordination → Pipeline Ingress: provides ingress
lightrag/kg/shared_storage.py - Shared Coordination → Pipeline Metrics: aggregates metrics
lightrag/kg/shared_storage.py - Ingestion Pipeline → Shared Coordination: coordinates workers
lightrag/pipeline.py - Ingestion Pipeline → Pipeline Ingress: signals work
lightrag/pipeline.py