How vars-123/rag-document-qa works
RAG PDF question answering: users upload PDFs, track ingestion until documents are embedded, then select a document and ask questions; answers stream back with conversation history and session management. The frontend coordinates document and chat workflows, while FastAPI routes delegate to ingestion, retrieval, and history services. SQLite stores chat history and ChromaDB stores embeddings. The README also documents per-user isolation and deployment readiness. Edges reflect shown calls, imports, or HTTP routes; unsampled implementation details are omitted.
Main entry points: documents.py Document routes · App.tsx Workspace · api.ts HTTP client · main.py API startup
Components 22
Frontend experience
- Workspace
frontend/src/App.tsx - PDF upload UI
frontend/src/components/UploadZone.tsx - Document list
frontend/src/components/DocumentList.tsx - Document workflow
frontend/src/hooks/useDocuments.ts - Chat interface
frontend/src/components/ChatInterface.tsx - Chat sessions
frontend/src/hooks/useChat.ts - Conversation list
frontend/src/hooks/useConversations.ts - HTTP client
frontend/src/services/api.ts
API routes
- API startup
backend/app/main.py - Document routes
backend/app/routers/documents.py - Chat routes
backend/app/routers/chat.py - Health route
backend/app/routers/health.py
Document and RAG
- PDF extraction
backend/app/services/pdf_service.py - Text chunking
backend/app/services/chunking_service.py - Embedding service
backend/app/services/embedding_service.py - Retrieval and generation
backend/app/services/chat_service.py
Persistent state
- Vector search
backend/app/services/vector_service.py - Conversation history
backend/app/services/chat_history_service.py
Other components
- User
- Google Gemini
- SQLite
- ChromaDB
Connections 31
- User → Workspace: uses
frontend/src/App.tsx - Workspace → PDF upload UI: renders
frontend/src/App.tsx - Workspace → Document list: renders
frontend/src/App.tsx - Workspace → Document workflow: uses
frontend/src/App.tsx - Workspace → Chat interface: renders
frontend/src/App.tsx - Document workflow → HTTP client: requests
frontend/src/hooks/useDocuments.ts - Chat interface → Chat sessions: uses
frontend/src/components/ChatInterface.tsx - Chat interface → Conversation list: uses
frontend/src/components/ChatInterface.tsx - Chat sessions → HTTP client: requests
frontend/src/hooks/useChat.ts - Conversation list → HTTP client: requests
frontend/src/hooks/useConversations.ts - HTTP client → Document routes: HTTP requests
frontend/src/services/api.ts - HTTP client → Chat routes: HTTP requests
frontend/src/services/api.ts - Workspace → Health route: checks
frontend/src/App.tsx - API startup → Document routes: registers
backend/app/main.py - API startup → Chat routes: registers
backend/app/main.py - API startup → Health route: registers
backend/app/main.py - API startup → Conversation history: initializes
backend/app/main.py - Document routes → PDF extraction: extracts text
backend/app/routers/documents.py - Document routes → Text chunking: chunks text
backend/app/routers/documents.py - Document routes → Embedding service: embeds chunks
backend/app/routers/documents.py - Document routes → Vector search: deletes collection
backend/app/routers/documents.py - Document routes → Conversation history: deletes history
backend/app/routers/documents.py - Chat routes → Retrieval and generation: delegates
backend/app/routers/chat.py - Chat routes → Conversation history: reads and writes
backend/app/routers/chat.py - Retrieval and generation → Embedding service: embeds query
backend/app/services/chat_service.py - Retrieval and generation → Vector search: searches
backend/app/services/chat_service.py - Embedding service → Vector search: stores vectors
backend/app/services/embedding_service.py - Embedding service → Google Gemini: generates embeddings
backend/app/services/embedding_service.py - Retrieval and generation → Google Gemini: streams completion
backend/app/services/chat_service.py - Vector search → ChromaDB: reads and writes
backend/app/services/vector_service.py - Conversation history → SQLite: reads and writes
backend/app/services/chat_history_service.py