# nareshedagotti/document-query-system architecture

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

- Interactive diagram: https://gitdiagram.com/nareshedagotti/document-query-system
- Repository: https://github.com/nareshedagotti/document-query-system

## Overview

##### Project type and purpose
- This is a Python‐based, single‐process full-stack application that provides a web interface (via Gradio) for uploading documents (PDF/DOCX/TXT), extracting their text, and querying them using two external LLM services (Groq API and Ollama).

##### File structure
- Top-level files:
- app.py ‑- application entry point, launches the Gradio server and ties everything together
- ui.py ‑- defines Gradio components (upload widget, radio button for model selection, chat history, text input)
- utils.py ‑- contains text-extraction routines (PDF, DOCX, TXT)
- models.py ‑- wraps the API calls to Groq and Ollama, implements send/query/receive logic
- requirements.txt, README.md, LICENSE, GitHub workflows for CI/CD

##### README for additional insights
- Documents the user flow: Upload → Select model → Ask question → Instant chat response.
- Calls out external dependencies: Groq API key, Ollama endpoint.
- No persistent database – state (chat history) is kept in memory.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Flow
    Browser((Browser)):::external
    UI["ui.py: Gradio UI Layer"]:::ui
    Controller["app.py: Orchestrator/Controller"]:::logic
    Extractor["utils.py: Text Extraction Module"]:::logic
    ModelInterface["models.py: Model Interface Module"]:::logic
    Groq[(Groq API)]:::external
    Ollama[(Ollama Service)]:::external

    Browser -->|"HTTP Request / File Upload / Query"| UI
    UI -->|"Event Callback"| Controller
    Controller -->|"Extract Text"| Extractor
    Controller -->|"Forward Text & Query"| ModelInterface
    ModelInterface -->|"API Call"| Groq
    ModelInterface -->|"API Call"| Ollama
    Groq -->|"Response"| ModelInterface
    Ollama -->|"Response"| ModelInterface
    ModelInterface -->|"Answer"| Controller
    Controller -->|"Render Chat"| UI
    UI -->|"HTTP Response"| Browser

    %% Ancillary Files
    subgraph "Ancillary Files"
        CI[".github/workflows/python-package-conda.yml"]:::ancillary
        Req["requirements.txt"]:::ancillary
        Readme["README.md"]:::ancillary
        License["LICENSE"]:::ancillary
    end

    %% Click Events
    click UI "https://github.com/nareshedagotti/document-query-system/blob/main/ui.py"
    click Controller "https://github.com/nareshedagotti/document-query-system/blob/main/app.py"
    click Extractor "https://github.com/nareshedagotti/document-query-system/blob/main/utils.py"
    click ModelInterface "https://github.com/nareshedagotti/document-query-system/blob/main/models.py"
    click CI "https://github.com/nareshedagotti/document-query-system/blob/main/.github/workflows/python-package-conda.yml"
    click Req "https://github.com/nareshedagotti/document-query-system/blob/main/requirements.txt"
    click Readme "https://github.com/nareshedagotti/document-query-system/blob/main/README.md"
    click License "https://github.com/nareshedagotti/document-query-system/tree/main/LICENSE"

    %% Styles
    classDef ui fill:#D6EFFF,stroke:#333,stroke-width:1px;
    classDef logic fill:#DFFFD6,stroke:#333,stroke-width:1px;
    classDef external fill:#FFEBD6,stroke:#333,stroke-width:1px;
    classDef ancillary fill:#F0F0F0,stroke:#999,stroke-width:1px,stroke-dasharray: 2 2;
```
