# uzee62/pdf_interactor architecture

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

- Interactive diagram: https://gitdiagram.com/uzee62/pdf_interactor
- Repository: https://github.com/uzee62/pdf_interactor

## Overview

##### Project type and purpose
- This is a Streamlit-based web application (“full-stack” in the sense of browser UI + Python backend in one process) for interactive PDF question answering and document exploration.
- It leverages Langchain, FAISS vector indexing, Groq’s LLM API, and Google Generative AI embeddings to process uploaded PDFs, store their embeddings, and answer user queries.

##### File structure
- Top-level files:
- .devcontainer/devcontainer.json – development container settings
- .gitignore, requirements.txt – standard project metadata
- README.md – project description & instructions
- app.py – main Streamlit application entry point
- PDFprocess_sample.py – sample script for PDF processing workflows
- faiss_index.bin – persisted FAISS vector index
- CSS/style.css – custom styling for response cards
- No separate “frontend” or “backend” directories; the Streamlit app serves both roles.

##### Extract key insights from the README
- Core features: PDF upload, Q&A, auto-question generation, multi-PDF support, styled UI, integration with Groq LLM and Google GenAI embeddings.
- The technical stack: Python 3.7+, Streamlit, Langchain, langchain_groq, langchain_google_genai, FAISS, python-dotenv for configuration.

a. Main components
1. User’s Web Browser (Streamlit UI)
2. Streamlit Application (app.py)
3. PDF Loader & Chunker (via Langchain and PyPDFDirectoryLoader)
4. Embedding Service
– Google Generative AI embeddings
5. Vector Store
– FAISS index (faiss_index.bin)
6. LLM QA Service
– Groq API (via langchain_groq)
7. Configuration Layer
– python-dotenv (.env file)
8. Static Assets
– CSS/style.css
9. Dev Environment
– .devcontainer settings for reproducible builds
b. Relationships and data flows
1. Browser → Streamlit App: user uploads PDF or submits query
2. App → PDF Loader: load & chunk PDF pages
3. Chunks → Embedding Service: call Google GenAI to generate embeddings
4. Embeddings → FAISS: index or retrieve most relevant chunks
5. Retrieved Chunks + Query → Groq LLM API: generate answer
6. Answer → Streamlit App → Browser: render styled response card
c. Architectural patterns and design principles
- “UI-Driven Backend”: UI code and business logic co-located in a single Python process (Streamlit)
- Pipeline pattern: loader → embedder → vector store → LLM
- Separation of concerns: static assets (CSS) vs. dynamic code (app.py)
- Externalized configuration: .env managed by python-dotenv
d. Key technologies and libraries
- Streamlit for UI
- Langchain for document processing pipelines
- FAISS for in-memory vector retrieval
- Groq API & Google Generative AI for LLM and embeddings
- python-dotenv for environment variables

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        Browser["User Web Browser"]:::external
        StreamlitApp["Streamlit App"]:::internal
        StaticAssets["CSS/style.css"]:::storage
    end

    subgraph "Processing Pipeline"
        PDFLoader["PDF Loader & Chunker"]:::internal
        EmbeddingService["Embedding Service\n(Google GenAI)"]:::external
        VectorStore[(faiss_index.bin)]:::storage
        LLMQAService["LLM QA Service\n(Groq API)"]:::external
    end

    subgraph "Configuration & Environment"
        DevContainer[".devcontainer/devcontainer.json"]:::config
        DotEnv["requirements.txt"]:::config
    end

    subgraph "Project Metadata & Docs"
        Readme["README.md"]:::metadata
        Gitignore[".gitignore"]:::metadata
    end

    Browser -->|"upload PDF / submit query"| StreamlitApp
    StreamlitApp -->|"load & chunk PDF"| PDFLoader
    PDFLoader -->|"PDF chunks"| EmbeddingService
    EmbeddingService -->|"embeddings"| VectorStore
    StreamlitApp -->|"retrieve index"| VectorStore
    VectorStore -->|"relevant chunks"| LLMQAService
    StreamlitApp -->|"query + context"| LLMQAService
    LLMQAService -->|"answer"| StreamlitApp
    StreamlitApp -->|"render answer"| Browser

    click StreamlitApp "https://github.com/uzee62/pdf_interactor/blob/main/app.py"
    click PDFLoader "https://github.com/uzee62/pdf_interactor/blob/main/PDFprocess_sample.py"
    click EmbeddingService "https://github.com/uzee62/pdf_interactor/blob/main/app.py"
    click LLMQAService "https://github.com/uzee62/pdf_interactor/blob/main/app.py"
    click VectorStore "https://github.com/uzee62/pdf_interactor/blob/main/faiss_index.bin"
    click StaticAssets "https://github.com/uzee62/pdf_interactor/blob/main/CSS/style.css"
    click DevContainer "https://github.com/uzee62/pdf_interactor/blob/main/.devcontainer/devcontainer.json"
    click DotEnv "https://github.com/uzee62/pdf_interactor/blob/main/requirements.txt"
    click Readme "https://github.com/uzee62/pdf_interactor/blob/main/README.md"
    click Gitignore "https://github.com/uzee62/pdf_interactor/blob/main/.gitignore"

    classDef internal fill:#bbf,stroke:#333,stroke-width:1px
    classDef external fill:#fdd,stroke:#333,stroke-width:1px
    classDef storage fill:#dfd,stroke:#333,stroke-width:1px
    classDef config fill:#ffd,stroke:#333,stroke-width:1px
    classDef metadata fill:#eee,stroke:#333,stroke-width:1px
```
