How dlozf/lightrag works
LightRAG is a retrieval-augmented generation system that turns uploaded or submitted documents into searchable knowledge and answers user queries from that knowledge. The main workflow is document intake, parsing and chunking, pipeline scheduling and extraction, storage, then query retrieval and LLM response; the API and WebUI expose document, query, and graph-visualization capabilities. Storage backends and model providers are pluggable. The source excerpts show only parts of this system, so links to unsampled implementation details are omitted or marked unverified.
Main entry points: pipeline.py Ingestion pipeline · lightrag.py LightRAG engine · DocumentManager.tsx WebUI · document_routes.py Document API
Components 18
User interfaces
- WebUI
lightrag_webui/src/features/DocumentManager.tsx - Document API
lightrag/api/routers/document_routes.py - Query API
lightrag/api/routers/query_routes.py - Graph API
lightrag/api/routers/graph_routes.py
Document ingestion
- Document parsing
lightrag/parser/routing.py - External parsers
lightrag/parser/external/_common.py - Text chunking
lightrag/chunker/registry.py - Ingestion pipeline
lightrag/pipeline.py - Pipeline ingress
lightrag/kg/pipeline_ingress.py - Pipeline coordination
lightrag/kg/shared_storage.py
Knowledge and retrieval
- LightRAG engine
lightrag/lightrag.py - RAG operations
lightrag/operate.py - Query validation
lightrag/query_validation.py
Storage and models
- Storage contracts
lightrag/base.py - Storage factory
lightrag/kg/factory.py - Storage backends
lightrag/kg/opensearch_impl.py - LLM providers
lightrag/llm/openai.py
Other components
- User
Connections 23
- User → WebUI: uses
README.md - WebUI → Document API: manages documents
- WebUI → Query API: submits queries
- WebUI → Graph API: views graph
README.md - User → Document API: submits documents
README.md - User → Query API: queries knowledge
README.md - Document API → LightRAG engine: manages
lightrag/api/routers/document_routes.py - Document API → Ingestion pipeline: enqueues work
lightrag/api/routers/document_routes.py - Ingestion pipeline → Document parsing: routes parsing
lightrag/pipeline.py - Document parsing → External parsers: uses shared parsing
- Ingestion pipeline → Text chunking: selects chunker
lightrag/pipeline.py - Ingestion pipeline → Pipeline ingress: signals documents
lightrag/kg/pipeline_ingress.py - Ingestion pipeline → Pipeline coordination: coordinates state
lightrag/pipeline.py - Pipeline coordination → Pipeline ingress: provides ingress
lightrag/kg/shared_storage.py - LightRAG engine → Ingestion pipeline: mixes in
lightrag/pipeline.py - Query API → Query validation: validates query
lightrag/api/routers/query_routes.py - Query API → LightRAG engine: runs query
- LightRAG engine → RAG operations: delegates RAG work
- LightRAG engine → Storage factory: configures storage
- Storage factory → Storage backends: selects backend
- Storage backends → Storage contracts: implements contracts
lightrag/kg/opensearch_impl.py - RAG operations → LLM providers: calls model
- Graph API → LightRAG engine: reads knowledge graph