How nvkdzvcl/rag works
Self-RAG is a document-grounded question-answering application with a React interface and FastAPI backend. Users upload PDF, DOCX, text, or Markdown documents; the backend parses, cleans, chunks, and indexes them, then answers filtered queries in standard, advanced, or compare mode with citations and optional SSE progress. Standard and advanced workflows preserve their distinct retrieval and answer-verification stages; compare runs both. The README documents dense/BM25 retrieval and local index persistence. Some subsystem links reflect documented capabilities because their implementation was not sampled.
Main entry points: builder.py Index builder · standard.py Standard workflow · advanced_pipeline.py Advanced stages · main.py FastAPI app
Components 28
User interface
- React app
frontend/src/App.tsx - API client
frontend/src/api/client.ts - Document controls
frontend/src/hooks/use-document-ingestion.ts
API and services
- FastAPI app
app/main.py - Query routes
app/api/routes/query.py - Document routes
app/api/routes/documents.py - Query service
app/services/query_service.py - Document service
app/services/document_service.py - Service runtime
app/services/runtime.py
Document processing
- Document loaders
app/ingestion/directory_ingestor.py - Chunking
app/ingestion/chunker.py
Retrieval and answering
- Workflow runner
app/workflows/runner.py - Standard workflow
app/workflows/standard.py - Advanced workflow
app/workflows/advanced.py - Compare workflow
app/workflows/compare.py - Advanced stages
app/workflows/advanced_pipeline.py - Hybrid retrieval
app/retrieval/hybrid.py - Reranking
app/retrieval/reranker.py - Context selection
app/retrieval/context_selector.py - Answer generation
app/generation/baseline.py - Citation handling
app/generation/citations.py - LLM client
app/generation/llm_client.py
Index state
- Index builder
app/indexing/builder.py - Vector index
app/indexing/vector_index.py - BM25 index
app/indexing/bm25_index.py - Index persistence
app/indexing/persistence.py
Other components
- User
- LLM endpoint
Connections 37
- User → React app: uses
- React app → API client: requests
- API client → FastAPI app: calls API
- Document controls → API client: uploads and manages
- FastAPI app → Service runtime: builds services
- FastAPI app → Query routes: mounts routes
- Query routes → Query service: executes query
- Query service → Workflow runner: dispatches
- Workflow runner → Standard workflow: runs standard
- Workflow runner → Advanced workflow: runs advanced
- Workflow runner → Compare workflow: runs both
- Compare workflow → Standard workflow: runs standard
- Compare workflow → Advanced workflow: runs advanced
- Standard workflow → Hybrid retrieval: retrieves
- Standard workflow → Reranking: reranks
- Standard workflow → Context selection: selects context
- Standard workflow → Answer generation: generates answer
- Advanced workflow → Advanced stages: executes stages
- Advanced stages → Hybrid retrieval: retrieves
- Advanced stages → Reranking: reranks
- Advanced stages → Context selection: selects context
- Advanced stages → Answer generation: drafts and refines
- Answer generation → LLM client: completes prompts
- LLM client → LLM endpoint: sends completion
- Answer generation → Citation handling: adds citations
- FastAPI app → Document routes: mounts routes
- Document routes → Document service: manages documents
- Document service → Document loaders: loads documents
- Document loaders → Chunking: produces text for
- Document service → Index builder: builds index
- Index builder → Vector index: indexes vectors
- Index builder → BM25 index: indexes terms
- Index builder → Document loaders: consumes documents
- Index builder → Chunking: chunks content
- Hybrid retrieval → Vector index: searches dense
- Hybrid retrieval → BM25 index: searches sparse
- Index builder → Index persistence: persists index