# thejaytea/writingtools architecture

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

- Interactive diagram: https://gitdiagram.com/thejaytea/writingtools
- Repository: https://github.com/thejaytea/writingtools

## Overview

##### High-Level Components

a) Create three main container blocks:
- Windows/Linux Implementation (Python-based)
- macOS Implementation (Swift-based)
- External Services/APIs

##### For the Windows/Linux Implementation, include these components

a) Core Components:
- Main Application (main.py)
- Writing Tool App (WritingToolApp.py)
- AI Provider Interface (aiprovider.py)
- Update Checker (update_checker.py)

b) UI Layer (show as a separate container):
- Response Window
- Settings Window
- Onboarding Window
- About Window
- Custom Popup Window
- Autostart Manager

##### For the macOS Implementation, include

a) Core Components:
- App Delegate
- App State Manager
- Update Checker
- Window Manager

b) Models Layer:
- AI Providers (OpenAI, Gemini)
- App Settings
- Custom Commands

c) UI Layer:
- Content View
- Response View
- Settings View
- Onboarding View
- Custom Modifiers

##### External Services (show as cloud components)
- OpenAI API
- Google Gemini API
- Local LLM Services (Ollama)
- Update Check Server

- Text input from system-wide selection to application
- Communication between UI and core components
- API calls to external services
- Response flow back to UI
- Update check communications

##### Important technical details

- Hotkey listener system (ctrl+space)
- Text selection mechanism
- API communication protocols
- Local configuration storage
- Cross-platform compatibility layers

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef core fill:#90EE90,stroke:#333,stroke-width:2px
    classDef ui fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef external fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef storage fill:#FFE4B5,stroke:#333,stroke-width:2px

    %% Main Sections
    subgraph Windows_Linux["Windows/Linux Implementation"]
        %% Core Components
        WLMain["Main Application"]:::core
        WLTA["Writing Tool App"]:::core
        WLAI["AI Provider Interface"]:::core
        WLUpdate["Update Checker"]:::core

        %% UI Components
        subgraph WL_UI["UI Layer"]
            WLResponse["Response Window"]:::ui
            WLSettings["Settings Window"]:::ui
            WLOnboard["Onboarding Window"]:::ui
            WLAbout["About Window"]:::ui
            WLPopup["Custom Popup Window"]:::ui
            WLAutostart["Autostart Manager"]:::ui
        end
    end

    subgraph MacOS["macOS Implementation"]
        %% Core Components
        MacDelegate["App Delegate"]:::core
        MacState["App State Manager"]:::core
        MacUpdate["Update Checker"]:::core
        MacWindow["Window Manager"]:::core

        %% Models Layer
        subgraph Mac_Models["Models Layer"]
            MacAIBase["AI Provider Base"]:::core
            MacOpenAI["OpenAI Provider"]:::core
            MacGemini["Gemini Provider"]:::core
            MacSettings["App Settings"]:::core
            MacCommands["Custom Commands"]:::core
        end

        %% UI Layer
        subgraph Mac_UI["UI Layer"]
            MacContent["Content View"]:::ui
            MacResponse["Response View"]:::ui
            MacSettingsView["Settings View"]:::ui
            MacOnboard["Onboarding View"]:::ui
            MacPopup["Popup View"]:::ui
            MacModifiers["Custom Modifiers"]:::ui
        end
    end

    %% External Services
    subgraph External["External Services"]
        OpenAI["OpenAI API"]:::external
        Gemini["Google Gemini API"]:::external
        Ollama["Local LLM Services\n(Ollama)"]:::external
        UpdateServer["Update Check Server"]:::external
    end

    %% Relationships
    WLMain --> WLTA
    WLTA --> WLAI
    WLAI --> OpenAI
    WLAI --> Gemini
    WLAI --> Ollama
    WLUpdate --> UpdateServer
    WLTA --> WL_UI

    MacDelegate --> MacState
    MacState --> Mac_Models
    MacState --> Mac_UI
    MacAIBase --> MacOpenAI
    MacAIBase --> MacGemini
    MacOpenAI --> OpenAI
    MacGemini --> Gemini
    MacUpdate --> UpdateServer

    %% Click events
    click WLMain "https://github.com/theJayTea/WritingTools/blob/main/Windows_and_Linux/main.py"
    click WLTA "https://github.com/theJayTea/WritingTools/blob/main/Windows_and_Linux/WritingToolApp.py"
    click WLAI "https://github.com/theJayTea/WritingTools/blob/main/Windows_and_Linux/aiprovider.py"
    click WLUpdate "https://github.com/theJayTea/WritingTools/blob/main/Windows_and_Linux/update_checker.py"
    click WLResponse "https://github.com/theJayTea/WritingTools/blob/main/Windows_and_Linux/ui/ResponseWindow.py"
    click WLSettings "https://github.com/theJayTea/WritingTools/blob/main/Windows_and_Linux/ui/SettingsWindow.py"
    click WLOnboard "https://github.com/theJayTea/WritingTools/blob/main/Windows_and_Linux/ui/OnboardingWindow.py"
    click WLAbout "https://github.com/theJayTea/WritingTools/blob/main/Windows_and_Linux/ui/AboutWindow.py"
    click WLPopup "https://github.com/theJayTea/WritingTools/blob/main/Windows_and_Linux/ui/CustomPopupWindow.py"
    click WLAutostart "https://github.com/theJayTea/WritingTools/blob/main/Windows_and_Linux/ui/AutostartManager.py"
    click MacDelegate "https://github.com/theJayTea/WritingTools/blob/main/macOS/writing-tools/AppDelegate.swift"
    click MacState "https://github.com/theJayTea/WritingTools/blob/main/macOS/writing-tools/AppState.swift"
    click MacUpdate "https://github.com/theJayTea/WritingTools/blob/main/macOS/writing-tools/UpdateChecker.swift"
    click MacWindow "https://github.com/theJayTea/WritingTools/blob/main/macOS/writing-tools/UI/WindowManager.swift"
    click MacAIBase "https://github.com/theJayTea/WritingTools/blob/main/macOS/writing-tools/Models/AIProvider.swift"
    click MacOpenAI "https://github.com/theJayTea/WritingTools/blob/main/macOS/writing-tools/Models/OpenAIProvider.swift"
    click MacGemini "https://github.com/theJayTea/WritingTools/blob/main/macOS/writing-tools/Models/GeminiProvider.swift"
    click MacSettings "https://github.com/theJayTea/WritingTools/blob/main/macOS/writing-tools/Models/AppSettings.swift"
    click MacCommands "https://github.com/theJayTea/WritingTools/blob/main/macOS/writing-tools/Commands/CustomCommand.swift"
    click MacContent "https://github.com/theJayTea/WritingTools/blob/main/macOS/writing-tools/ContentView.swift"
    click MacResponse "https://github.com/theJayTea/WritingTools/blob/main/macOS/writing-tools/UI/ResponseView.swift"
    click MacSettingsView "https://github.com/theJayTea/WritingTools/blob/main/macOS/writing-tools/UI/SettingsView.swift"
    click MacOnboard "https://github.com/theJayTea/WritingTools/blob/main/macOS/writing-tools/UI/OnboardingView.swift"
    click MacPopup "https://github.com/theJayTea/WritingTools/blob/main/macOS/writing-tools/UI/PopupView.swift"
    click MacModifiers "https://github.com/theJayTea/WritingTools/tree/main/macOS/writing-tools/UI/Custom Modifiers/"
```
