# 7vyshak7/pdf_chatter architecture

> Architecture diagram of the GitHub repository 7vyshak7/pdf_chatter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/7vyshak7/pdf_chatter
- Repository: https://github.com/7vyshak7/pdf_chatter

## Overview

##### Project Type and Purpose
- PDF Chatter is a single‐page interactive web application built with Streamlit.
- It enables users to upload PDF documents, index their contents using embeddings, and interact via natural‐language queries.
- It leverages LangChain for orchestration, Ollama (or optionally Groq) for embeddings & LLM inference, and an in‐memory or simple vector store for retrieval.

##### File Structure
- PdfChatApp.py
- The sole entry point. Contains Streamlit UI definitions, PDF ingestion logic, embedding generation, vector store setup, and QA chain orchestration.
- temp_files/
- Holds sample PDF files for testing/demonstration.
- README.md
- Documents installation, dependencies (Streamlit, LangChain, Ollama, Groq), and usage instructions.

##### README for Insights
- Core dependencies: streamlit, langchain, streamlit-pdf-viewer, langchain_ollama, langchain_groq, langchain_community
- External services: Ollama desktop app (mandatory), Groq API (optional)
- High‐level workflow: Upload PDF → Extract & chunk text → Generate embeddings → Store in vector DB → Prompt LLM with retrieval → Display answers

a. Main Components
- UI Layer (Streamlit)
- PDF Ingestion & Preprocessing Module
- Embedding Generator (Ollama / Groq)
- Vector Store (in‐memory or local)
- Retrieval‐Augmented Generation (RAG) Chain (LangChain QA)
- External Services: Ollama Service, Groq API
b. Relationships & Data Flow
1. User → UI Layer (Streamlit app)
2. UI Layer → PDF Ingestion Module
3. Ingestion Module → Text chunks → Embedding Generator
4. Embedding Generator → Vector Store (index)
5. User Question → RAG Chain retrieves relevant chunks from Vector Store
6. RAG Chain → LLM (Ollama/Groq) → Generated Answer → UI Layer → User
c. Architectural Patterns & Principles
- Layered Architecture (UI, Processing, Storage, Inference)
- Pipeline pattern for document processing (extract → chunk → embed → index → retrieve → answer)
- Retrieval‐Augmented Generation for combining embeddings with LLM inference
d. Key Technologies & Frameworks
- Streamlit: front‐end web framework
- LangChain: orchestration, chains, vector store wrappers
- Ollama / Groq: embedding and LLM providers
- Streamlit‐PDF‐Viewer or similar for PDF rendering

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User"]:::external
    User -->|"upload PDF / ask query"| UI["Streamlit UI"]:::frontend

    subgraph "Frontend Layer"
        UI
    end

    subgraph "Processing Modules"
        Ingest["PDF Ingestion & Preprocessing"]:::processing
        Embed["Embedding Generator<br/>(Ollama / Groq)"]:::processing
        RAG["RAG Chain<br/>(LangChain QA)"]:::processing
    end

    subgraph "Storage Components"
        VecStore["Vector Store<br/>(in-memory / local)"]:::storage
    end

    subgraph "External Services"
        Ollama["Ollama Desktop App"]:::external
        Groq["Groq API<br/>(optional)"]:::external
    end

    subgraph "Sample PDF Files"
        TempDir["temp_files/"]:::storage
        DeepLearning["Deep_learning-based_object_detection_and_geographi.pdf"]:::storage
        IRJET["IRJET-V7I5478.pdf"]:::storage
    end

    README["README.md"]:::external

    UI -->|"streamlit-pdf-viewer render() & upload"| Ingest
    Ingest -->|"text chunks"| Embed
    Embed -->|"langchain_ollama embed() / langchain_groq embed()"| VecStore
    UI -->|"user query"| RAG
    RAG -->|"retrieve relevant chunks"| VecStore
    RAG -->|"llm call"| Ollama
    RAG -->|"llm call (optional)"| Groq
    Ollama -->|"generated answer"| RAG
    Groq -->|"generated answer"| RAG
    RAG -->|"answer"| UI
    UI -->|"display answer"| User

    TempDir --> DeepLearning
    TempDir --> IRJET

    %% Click Events
    click UI "https://github.com/7vyshak7/pdf_chatter/blob/main/PdfChatApp.py"
    click Ingest "https://github.com/7vyshak7/pdf_chatter/blob/main/PdfChatApp.py"
    click Embed "https://github.com/7vyshak7/pdf_chatter/blob/main/PdfChatApp.py"
    click VecStore "https://github.com/7vyshak7/pdf_chatter/blob/main/PdfChatApp.py"
    click RAG "https://github.com/7vyshak7/pdf_chatter/blob/main/PdfChatApp.py"
    click README "https://github.com/7vyshak7/pdf_chatter/blob/main/README.md"
    click TempDir "https://github.com/7vyshak7/pdf_chatter/tree/main/temp_files/"
    click DeepLearning "https://github.com/7vyshak7/pdf_chatter/blob/main/temp_files/Deep_learning-based_object_detection_and_geographi.pdf"
    click IRJET "https://github.com/7vyshak7/pdf_chatter/blob/main/temp_files/IRJET-V7I5478.pdf"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#0366D6,stroke-width:1px;
    classDef processing fill:#FFD59E,stroke:#F4900C,stroke-width:1px;
    classDef storage fill:#C2EABC,stroke:#2F8F00,stroke-width:1px;
    classDef external fill:#E2D2F8,stroke:#6E44FF,stroke-width:1px;
```
