# jrmlmaurya/pdf-chat-assistant architecture

> Architecture diagram of the GitHub repository jrmlmaurya/pdf-chat-assistant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jrmlmaurya/pdf-chat-assistant
- Repository: https://github.com/jrmlmaurya/pdf-chat-assistant

## Overview

##### Project Type and Purpose
- This is a lightweight, document-based Q&A web application built with Python and Streamlit.
- Users upload a PDF, which is split, embedded, and indexed; queries are answered via a LangChain RetrievalQA pipeline powered by the Groq LLM service.

##### File Structure Analysis
- Top-level files:
- app.py – Streamlit UI and orchestration
- requirements.txt, .gitignore, LICENSE
- Backend folder: langchain_backend/
- document_loader.py – PDF ingestion and FAISS vector store creation
- qa_chain.py – construction of the RetrievalQA pipeline using Groq LLaMA3

##### Architectural Insights from README
- Frontend: Streamlit app for upload, preview, and query input
- Document Processing: PyPDFLoader → chunking via RecursiveCharacterTextSplitter → embeddings via HuggingFace model (all-MiniLM-L6-v2) → FAISS index
- QA Chain: LangChain RetrievalQA that calls the Groq API (LLaMA3-8B-8192)
- No persistent DB: each upload is ephemeral and regenerated on every run

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer"
        UI["Streamlit UI"]:::ui
        Notebook["Analysis Notebook"]:::ui
    end

    %% Processing & Inference Layer
    subgraph "Backend" 
        DL["Document Loader"]:::process
        TS["Text Splitter"]:::process
        ES["Embedding Service (HuggingFace)"]:::external
        VS["FAISS Vector Store"]:::datastore
        QA["RetrievalQA Pipeline"]:::process
    end

    %% External LLM Service
    LLM["Groq LLM Service"]:::external

    %% Documentation & Setup
    subgraph "Project Docs & Setup"
        Req["requirements.txt"]:::doc
        Readme["README.md"]:::doc
        Gitignore[".gitignore"]:::doc
        License["LICENSE"]:::doc
    end

    %% Data Flows
    UI -->|"upload PDF"| DL
    DL -->|"load PDF"| TS
    TS -->|"chunks"| ES
    ES -->|"embeddings"| VS
    UI -->|"user query"| QA
    QA -->|"search vectors"| VS
    VS -->|"retrieved chunks"| QA
    QA -->|"send context+query"| LLM
    LLM -->|"answer"| QA
    QA -->|"display answer"| UI

    %% Click Events
    click UI "https://github.com/jrmlmaurya/pdf-chat-assistant/blob/main/app.py"
    click Notebook "https://github.com/jrmlmaurya/pdf-chat-assistant/blob/main/chat.ipynb"
    click DL "https://github.com/jrmlmaurya/pdf-chat-assistant/blob/main/langchain_backend/document_loader.py"
    click TS "https://github.com/jrmlmaurya/pdf-chat-assistant/blob/main/langchain_backend/document_loader.py"
    click ES "https://github.com/jrmlmaurya/pdf-chat-assistant/blob/main/langchain_backend/document_loader.py"
    click VS "https://github.com/jrmlmaurya/pdf-chat-assistant/blob/main/langchain_backend/document_loader.py"
    click QA "https://github.com/jrmlmaurya/pdf-chat-assistant/blob/main/langchain_backend/qa_chain.py"
    click LLM "https://github.com/jrmlmaurya/pdf-chat-assistant/blob/main/langchain_backend/qa_chain.py"
    click Req "https://github.com/jrmlmaurya/pdf-chat-assistant/blob/main/requirements.txt"
    click Readme "https://github.com/jrmlmaurya/pdf-chat-assistant/blob/main/README.md"
    click Gitignore "https://github.com/jrmlmaurya/pdf-chat-assistant/blob/main/.gitignore"
    click License "https://github.com/jrmlmaurya/pdf-chat-assistant/tree/main/LICENSE"

    %% Styles
    classDef ui fill:#D0E8F2,stroke:#036280,color:#000
    classDef process fill:#E2F0D9,stroke:#2F6F44,color:#000
    classDef external fill:#FDE9D9,stroke:#D96E00,color:#000
    classDef datastore fill:#F2F2F2,stroke:#555,color:#000
    classDef doc fill:#FFF8E1,stroke:#B08B00,color:#000
```
