How subbuparavatareddy/geminiragresearchassistant works
Purpose and Entry Points
This is a local research-paper RAG assistant: users upload PDF/TXT papers, index them into a persistent vector store, then ask grounded questions. The backend API starts from Backend/main.py; the browser client starts from Frontend/my-react-app/src/main.jsx and renders the application in Frontend/my-react-app/src/App.jsx.
Client Interaction Layer
The React/Vite client provides the two user workflows: select/upload a paper and submit a question. It sends multipart uploads to POST /upload, sends question JSON to POST /query, and displays the generated answer plus retrieved evidence. Primary UI boundary: Frontend/my-react-app/src/App.jsx; build/runtime setup: Frontend/my-react-app/package.json, Frontend/my-react-app/vite.config.js.
FastAPI API Boundary
Backend/main.py owns the HTTP service and coordinates the RAG lifecycle. /upload accepts the document and triggers loading, chunking, embedding, and persistence. /query retrieves relevant chunks, calls the LLM, and returns an answer and source metadata. The backend is intended to run under Uvicorn on port 8000; API documentation is exposed by FastAPI.
Document Ingestion and Indexing
Upload handling distinguishes PDF from text: LangChain loaders extract document text, then a recursive text splitter produces overlapping chunks (README specifies 1,000 characters with 200 overlap). Chunks are embedded through Google’s gemini-embedding-001 and written to the shared Chroma collection. Uploaded/example source material exists under Backend/data/ and root data/, including Backend/data/bert_paper.txt and Backend/data/ofosu-ampong.pdf.
Persistent Retrieval Store
ChromaDB is local and durable rather than an external managed database. Its persisted state is under Backend/chroma_db/, including Backend/chroma_db/chroma.sqlite3. This is a single shared store: documents are not separated by user, session, or paper collection. Query retrieval is similarity-based and selects the top three chunks, with no re-ranking or metadata isolation.
Answer Generation Flow
For /query, the backend embeds the user question, retrieves the closest Chroma chunks, and supplies those passages as grounding context to Gemini 2.5 Flash. Gemini synthesizes a one-shot answer; the API also returns the raw chunks/metadata so the client can show evidence. The core orchestration and provider calls are centralized in Backend/main.py.
Runtime, Secrets, and External Services
Python 3.10+ hosts FastAPI, LangChain, document parsing, ChromaDB, and Google Gemini integration; dependencies are declared in requirements.txt and pyproject.toml. Node.js 18+ runs the Vite React client via Frontend/my-react-app/package.json. Google AI Studio is the only required external service: its API key is read from Backend/.env. Chroma persistence, document files, and the API server are local infrastructure.
Main entry points: main.py POST /query · App.jsx Paper Q&A UI · .env Google API key · main.jsx React entry
Components 15
Browser Client
- React entry
Frontend/my-react-app/src/main.jsx - Paper Q&A UI · Uploads papers and displays answers with evidence.
Frontend/my-react-app/src/App.jsx - Vite runtime
Frontend/my-react-app/package.json
RAG API
- FastAPI RAG service · Owns upload, retrieval, generation, and response assembly.
Backend/main.py - POST /upload
Backend/main.py - POST /query
Backend/main.py - PDF/TXT loaders · Extracts text according to uploaded document type.
- Recursive splitter · Creates overlapping 1,000-character chunks.
- Top-3 similarity retrieval · Returns nearest chunks without reranking or isolation.
Backend/main.py - Python dependencies · FastAPI, LangChain, ChromaDB, and parsing dependencies.
requirements.txt
Local Persistence
- Paper files · Uploaded and example PDF/TXT source material.
Backend/data/bert_paper.txt - Shared Chroma collection · Single collection shared across papers, users, and sessions.
Backend/chroma_db/chroma.sqlite3 - Google API key
Backend/.env
Google AI
- Gemini embeddings
- Gemini answer generation · Synthesizes a grounded one-shot answer.
Connections 20
- React entry → Paper Q&A UI: renders
- Vite runtime → React entry: runs
- Paper Q&A UI → POST /upload: multipart upload
- Paper Q&A UI → POST /query: question JSON
- POST /upload → FastAPI RAG service: handled by
- POST /query → FastAPI RAG service: handled by
- POST /upload → Paper files: stores source
- POST /upload → PDF/TXT loaders: extracts text
- PDF/TXT loaders → Recursive splitter: documents
- Recursive splitter → Gemini embeddings: chunk vectors
- Gemini embeddings → Shared Chroma collection: writes embeddings
- POST /query → Gemini embeddings: embeds question
- Gemini embeddings → Top-3 similarity retrieval: query vector
- Top-3 similarity retrieval → Shared Chroma collection: similarity search
- Top-3 similarity retrieval → Gemini answer generation: grounding chunks
- Gemini answer generation → POST /query: answer
- POST /query → Paper Q&A UI: answer and evidence
- Google API key → Gemini embeddings: authenticates
- Google API key → Gemini answer generation: authenticates
- Python dependencies → FastAPI RAG service: provides runtime