# anilkumark-10/document-ai-assistant architecture

> Architecture diagram of the GitHub repository anilkumark-10/document-ai-assistant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anilkumark-10/document-ai-assistant
- Repository: https://github.com/anilkumark-10/document-ai-assistant

## Overview

##### Project type and purpose
- From the file tree and README (“Document-Assistant”), this is a full-stack Python application whose goal is to ingest PDF documents, preprocess them, build a vector store of embeddings, and expose QA & summarization capabilities via a Streamlit frontend.

##### File structure
- Top-level directories:
- app/backend – Implements core NLP/ML pipelines (pdf_loader, preprocessor, embeddings, vector_store, llm wrappers, qa, summarizer).
- app/frontend – Streamlit app (streamlit_app.py) with its own requirements.
- Key config files: requirements.txt (root & frontend), .gitignore.
- No explicit external deployment scripts, so assume a single process or container running both front and back ends.

##### README for additional insights
- README is minimal, but file names reveal:
- PDF ingestion (pdf_loader.py)
- Text preprocessing (preprocessor.py)
- Embedding generation (embeddings.py)
- Vector database operations (vector_store.py)
- LLM interactions (llm.py)
- Downstream QA & summarization modules (qa.py, summarizer.py)
- Streamlit UI (streamlit_app.py)

a. Components
- Frontend: Streamlit-based web UI
- Backend services:
1. PDF Loader
2. Preprocessor
3. Embeddings module
4. Vector Store (e.g., FAISS or Pinecone)
5. LLM wrapper (calls an API like OpenAI)
6. QA service
7. Summarization service
- Data storage: vector database
- External services: LLM API
b. Relationships & interactions
1. User uploads or selects a PDF via Streamlit → frontend sends document to Backend → PDF Loader
2. PDF Loader → Preprocessor → Embeddings → Vector Store (persistence)
3. User submits a query in UI → QA module retrieves relevant embeddings from Vector Store → LLM is invoked → answer returned to frontend
4. Summarizer: similar flow (retrieve context → LLM summarize → frontend)
c. Architectural patterns & design principles
- Layered architecture: UI layer, service layer (QA/Summarizer), data layer (vector store), external API layer (LLM).
- Pipeline pattern for document ingestion.
- Single-process or containerized micro-layered services (can evolve into microservices if needed).
d. Key technologies
- Python modules in /app/backend
- Streamlit for UI
- Vector store tech (FAISS, Pinecone, etc.)
- LLM API (OpenAI or similar)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        UI["Streamlit UI"]:::frontend
        Config[".streamlit/config.toml"]:::config
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        PDFLoader["pdf_loader.py"]:::backend
        Preprocessor["preprocessor.py"]:::backend
        Embeddings["embeddings.py"]:::backend
        VectorStore["vector_store.py"]:::storage
        QA["qa.py"]:::backend
        Summarizer["summarizer.py"]:::backend
    end

    %% External Services
    LLMAPI["External LLM API"]:::external

    %% Configurations
    subgraph "Configurations"
        direction TB
        ReqRoot["requirements.txt"]:::config
        ReqFront["app/frontend/requirements.txt"]:::config
    end

    %% Data Flows
    UI -->|Ingest PDF| PDFLoader
    PDFLoader -->|Extract text| Preprocessor
    Preprocessor -->|Clean text| Embeddings
    Embeddings -->|Store embeddings| VectorStore

    UI -->|Submit query| QA
    QA -->|Retrieve embeddings| VectorStore
    QA -->|Call LLM| LLMAPI
    LLMAPI -->|Return answer| QA
    QA -->|Display answer| UI

    UI -->|Request summary| Summarizer
    Summarizer -->|Retrieve embeddings| VectorStore
    Summarizer -->|Call LLM| LLMAPI
    LLMAPI -->|Return summary| Summarizer
    Summarizer -->|Display summary| UI

    %% Click Events
    click UI "https://github.com/anilkumark-10/document-ai-assistant/blob/main/app/frontend/streamlit_app.py"
    click Config "https://github.com/anilkumark-10/document-ai-assistant/blob/main/app/frontend/.streamlit/config.toml"
    click PDFLoader "https://github.com/anilkumark-10/document-ai-assistant/blob/main/app/backend/pdf_loader.py"
    click Preprocessor "https://github.com/anilkumark-10/document-ai-assistant/blob/main/app/backend/preprocessor.py"
    click Embeddings "https://github.com/anilkumark-10/document-ai-assistant/blob/main/app/backend/embeddings.py"
    click VectorStore "https://github.com/anilkumark-10/document-ai-assistant/blob/main/app/backend/vector_store.py"
    click QA "https://github.com/anilkumark-10/document-ai-assistant/blob/main/app/backend/qa.py"
    click Summarizer "https://github.com/anilkumark-10/document-ai-assistant/blob/main/app/backend/summarizer.py"
    click LLMAPI "https://github.com/anilkumark-10/document-ai-assistant/blob/main/app/backend/llm.py"
    click ReqRoot "https://github.com/anilkumark-10/document-ai-assistant/blob/main/requirements.txt"
    click ReqFront "https://github.com/anilkumark-10/document-ai-assistant/blob/main/app/frontend/requirements.txt"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#2E86C1,color:#1B4F72
    classDef backend fill:#D5F5E3,stroke:#28B463,color:#196F3D
    classDef storage fill:#FCF3CF,stroke:#D4AC0D,color:#7D6608
    classDef external fill:#E8DAEF,stroke:#8E44AD,color:#512E5F
    classDef config fill:#F4ECF7,stroke:#7D3C98,color:#4A235A
```
