# akshayacharyan/text_summarizer_chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/akshayacharyan/text_summarizer_chatbot
- Repository: https://github.com/akshayacharyan/text_summarizer_chatbot

## Overview

##### Project Type and Purpose
- This is a single-page web application built with Streamlit.
- It allows users to upload PDF files, extract and clean their text, generate summaries, and ask questions via a chatbot interface powered by Hugging Face models.

##### File Structure Analysis
- Top-level scripts:
- app.py ‑ the Streamlit application entrypoint (UI + orchestration)
- QA_chatbot.py / llama_qa.py ‑ modules for question-answering logic
- summarizer.py ‑ summarization logic
- pdf_extractor.py ‑ PDF text extraction using PyPDF2
- text_cleaner.py ‑ text preprocessing and cleaning
- test.py ‑ test harness for components
- Dev container support in .devcontainer/devcontainer.json for consistent development environment
- requirements.txt lists Python dependencies (Streamlit, Transformers, PyPDF2, etc.)

##### Key Insights from README
- Streamlit provides the user interface and handles HTTP interactions.
- Hugging Face Transformers power both summarization and Q&A models.
- No external database; uploaded PDFs are processed in memory or temporary storage.

a. Main Components
- User Browser (UI)
- Streamlit Server (app.py)
- PDF Extraction Module (pdf_extractor.py)
- Text Cleaning Module (text_cleaner.py)
- Summarization Module (summarizer.py)
- Q&A Module (QA_chatbot.py / llama_qa.py)
- Hugging Face Model Hosts (local or remote)
- Temporary File Storage (in-memory or disk)

b. Relationships and Data Flow
1. User uploads PDF via Streamlit UI
2. Streamlit Server invokes PDF Extraction Module
3. Extracted text passes to Text Cleaning Module
4. Clean text branches to either:
– Summarization Module → calls HF Summarization Model → returns summary
– Q&A Module → calls HF QA Model → returns answer
5. Streamlit displays results back to the user

c. Architectural Patterns
- Monolithic service with clear functional modules (extraction, cleaning, NLP tasks)
- Sequential data pipeline inside one process
- External dependency calls (Hugging Face Inference or local model)

d. Technologies & Frameworks
- Streamlit for UI & HTTP handling
- PyPDF2 for PDF text extraction
- Python modules orchestrating data flow
- Hugging Face Transformers for NLP tasks

## Diagram (Mermaid)

```mermaid
graph TB
    %% Frontend Layer
    User["User Browser"]:::frontend
    Streamlit["Streamlit Server\n(app.py)"]:::frontend

    %% Temporary Storage
    TempStorage["Temporary File Storage\n(In-memory/Disk)"]:::storage

    %% Processing Modules
    PDFExtr["PDF Extraction Module\n(PyPDF2)"]:::processing
    TextClean["Text Cleaning Module"]:::processing
    SummModule["Summarization Module"]:::processing
    QAModule["Q&A Module"]:::processing

    %% External Services
    HFService["Hugging Face Models"]:::external

    %% Repository Artifacts
    subgraph "Repository Artifacts"
        devc[".devcontainer/devcontainer.json"]:::external
        req["requirements.txt"]:::external
        testHarness["test.py"]:::external
        readme["README.md"]:::external
    end

    %% Data Flow
    User -->|"uploads PDF"| Streamlit
    Streamlit -->|"stores PDF"| TempStorage
    TempStorage -->|"reads PDF"| PDFExtr
    PDFExtr -->|"extracted text"| TextClean
    TextClean -->|"clean text"| SummModule
    TextClean -->|"clean text"| QAModule
    SummModule -->|"requests summary"| HFService
    QAModule -->|"requests answer"| HFService
    HFService -->|"returns summary"| SummModule
    HFService -->|"returns answer"| QAModule
    SummModule -->|"delivers summary"| Streamlit
    QAModule -->|"delivers answer"| Streamlit

    %% Click Events
    click Streamlit "https://github.com/akshayacharyan/text_summarizer_chatbot/blob/master/app.py"
    click PDFExtr "https://github.com/akshayacharyan/text_summarizer_chatbot/blob/master/pdf_extractor.py"
    click TextClean "https://github.com/akshayacharyan/text_summarizer_chatbot/blob/master/text_cleaner.py"
    click SummModule "https://github.com/akshayacharyan/text_summarizer_chatbot/blob/master/summarizer.py"
    click QAModule "https://github.com/akshayacharyan/text_summarizer_chatbot/blob/master/QA_chatbot.py"
    click QAModule "https://github.com/akshayacharyan/text_summarizer_chatbot/blob/master/llama_qa.py"
    click devc "https://github.com/akshayacharyan/text_summarizer_chatbot/blob/master/.devcontainer/devcontainer.json"
    click req "https://github.com/akshayacharyan/text_summarizer_chatbot/blob/master/requirements.txt"
    click testHarness "https://github.com/akshayacharyan/text_summarizer_chatbot/blob/master/test.py"
    click readme "https://github.com/akshayacharyan/text_summarizer_chatbot/blob/master/README.md"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#0288D1,color:#000
    classDef processing fill:#FFF9C4,stroke:#FBC02D,color:#000
    classDef external fill:#E1BEE7,stroke:#8E24AA,color:#000
    classDef storage fill:#C8E6C9,stroke:#388E3C,color:#000
```
