# piyushdhoka/drdo_docxsummarizer architecture

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

- Interactive diagram: https://gitdiagram.com/piyushdhoka/drdo_docxsummarizer
- Repository: https://github.com/piyushdhoka/drdo_docxsummarizer

## Overview

##### Project type and purpose
- This is a full-stack Python application with a Streamlit-based UI (app.py) and a FastAPI backend (fastapi_app.py).
- It ingests documents, uses utility modules (file_reader.py, pdf_reader.py) to parse them, then runs a summarization routine and returns results to the UI.

##### File structure
Top-level components:
- app.py – streamlit frontend
- fastapi_app.py – FastAPI server
- backend.py – orchestration between FastAPI and utils (optional entrypoint)
- utils/ – document-processing helpers
- tests/ – environment and integration tests
- .devcontainer/ – container setup for local development
- start_services.bat – script to launch both UI and API

##### README insights
- Two services must run in parallel: Streamlit UI & FastAPI backend.
- Interaction is via HTTP (UI calls the API).
- Dependencies are defined in requirements.txt.

##### Main components & their interactions
a. Components:
– User’s Browser (or local host)
– Streamlit UI (app.py)
– FastAPI Backend (fastapi_app.py)
– Document Processing Utilities (utils/file_reader.py, utils/pdf_reader.py)
– Summarization Engine (external library, e.g., Hugging Face or custom model)
– Local Filesystem (where docs reside)
– Development Container (.devcontainer)
– Tests (tests/test_env.py)

b. Data flows and relationships:
1. User uploads/selects document in Streamlit UI.
2. UI makes HTTP POST to FastAPI endpoint.
3. FastAPI handler invokes backend logic (backend.py) or directly calls utils/.
4. File is read via file_reader; if PDF, it goes through pdf_reader.
5. Text is passed to the summarization engine.
6. Summary returned to FastAPI, then relayed back to UI.
7. UI displays the summary.

c. Architectural patterns/principles:
– Clear separation of concerns (UI vs. API vs. utils).
– Single-responsibility for each module.
– Modular utility functions for parsing.
– Containerization support via .devcontainer.

d. Key technologies:
– Streamlit (frontend)
– FastAPI + Uvicorn (backend server)
– Python utilities for file & PDF handling
– Summarization library (specified in requirements.txt)

##### Putting it all together
- Top layer: User’s Browser → Streamlit UI (app.py)
- Middle layer: FastAPI backend (fastapi_app.py / backend.py)
- Bottom layer:
– Utils: file_reader.py → pdf_reader.py
– Summarizer (external library)
– Local filesystem
- Test flow: highlight tests invoking environment setup

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        Browser["User’s Browser"]:::external
        UI["Streamlit UI\n(app.py)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        API["FastAPI Backend\n(fastapi_app.py)"]:::backend
        Orchestrator["Backend Orchestration\n(backend.py)"]:::backend
    end

    %% Utils & Model Layer
    subgraph "Utils & Model Layer"
        FileReader["File Reader Utility\n(utils/file_reader.py)"]:::utils
        PDFReader["PDF Reader Utility\n(utils/pdf_reader.py)"]:::utils
        Summarizer["Summarization Engine\n(external lib)"]:::utils
        Filesystem["Local Filesystem"]:::infra
    end

    %% Infrastructure & Support
    subgraph "Infrastructure & Support"
        DevContainer["Development Container\n(.devcontainer)"]:::infra
        Tests["Env & Integration Tests\n(tests/test_env.py)"]:::infra
        Startup["Service Startup Script\n(start_services.bat)"]:::infra
        Deps["Dependencies\n(requirements.txt)"]:::infra
        Readme["Project README\n(README.md)"]:::infra
    end

    %% Connections
    Browser -->|"opens UI"| UI
    UI -->|"POST /summarize"| API
    API -->|"calls orchestration"| Orchestrator
    Orchestrator -->|"read_file()"| FileReader
    FileReader -->|"if PDF"| PDFReader
    FileReader -->|"reads doc"| Filesystem
    PDFReader -->|"reads pdf"| Filesystem
    FileReader -->|"extract_text()"| Summarizer
    PDFReader -->|"extract_text()"| Summarizer
    Summarizer -->|"summary result"| API
    API -->|"response"| UI

    %% Click Events
    click UI "https://github.com/piyushdhoka/drdo_docxsummarizer/blob/main/app.py"
    click API "https://github.com/piyushdhoka/drdo_docxsummarizer/blob/main/fastapi_app.py"
    click Orchestrator "https://github.com/piyushdhoka/drdo_docxsummarizer/blob/main/backend.py"
    click FileReader "https://github.com/piyushdhoka/drdo_docxsummarizer/blob/main/utils/file_reader.py"
    click PDFReader "https://github.com/piyushdhoka/drdo_docxsummarizer/blob/main/utils/pdf_reader.py"
    click DevContainer "https://github.com/piyushdhoka/drdo_docxsummarizer/blob/main/.devcontainer/devcontainer.json"
    click Tests "https://github.com/piyushdhoka/drdo_docxsummarizer/blob/main/tests/test_env.py"
    click Startup "https://github.com/piyushdhoka/drdo_docxsummarizer/blob/main/start_services.bat"
    click Deps "https://github.com/piyushdhoka/drdo_docxsummarizer/blob/main/requirements.txt"
    click Readme "https://github.com/piyushdhoka/drdo_docxsummarizer/blob/main/README.md"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#000;
    classDef backend fill:#D0FFD8,stroke:#28a745,color:#000;
    classDef utils fill:#FFE0B2,stroke:#e65100,color:#000;
    classDef infra fill:#E0E0E0,stroke:#6a737d,color:#000;
    classDef external fill:#F0F0F0,stroke:#444,color:#000;
```
