How isurulkh/rag-application-gemini works
Project Type and Purpose
• Type: Full-stack web application (single-page UI + backend logic bundled in app.py).
• Purpose: Let users upload PDFs, index them via embeddings, then ask context-aware questions answered by Google Gemini.
Main Components
a. User Interface (Streamlit)
• Rendered in the browser.
• Handles file upload, question input, and displays answers.
b. Application Logic (app.py)
• Orchestrates ingestion, embedding, retrieval, and inference.
• Uses LangChain to build the RAG pipeline.
c. Document Store
• Temporary storage of uploaded PDFs (in memory or disk).
d. Vector Store (ChromaDB)
• Stores and indexes document embeddings.
e. Embedding & LLM Service (Google Generative AI / Gemini)
• Generates embeddings for document chunks.
• Performs question answering over retrieved context.
f. Configuration / Environment
• Manages GOOGLE_API_KEY via .env.
Relationships & Data Flow
1) User uploads PDF via Streamlit UI.
2) app.py extracts text → chunks → calls Gemini embeddings API.
3) Embeddings stored in ChromaDB.
4) User submits a question → app.py sends retrieval request to ChromaDB → retrieves top-k relevant chunks.
5) Retrieved chunks + question forwarded to Gemini LLM for answer.
6) Answer returned to Streamlit for display.
Architectural Patterns & Design Principles
• Single Entry Point: app.py orchestrates end-to-end flow.
• Modular Pipeline: clear separation of ingestion, indexing, retrieval, and inference stages.
• External Service Integration: Google Gemini API for both embeddings and generation.
• State Management: ephemeral document storage and persistent vector store.
4. Within Application Logic, show two sub-blocks:
• Ingestion & Embeddings
• Retrieval & Generation
7. Vector Store → back to Retrieval sub-block.
9. Answer → back to Streamlit UI → Browser → User.
10. Off to the side, list environment config component (.env / GOOGLE_API_KEY).