# devvirani13/docbot-chatbot-based-document-assistance-system- architecture

> Architecture diagram of the GitHub repository devvirani13/docbot-chatbot-based-document-assistance-system-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/devvirani13/docbot-chatbot-based-document-assistance-system-
- Repository: https://github.com/devvirani13/docbot-chatbot-based-document-assistance-system-

## Overview

##### Main Components
- Client Interface: Represent the user’s interaction with the system (e.g., browser or API client). This is where users upload PDF files and send questions.
- Flask Web Server: This is the central application (app.py) that handles incoming HTTP requests (like /upload and /ask_question endpoints), orchestrates the PDF processing, and responds to client queries.
- PDF Upload & File Storage: Include components to represent the “uploads” directory (for the raw PDFs) and “uploadimages” (for the images extracted from PDFs).
- PDF Processing Pipeline:
- PDF Text Extraction Module: Using libraries such as pdfminer, PyPDF2, and pdfplumber to extract text.
- PDF-to-Image Conversion: Handling the conversion of PDF pages to images (using pdf2image).
- NLP & Question Answering Engine:
- Use LangChain and HuggingFace to process the extracted content.
- Integration with Google Generative AI for enhanced Q&A.
- A visual representation of the knowledge (e.g., a Chroma vector store depicted as the “db_text” directory) that stores processed text data for rapid querying.

##### Relationships and Data Flow
- From the Flask server, illustrate two parallel processing pipelines:
- One for direct PDF text extraction.
- Another for converting PDF pages to images followed by YOLO (for image detection) and then EasyOCR (for OCR).
- Converge these outputs into a data aggregation module that indexes content into the Chroma vector store (“db_text”).
- Finally, indicate the returning flow where the Flask server sends back results to the client.

##### Additional Technical Details
- Two main API endpoints: “/upload” for file submissions and “/ask_question” for querying the processed data.
- That the system separates concerns (PDF processing, image analysis, and NLP-based question answering) which is an architecturally clean design.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        CI["Client Interface<br/>(User Uploads PDF, Asks Questions)"]:::client
    end

    %% Backend Server
    subgraph "Backend Server"
        FWS["Flask Web Server<br/>(Handles /upload and /ask_question)"]:::backend
        DEP["Dependency & Package Management<br/>(Integrations: YOLO, EasyOCR, LangChain, HuggingFace)"]:::backend
    end

    %% File Storage
    subgraph "File Storage"
        PDF["PDF Upload & Storage<br/>(uploads)"]:::storage
        IMG["Image Storage<br/>(uploadimages)"]:::storage
    end

    %% PDF Processing Pipeline
    subgraph "PDF Processing Pipeline"
        TE["PDF Text Extraction<br/>(pdfminer, PyPDF2, pdfplumber)"]:::processing
        P2I["PDF-to-Image Conversion<br/>(pdf2image)"]:::processing
        IO["Image Analysis & OCR<br/>(YOLO & EasyOCR)"]:::processing
    end

    %% Data Aggregation & NLP Engine
    subgraph "Data Aggregation & NLP Engine"
        CA["Content Indexing<br/>(Chroma Vector Store: db_text)"]:::storage
        NLP["NLP & Question Answering Engine<br/>(LangChain, HuggingFace, Google Generative AI)"]:::nlp
    end

    %% Data Flow
    CI -->|"sends request"| FWS
    FWS -->|"manages"| DEP
    FWS -->|"receives PDF"| PDF
    PDF -->|"provides PDF"| TE
    FWS -->|"converts PDF to images"| P2I
    P2I -->|"stores images"| IMG
    IMG -->|"analyzes images"| IO
    TE -->|"extracted text"| CA
    IO -->|"ocr text"| CA
    CA -->|"index content"| NLP
    NLP -->|"generates answer"| FWS
    FWS -->|"returns response"| CI

    %% Click Events
    click CI "https://github.com/devvirani13/docbot-chatbot-based-document-assistance-system-/blob/main/README.md"
    click FWS "https://github.com/devvirani13/docbot-chatbot-based-document-assistance-system-/blob/main/app.py"
    click PDF "https://github.com/devvirani13/docbot-chatbot-based-document-assistance-system-/blob/main/sample_input_file.pdf"
    click DEP "https://github.com/devvirani13/docbot-chatbot-based-document-assistance-system-/blob/main/requirement.txt"

    %% Styles
    classDef client fill:#ccf,stroke:#333,stroke-width:2px;
    classDef backend fill:#cfc,stroke:#333,stroke-width:2px;
    classDef storage fill:#fcf,stroke:#333,stroke-width:2px;
    classDef processing fill:#ff9,stroke:#333,stroke-width:2px;
    classDef nlp fill:#cff,stroke:#333,stroke-width:2px;
```
