# sean1832/sumgpt architecture

> Architecture diagram of the GitHub repository sean1832/sumgpt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sean1832/sumgpt
- Repository: https://github.com/sean1832/sumgpt

## Overview

##### Main Components Identification
The system can be broken down into these key components:

a. Web Interface Layer (Streamlit)
- Located in SumGPT/app directory
- Contains page.py, sidebar_handler.py, and body_handler.py

b. Core Processing Layer
- Located in SumGPT/core directory
- Handles LLM interactions, tokenization, and encryption

c. Data Model Layer
- Located in SumGPT/datamodel directory
- Defines data structures for chunks, LLM models, and parameters

d. Utility Layer
- Located in SumGPT/utils directory
- Provides helper functions and I/O operations

**[Web Interface Layer] → [Core Processing Layer] → [OpenAI API]**
- ↑                        ↑

- [Utility Layer]        [Data Model Layer]

##### Important Relationships to Highlight
- Document flow: Input → Chunking → Parallel Processing → Summary
- Configuration flow: UI → Storage → Encryption → Cookie
- API interaction: Core → OpenAI API

##### Technical Details
- Python 3.11 runtime
- Streamlit framework
- Supported file formats (.txt, .md)
- Available GPT models (gpt-4o-mini, gpt-4o, etc.)
- Cookie encryption mechanism

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Web_Interface
        UI_Main["Main Page Interface"]
        UI_Sidebar["Sidebar Configuration"]
        UI_Body["Main Body Handler"]
    end

    subgraph Core_Processing
        CP_LLM["LLM Processing"]
        CP_Chunk["Document Chunking"]
        CP_Crypto["Encryption Handler"]
    end

    subgraph Data_Model
        DM_Chunk["Chunk Model"]
        DM_LLM["LLM Model Definitions"]
        DM_Params["LLM Parameters"]
    end

    subgraph Utility
        U_Helper["Helper Functions"]
        U_IO["I/O Operations"]
    end

    subgraph Config_Files
        CF_Models["Model Configurations"]
        CF_Manifest["System Manifest"]
        CF_Prompt["Prompt Templates"]
    end

    subgraph External_Services
        ES_OpenAI["OpenAI API"]
        ES_Browser["Browser Cookie Storage"]
    end

    %% Main Application Entry
    Entry["Application Entry Point"]

    %% Relationships
    Entry --> Web_Interface
    Web_Interface --> Core_Processing
    Core_Processing --> External_Services
    Data_Model --> Core_Processing
    Utility --> Web_Interface
    Utility --> Core_Processing
    Config_Files --> Core_Processing

    %% Component Relationships
    UI_Sidebar --> UI_Main
    UI_Body --> UI_Main
    CP_Chunk --> CP_LLM
    CP_Crypto --> ES_Browser
    CP_LLM --> ES_OpenAI

    %% Styling
    classDef ui fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef core fill:#90EE90,stroke:#333,stroke-width:2px
    classDef data fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef util fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef config fill:#F0E68C,stroke:#333,stroke-width:2px
    classDef external fill:#FF6B6B,stroke:#333,stroke-width:2px
    classDef entry fill:#FFFFFF,stroke:#333,stroke-width:2px

    class UI_Main,UI_Sidebar,UI_Body ui
    class CP_LLM,CP_Chunk,CP_Crypto core
    class DM_Chunk,DM_LLM,DM_Params data
    class U_Helper,U_IO util
    class CF_Models,CF_Manifest,CF_Prompt config
    class ES_OpenAI,ES_Browser external
    class Entry entry

    %% Click Events
    click UI_Main "https://github.com/sean1832/SumGPT/blob/master/SumGPT/app/page.py"
    click UI_Sidebar "https://github.com/sean1832/SumGPT/blob/master/SumGPT/app/sidebar_handler.py"
    click UI_Body "https://github.com/sean1832/SumGPT/blob/master/SumGPT/app/body_handler.py"
    click CP_LLM "https://github.com/sean1832/SumGPT/blob/master/SumGPT/core/llm.py"
    click CP_Chunk "https://github.com/sean1832/SumGPT/blob/master/SumGPT/core/tokenizer.py"
    click CP_Crypto "https://github.com/sean1832/SumGPT/blob/master/SumGPT/core/crypto.py"
    click DM_Chunk "https://github.com/sean1832/SumGPT/blob/master/SumGPT/datamodel/chunk.py"
    click DM_LLM "https://github.com/sean1832/SumGPT/blob/master/SumGPT/datamodel/llm_model.py"
    click DM_Params "https://github.com/sean1832/SumGPT/blob/master/SumGPT/datamodel/llm_params.py"
    click U_Helper "https://github.com/sean1832/SumGPT/blob/master/SumGPT/utils/helpers.py"
    click U_IO "https://github.com/sean1832/SumGPT/blob/master/SumGPT/utils/io.py"
    click CF_Models "https://github.com/sean1832/SumGPT/blob/master/SumGPT/models.json"
    click CF_Manifest "https://github.com/sean1832/SumGPT/blob/master/SumGPT/manifest.json"
    click CF_Prompt "https://github.com/sean1832/SumGPT/blob/master/SumGPT/prompt.json"
    click Entry "https://github.com/sean1832/SumGPT/blob/master/SumGPT/main.py"
```
