How pixelcraftlab/custom-rag works
Custom RAG is a full-stack document-question-answering application. Users upload PDFs, which the backend loads, semantically chunks, embeds, and stores; questions travel from the React chat UI through FastAPI to hybrid retrieval and reranking, then to a grounded LLM response with sources. The README describes persistent vector storage and hybrid retrieval; sampled storage code currently uses PostgreSQL/pgvector rather than ChromaDB. Edges reflect shown calls, imports listed in the source index, or README-documented behavior; unsampled details are not inferred.
Main entry points: Home.jsx Home workflow · ingestion.py Ingestion pipeline · chat.py RAG orchestration · ragApi.js RAG API client
Components 28
React interface
- Home workflow
frontend/src/pages/Home.jsx - Document sidebar
frontend/src/components/Sidebar.jsx - Chat display
frontend/src/components/ChatBox.jsx - Message list
frontend/src/components/MessageList.jsx - Message view
frontend/src/components/Message.jsx - Message input
frontend/src/components/MessageInput.jsx - RAG API client
frontend/src/api/ragApi.js
FastAPI routes
- Upload route
backend/app/api/upload.py - Chat route
backend/app/api/chat.py - Documents route
backend/app/api/documents.py
Document ingestion
- Ingestion pipeline
backend/app/ingestion.py - PDF loading
backend/app/loader.py - Semantic chunking
backend/app/splitter.py
Retrieval
- Retrieval orchestration
backend/app/retriever.py - Hybrid retrieval
backend/app/hybrid_retriever.py - Vector search
backend/app/vector_search.py - BM25 index loader
backend/app/bm25_loader.py - BM25 search
backend/app/bm25.py - Rank fusion
backend/app/rrf.py - Result reranking
backend/app/reranker.py
Answer and storage
- Embedding model
backend/app/embeddings.py - RAG orchestration
backend/app/chat.py - Grounding prompt
backend/app/prompt.py - LLM client
backend/app/llm.py - Conversation memory
backend/app/memory.py - Document storage
backend/app/vectorstore.py
Other components
- Document user
- PostgreSQL pgvector
Connections 30
- Document user → Home workflow: uses
README.md - Home workflow → Document sidebar: renders
frontend/src/pages/Home.jsx - Home workflow → Chat display: renders
frontend/src/pages/Home.jsx - Home workflow → Message input: renders
frontend/src/pages/Home.jsx - Chat display → Message list: renders
frontend/src/components/ChatBox.jsx - Message list → Message view: renders
frontend/src/components/MessageList.jsx - Home workflow → RAG API client: requests
frontend/src/pages/Home.jsx - RAG API client → Upload route: uploads PDFs
frontend/src/api/ragApi.js - RAG API client → Chat route: sends questions
frontend/src/api/ragApi.js - RAG API client → Documents route: lists and deletes
frontend/src/api/ragApi.js - Upload route → Ingestion pipeline: ingests files
backend/app/api/upload.py - Ingestion pipeline → PDF loading: loads PDFs
backend/app/ingestion.py - Ingestion pipeline → Semantic chunking: splits documents
backend/app/ingestion.py - Ingestion pipeline → Embedding model: gets embeddings
backend/app/ingestion.py - Ingestion pipeline → Document storage: stores chunks
backend/app/ingestion.py - Chat route → RAG orchestration: handles questions
backend/app/api/chat.py - RAG orchestration → Retrieval orchestration: retrieves context
backend/app/chat.py - Retrieval orchestration → Hybrid retrieval: searches candidates
backend/app/retriever.py - Retrieval orchestration → Result reranking: reranks results
backend/app/retriever.py - Hybrid retrieval → Vector search: runs semantic search
backend/app/hybrid_retriever.py - Hybrid retrieval → BM25 index loader: loads keyword index
backend/app/hybrid_retriever.py - Hybrid retrieval → Rank fusion: fuses rankings
backend/app/hybrid_retriever.py - Vector search → Document storage: queries vectors
backend/app/vector_search.py - BM25 index loader → BM25 search: loads index
backend/app/bm25_loader.py - BM25 index loader → Document storage: loads stored chunks
backend/app/bm25_loader.py - RAG orchestration → Grounding prompt: builds prompt
backend/app/chat.py - RAG orchestration → LLM client: generates answer
backend/app/chat.py - RAG orchestration → Conversation memory: uses conversation state
backend/app/chat.py - Document storage → PostgreSQL pgvector: reads and writes
backend/app/vectorstore.py - LLM client → PostgreSQL pgvector: uses provider