# arun-sr07/voice-enabled-rag-chatbot- architecture

> Architecture diagram of the GitHub repository arun-sr07/voice-enabled-rag-chatbot-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arun-sr07/voice-enabled-rag-chatbot-
- Repository: https://github.com/arun-sr07/voice-enabled-rag-chatbot-

## Overview

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`](https://github.com/arun-sr07/voice-enabled-rag-chatbot-/blob/main/main.py) (Hybrid retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_local["Local app"]
  node_ui["Streamlit app<br/>orchestrator<br/>[main.py]"]
  node_mic(("Mic input<br/>ui input<br/>[main.py]"))
  node_upload(("PDF upload<br/>ui input<br/>[main.py]"))
  node_ingest["PDF parser<br/>ingestion<br/>[main.py]"]
  node_retrieve["Hybrid retrieval<br/>[main.py]"]
  node_cite["Citations<br/>rendering<br/>[main.py]"]
end

subgraph group_services["Managed services"]
  node_transcribe["Speech text<br/>transcription"]
  node_describe["Visual enrich<br/>multimodal llm"]
  node_embed{{"Embeddings<br/>vectorizer"}}
  node_store[("Pinecone index<br/>vector store")]
  node_search["Serper search<br/>web search"]
  node_answer["Groq answer<br/>llm synthesis"]
end

node_mic -->|"voice question"| node_ui
node_upload -->|"pdfs"| node_ui
node_ui -->|"audio"| node_transcribe
node_transcribe -->|"text query"| node_ui
node_upload -->|"parse"| node_ingest
node_ingest -->|"visual content"| node_describe
node_ingest -->|"text chunks"| node_embed
node_describe -->|"descriptions"| node_embed
node_embed -->|"vectors"| node_store
node_ui -->|"question"| node_retrieve
node_retrieve -->|"vector search"| node_store
node_retrieve -->|"web search"| node_search
node_store -->|"matches"| node_retrieve
node_search -->|"results"| node_retrieve
node_retrieve -->|"context"| node_answer
node_answer -->|"response"| node_cite
node_cite -->|"render"| node_ui

click node_ui "https://github.com/arun-sr07/voice-enabled-rag-chatbot-/blob/main/main.py"
click node_mic "https://github.com/arun-sr07/voice-enabled-rag-chatbot-/blob/main/main.py"
click node_upload "https://github.com/arun-sr07/voice-enabled-rag-chatbot-/blob/main/main.py"
click node_ingest "https://github.com/arun-sr07/voice-enabled-rag-chatbot-/blob/main/main.py"
click node_retrieve "https://github.com/arun-sr07/voice-enabled-rag-chatbot-/blob/main/main.py"
click node_cite "https://github.com/arun-sr07/voice-enabled-rag-chatbot-/blob/main/main.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ui,node_mic,node_upload,node_ingest,node_retrieve,node_cite toneBlue
class node_transcribe,node_describe,node_embed,node_store,node_search,node_answer toneAmber
```

## Components

### Local app

Single-process Streamlit runtime that orchestrates upload, voice input, retrieval, and answer rendering.

- [Streamlit app](https://github.com/arun-sr07/voice-enabled-rag-chatbot-/blob/main/main.py): orchestrator · Single Streamlit entrypoint that coordinates the full RAG workflow and renders responses. · `main.py`
- [Mic input](https://github.com/arun-sr07/voice-enabled-rag-chatbot-/blob/main/main.py): ui input · Browser microphone capture for voice questions. · `main.py`
- [PDF upload](https://github.com/arun-sr07/voice-enabled-rag-chatbot-/blob/main/main.py): ui input · Accepts user-provided PDF documents for ingestion and citation. · `main.py`
- [PDF parser](https://github.com/arun-sr07/voice-enabled-rag-chatbot-/blob/main/main.py): ingestion · Extracts page text and detects visual content such as tables, charts, and images. · `main.py`
- [Hybrid retrieval](https://github.com/arun-sr07/voice-enabled-rag-chatbot-/blob/main/main.py): retrieval · Combines Pinecone vector search with live web search results for grounding. · `main.py`
- [Citations](https://github.com/arun-sr07/voice-enabled-rag-chatbot-/blob/main/main.py): rendering · 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**: transcription · Converts spoken questions into text before retrieval.
- **Visual enrich**: multimodal llm · Generates text descriptions for non-text PDF content so it can be searched.
- **Embeddings**: vectorizer · Creates 384-dimensional sentence embeddings for text chunks and visual descriptions.
- **Pinecone index**: vector store · Persistent vector store holding embeddings and page-level metadata for retrieval and citations.
- **Serper search**: web search · Fetches live public web context to augment private PDF retrieval.
- **Groq answer**: llm synthesis · Synthesizes a grounded response from retrieved PDF and web context.

## Connections

- 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.
