# zaradarz/ask-multiple-pdfs architecture

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

- Interactive diagram: https://gitdiagram.com/zaradarz/ask-multiple-pdfs
- Repository: https://github.com/zaradarz/ask-multiple-pdfs

## Overview

##### Main Components Identification
- PDF Processing Layer
- Text Processing Layer
- Vector Database Layer
- Language Model Layer
- User Interface Layer
- API Integration Layer

##### Component Details

For each component, include these specific details:

PDF Processing Layer:
- Input: PDF files
- Process: Text extraction
- Output: Raw text

Text Processing Layer:
- Input: Raw text
- Process: Chunking algorithm
- Output: Text chunks

Vector Database Layer:
- Input: Text chunks
- Process: Vector storage
- Output: Searchable embeddings

Language Model Layer:
- OpenAI API integration
- Embedding generation
- Query processing flow

User Interface Layer:
- Streamlit components
- User input handling
- Response display

##### Specific Implementation Details

Technical elements:
- OpenAI API connection (shown in .env.example)
- Streamlit framework (from app.py)
- PDF processing libraries
- Vector storage system

##### Additional Elements

Supporting details:
- System requirements
- API key configuration
- Data flow direction indicators
- Component interaction patterns

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Legend
        UI[User Interface]:::ui
        PROC[Processing Component]:::processing
        STORE[(Storage Component)]:::storage
        API[External API]:::api
        style Legend fill:#f0f0f0,stroke:#333
    end

    subgraph "User Interface Layer"
        UI_COMP[Streamlit Interface]:::ui
        TEMPLATE[HTML Templates]:::ui
    end

    subgraph "Document Processing Flow"
        PDF_IN[PDF Input]:::processing
        TEXT_EX[Text Extraction]:::processing
        TEXT_CHUNK[Text Chunking]:::processing
        VECTOR_EMB[Vector Embedding]:::processing
    end

    subgraph "Storage Layer"
        VEC_DB[(Vector Database)]:::storage
    end

    subgraph "Query Processing Flow"
        QUERY[Query Processing]:::processing
        SIM_SEARCH[Similarity Search]:::processing
        RESP_GEN[Response Generation]:::processing
    end

    subgraph "External Services"
        OPENAI[OpenAI API]:::api
    end

    %% Data Flow
    UI_COMP --> PDF_IN
    UI_COMP --> QUERY
    PDF_IN --> TEXT_EX
    TEXT_EX --> TEXT_CHUNK
    TEXT_CHUNK --> VECTOR_EMB
    VECTOR_EMB --> VEC_DB
    QUERY --> SIM_SEARCH
    SIM_SEARCH --> VEC_DB
    VEC_DB --> RESP_GEN
    RESP_GEN --> OPENAI
    OPENAI --> UI_COMP
    TEMPLATE --> UI_COMP

    %% Click Events
    click UI_COMP "https://github.com/zaradarz/ask-multiple-pdfs/blob/main/app.py"
    click TEMPLATE "https://github.com/zaradarz/ask-multiple-pdfs/blob/main/htmlTemplates.py"
    click OPENAI "https://github.com/zaradarz/ask-multiple-pdfs/blob/main/.env.example"

    %% Styling
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef processing fill:#2ecc71,stroke:#27ae60,color:white
    classDef storage fill:#f1c40f,stroke:#f39c12,color:black
    classDef api fill:#e74c3c,stroke:#c0392b,color:white
```
