# czerny40/project-gpt architecture

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

- Interactive diagram: https://gitdiagram.com/czerny40/project-gpt
- Repository: https://github.com/czerny40/project-gpt

## Overview

Based on our analysis of the file structure and README, this project is an LLM-based chatbot service implemented in Python using Streamlit and LangChain. It provides several “GPT” modules (e.g., DocumentGPT, AudioGPT, PrivateGPT, QuizGPT, and SiteGPT) that offer specialized functionalities such as document analysis, audio transcription, and Q&A based on different input types. Although there are several Jupyter notebooks and example files, the core interactive application is driven by Streamlit (via Home.py/app.py) with separate modules under the “pages” directory, and supporting utilities in the “utils” folder. External integrations include OpenAI APIs, local LLM alternatives (e.g., ChatOllama), HuggingFace modules, and other AI/ML libraries (e.g., yt_dlp, pydub, ffmpeg).

##### Main Components
- Frontend/UI Layer
– The user interface is powered by Streamlit. This is represented by files such as Home.py and app.py.
- Service/Module Layer
– The “pages” directory encapsulates the main functional components (AudioGPT.py, DocumentGPT.py, PrivateGPT.py, QuizGPT.py, SiteGPT.py). These can be depicted as separate modules responsible for different conversation and processing tasks.
- Business Logic and Utilities
– Utility functions handling callbacks, chat management, document processing, and retrieval are in the “utils” folder.
– The configuration files (prompt.json, prompt.yaml, model.json) and the cache database (cache.db) support the back-end processing.
- External Services & APIs
– External APIs (OpenAI, HuggingFace, etc.) and local LLMs are key external integration points. These provide core LLM functionality.
- Experimental / Example Workbench
– Jupyter notebooks (agents.ipynb, assistant.ipynb, notebook.ipynb, whisper.ipynb) and the notebook examples in the “examples” directory demonstrate experimental code and usage examples.

##### Relationships & Interactions
- Shared Resources: Indicate how configuration (prompt files) or caching (cache.db) plays a role in the services.
- Additionally, note that while many experimental notebooks exist, they are not part of the production service but are useful for understanding and demonstrating the processing logic.

##### Architectural Patterns & Design Principles
- Separation of Concerns: Clearly separate the presentation layer (Streamlit UI) from the functional logic (different GPT pages) and from external API integrations.
- Modularity: Each GPT module acts as an independent service (functionally or as a micro-module) that leverages common utilities.
- Extensibility: The design supports adding more pages or integrating additional external services without impacting the overall structure.
- Reusability: The “utils” module provides shared functions across different GPT services.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend/UI Layer
    subgraph "Frontend/UI Layer"
        Home_py["Home.py"]:::frontend
        App_py["app.py"]:::frontend
    end

    %% Service/Module Layer
    subgraph "Service/Module Layer"
        AudioGPT["AudioGPT.py"]:::service
        DocumentGPT["DocumentGPT.py"]:::service
        PrivateGPT["PrivateGPT.py"]:::service
        QuizGPT["QuizGPT.py"]:::service
        SiteGPT["SiteGPT.py"]:::service
    end

    %% Business Logic & Utilities
    subgraph "Business Logic & Utilities"
        Utils["utils/"]:::utility
        Callback["callback_utils.py"]:::utility
        Chat["chat_utils.py"]:::utility
        DocumentUtil["document_utils.py"]:::utility
        Retriever["retriever_utils.py"]:::utility
        PromptJSON["prompt.json"]:::utility
        PromptYAML["prompt.yaml"]:::utility
        ModelJSON["model.json"]:::utility
        CacheDB["cache.db"]:::utility
    end

    %% External Services & APIs
    subgraph "External Services"
        OpenAI["OpenAI API"]:::external
        HuggingFace["HuggingFace"]:::external
        LocalLLM["LocalLLM (ChatOllama)"]:::external
    end

    %% Experimental / Example Workbench
    subgraph "Experimental / Example Workbench"
        Agents["agents.ipynb"]:::experimental
        Assistant["assistant.ipynb"]:::experimental
        Notebook["notebook.ipynb"]:::experimental
        Whisper["whisper.ipynb"]:::experimental
        Examples["examples/"]:::experimental
    end

    %% Data Flow: Frontend to Service Modules
    Home_py -->|"triggers"| AudioGPT
    Home_py -->|"triggers"| DocumentGPT
    Home_py -->|"triggers"| PrivateGPT
    Home_py -->|"triggers"| QuizGPT
    Home_py -->|"triggers"| SiteGPT
    App_py -->|"triggers"| AudioGPT
    App_py -->|"triggers"| DocumentGPT
    App_py -->|"triggers"| PrivateGPT
    App_py -->|"triggers"| QuizGPT
    App_py -->|"triggers"| SiteGPT

    %% Service Modules interact with Business Logic & Utilities
    AudioGPT -->|"processes"| Utils
    DocumentGPT -->|"processes"| Utils
    PrivateGPT -->|"processes"| Utils
    QuizGPT -->|"processes"| Utils
    SiteGPT -->|"processes"| Utils

    %% Utilities call External Services
    Utils -->|"calls"| OpenAI
    Utils -->|"calls"| HuggingFace
    Utils -->|"calls"| LocalLLM

    %% Direct integration from some GPT modules to External Services
    AudioGPT ---|"direct"| OpenAI
    DocumentGPT ---|"direct"| HuggingFace
    PrivateGPT ---|"direct"| LocalLLM

    %% Experimental Workbench connections (prototype/demonstration)
    AudioGPT ---|"prototype"| Agents
    DocumentGPT ---|"prototype"| Assistant
    PrivateGPT ---|"prototype"| Notebook
    QuizGPT ---|"prototype"| Whisper
    SiteGPT ---|"prototype"| Examples

    %% Click Events
    click Home_py "https://github.com/czerny40/project-gpt/blob/master/Home.py"
    click App_py "https://github.com/czerny40/project-gpt/blob/master/app.py"
    click AudioGPT "https://github.com/czerny40/project-gpt/blob/master/pages/AudioGPT.py"
    click DocumentGPT "https://github.com/czerny40/project-gpt/blob/master/pages/DocumentGPT.py"
    click PrivateGPT "https://github.com/czerny40/project-gpt/blob/master/pages/PrivateGPT.py"
    click QuizGPT "https://github.com/czerny40/project-gpt/blob/master/pages/QuizGPT.py"
    click SiteGPT "https://github.com/czerny40/project-gpt/blob/master/pages/SiteGPT.py"
    click Utils "https://github.com/czerny40/project-gpt/tree/master/utils/"
    click Callback "https://github.com/czerny40/project-gpt/blob/master/utils/callback_utils.py"
    click Chat "https://github.com/czerny40/project-gpt/blob/master/utils/chat_utils.py"
    click DocumentUtil "https://github.com/czerny40/project-gpt/blob/master/utils/document_utils.py"
    click Retriever "https://github.com/czerny40/project-gpt/blob/master/utils/retriever_utils.py"
    click PromptJSON "https://github.com/czerny40/project-gpt/blob/master/prompt.json"
    click PromptYAML "https://github.com/czerny40/project-gpt/blob/master/prompt.yaml"
    click ModelJSON "https://github.com/czerny40/project-gpt/blob/master/model.json"
    click CacheDB "https://github.com/czerny40/project-gpt/blob/master/cache.db"
    click Agents "https://github.com/czerny40/project-gpt/blob/master/agents.ipynb"
    click Assistant "https://github.com/czerny40/project-gpt/blob/master/assistant.ipynb"
    click Notebook "https://github.com/czerny40/project-gpt/blob/master/notebook.ipynb"
    click Whisper "https://github.com/czerny40/project-gpt/blob/master/whisper.ipynb"
    click Examples "https://github.com/czerny40/project-gpt/tree/master/examples/"

    %% Styles
    classDef frontend fill:#a3d8f4,stroke:#333,stroke-width:2px;
    classDef service fill:#b2f2bb,stroke:#333,stroke-width:2px;
    classDef utility fill:#fff3bf,stroke:#333,stroke-width:2px;
    classDef external fill:#d0bfff,stroke:#333,stroke-width:2px;
    classDef experimental fill:#ffc9de,stroke:#333,stroke-width:2px;
```
