# deveshkd/simple-rag-pipline architecture

> Architecture diagram of the GitHub repository deveshkd/simple-rag-pipline, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/deveshkd/simple-rag-pipline
- Repository: https://github.com/deveshkd/simple-rag-pipline

## Overview

##### Project Type and Purpose
- This is a mono‐repo “full‐stack” (UI + backend logic) Retrieval‐Augmented Generation (RAG) chatbot.
- Purpose: Let users upload PDFs, extract and index text (including OCR), then answer natural-language questions using an LLM (via Ollama) + FAISS vector search.

##### File‐Structure Analysis
- Top level
- app.py – Streamlit entry point, HTTP‐style UI/UX
- requirements.txt / Tesseract_req.txt – Python & OCR dependencies
- .devcontainer – VSCode dev‐container config
- src/ (backend modules)
- loader.py – PDF ingestion & text extraction (PyMuPDF + Tesseract)
- splitter.py – Text chunking logic
- embedder.py – Embedding text chunks (SentenceTransformer)
- vectorstore.py – Vector store management (FAISS)
- qa.py – Query orchestration: retrieve top‐k chunks, call LLM via Ollama, assemble response

##### README Insights
- Highlights the processing pipeline: PDF upload → OCR/text parse → chunking → embedding → vector indexing → similarity search → LLM QA.
- Key external services/libraries: Streamlit (UI), PyMuPDF, Tesseract, FAISS, Ollama, Sentence Transformer.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Dev Container"
        subgraph "Frontend"
            UI["Browser / Streamlit UI"]:::frontend
        end
        subgraph "Document Processing"
            Loader["loader.py\n(PyMuPDF + Tesseract)"]:::internal
            OCR["Tesseract OCR"]:::external
            Splitter["splitter.py\n(Text Chunking)"]:::internal
        end
        subgraph "Indexing"
            Embedder["embedder.py\n(SentenceTransformer)"]:::internal
            VectorService["vectorstore.py\n(FAISS and Disk)"]:::internal
            FAISS["FAISS Index"]:::db
        end
        subgraph "Query / Inference"
            QA["qa.py\n(Orchestrator + Ollama)"]:::internal
            LLM["Ollama LLM"]:::external
        end
    end

    UI -->|"PDF file"| Loader
    Loader -->|"calls OCR"| OCR
    OCR -->|"returns text"| Loader
    Loader -->|"raw text"| Splitter
    Splitter -->|"text chunks"| Embedder
    Embedder -->|"embeddings"| VectorService
    VectorService -->|"persist index"| FAISS

    UI -->|"user query"| QA
    QA -->|"top-k chunks request"| VectorService
    VectorService -->|"top-k chunks"| QA
    QA -->|"LLM prompt/response"| LLM
    LLM -->|"answer"| QA
    QA -->|"answer"| UI

    click UI "https://github.com/deveshkd/simple-rag-pipline/blob/main/app.py"
    click Loader "https://github.com/deveshkd/simple-rag-pipline/blob/main/src/loader.py"
    click Splitter "https://github.com/deveshkd/simple-rag-pipline/blob/main/src/splitter.py"
    click Embedder "https://github.com/deveshkd/simple-rag-pipline/blob/main/src/embedder.py"
    click VectorService "https://github.com/deveshkd/simple-rag-pipline/blob/main/src/vectorstore.py"
    click QA "https://github.com/deveshkd/simple-rag-pipline/blob/main/src/qa.py"

    classDef internal fill:#e0f7fa,stroke:#006064
    classDef external fill:#fff3e0,stroke:#e65100
    classDef db fill:#e8f5e9,stroke:#2e7d32
    classDef frontend fill:#e3f2fd,stroke:#1e88e5
```
