How arun-sr07/voice-enabled-rag-chatbot- works
1. Repository shape
- This is a very small Python application, not a multi-service codebase.
- The architecture appears to be centered in a single orchestration file: main.py in the tree, though the README still refers to app.py. For diagramming, treat it as a single Streamlit entrypoint that coordinates the whole pipeline.
2. Primary user interface
- The user-facing boundary is a Streamlit chat app.
- It supports two input modes: typed questions and microphone-based voice questions.
- The UI also handles PDF upload and renders the answer plus any cited document previews.
3. Voice input path
- Audio from the browser is captured through Streamlit’s mic component.
- Speech-to-text is delegated to Deepgram, which converts the user’s spoken question into text before retrieval/generation.
4. Document ingestion pipeline
- Uploaded PDFs are processed page by page.
- The app extracts text directly from the PDF and also detects non-text content such as tables, charts, and images.
- This ingestion step is the main boundary between user-provided content and the retrieval layer.
5. Multimodal enrichment
- Visual PDF content is sent to a multimodal LLM for description generation.
- The README names Groq models for this, with a possible fallback/reference to Gemini in the environment variables.
- The purpose is to turn images/tables into searchable text so the document becomes usable in RAG retrieval.
6. Embedding layer
- Both raw text chunks and generated visual descriptions are converted into vector embeddings locally using SentenceTransformer.
- The README specifies a 384-dimensional embedding model (all-MiniLM-L6-v2), which determines the downstream Pinecone index shape.
7. Vector storage
- Embeddings and metadata are stored in Pinecone.
- Metadata includes document identity and page-level provenance, which later drives citations and page previews.
- The Pinecone index is an external persistent knowledge store for the uploaded PDFs.
8. Query retrieval
- When a question arrives, the system runs two retrieval paths in parallel:
- vector search against Pinecone for private document context
- web search via Serper for live public context
- This makes the RAG pipeline hybrid: private PDF knowledge plus live web augmentation.
9. Answer generation
- Retrieved context from both sources is combined and sent to a fast Groq-hosted LLM.
- The README names llama-3.1-8b-instant for answering, optimized for low-latency synthesis.
- The model is expected to produce a grounded answer with citations to both PDF and web sources.
10. Citation and preview rendering
- The app parses the generated response for citation references.
- For PDF-backed answers, it uses the stored page metadata to show a visual preview of the relevant page and a link to the source document/page.
- This is the main “trust and verification” boundary in the system.
11. External services and infrastructure
- The architecture depends on multiple external APIs: Groq, Pinecone, Deepgram, and Serper.
- Secrets are loaded from a local .env file.
- The repo itself contains no dedicated backend service or database; persistence and AI capabilities are offloaded to those managed services.
12. Operational boundaries
- There is no evident separate worker, queue, or microservice split in the repo tree.
- The likely runtime is a single Python process launched by Streamlit, orchestrating ingestion, embedding, retrieval, and UI rendering.
- requirements.txt defines the software stack; no additional infrastructure code is present in the repository.
13. Diagramming takeaway
- The cleanest architecture diagram would show one Streamlit app in the center, connected to:
- user microphone/browser input
- PDF upload and parsing
- Deepgram for transcription
- Groq/Gemini for multimodal description and answer generation
- SentenceTransformer for embeddings
- Pinecone for vector storage/retrieval
- Serper for web search
- The app is a coordinated RAG pipeline rather than a layered backend/frontend system.
Main entry points: main.py Hybrid retrieval
Components 12
Local app
Single-process Streamlit runtime that orchestrates upload, voice input, retrieval, and answer rendering.
- Streamlit app · Single Streamlit entrypoint that coordinates the full RAG workflow and renders responses.
main.py - Mic input · Browser microphone capture for voice questions.
main.py - PDF upload · Accepts user-provided PDF documents for ingestion and citation.
main.py - PDF parser · Extracts page text and detects visual content such as tables, charts, and images.
main.py - Hybrid retrieval · Combines Pinecone vector search with live web search results for grounding.
main.py - Citations · Parses references in the answer and maps them to page metadata for previews and source links.
main.py
Managed services
External APIs and hosted infrastructure used for transcription, embeddings, vector storage, search, and generation.
- Speech text · Converts spoken questions into text before retrieval.
- Visual enrich · Generates text descriptions for non-text PDF content so it can be searched.
- Embeddings · Creates 384-dimensional sentence embeddings for text chunks and visual descriptions.
- Pinecone index · Persistent vector store holding embeddings and page-level metadata for retrieval and citations.
- Serper search · Fetches live public web context to augment private PDF retrieval.
- Groq answer · Synthesizes a grounded response from retrieved PDF and web context.
Connections 17
- Mic input → Streamlit app: voice question · User speaks into the Streamlit app.
- PDF upload → Streamlit app: pdfs · User uploads documents into the app.
- Streamlit app → Speech text: audio · Captured audio is sent for speech-to-text.
- Speech text → Streamlit app: text query · Transcribed question returns to the app.
- PDF upload → PDF parser: parse · Uploaded PDF is extracted page by page.
- PDF parser → Visual enrich: visual content · Non-text regions are sent for multimodal description.
- PDF parser → Embeddings: text chunks · Raw extracted text is embedded.
- Visual enrich → Embeddings: descriptions · Generated visual descriptions are embedded.
- Embeddings → Pinecone index: vectors · Embeddings and metadata are persisted in Pinecone.
- Streamlit app → Hybrid retrieval: question · The current user question enters retrieval.
- Hybrid retrieval → Pinecone index: vector search · Searches private document embeddings in Pinecone.
- Hybrid retrieval → Serper search: web search · Fetches live public context from Serper.
- Pinecone index → Hybrid retrieval: matches · Relevant pages and metadata return from Pinecone.
- Serper search → Hybrid retrieval: results · Web results return for hybrid grounding.
- Hybrid retrieval → Groq answer: context · Combined private and public context is sent to the answer model.
- Groq answer → Citations: response · The generated answer is parsed for citations.
- Citations → Streamlit app: render · Citations and page previews are shown alongside the answer.