# franklyc/tmspeech-companion architecture

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

- Interactive diagram: https://gitdiagram.com/franklyc/tmspeech-companion
- Repository: https://github.com/franklyc/tmspeech-companion

## Overview

##### Main Components

a) Frontend Layer (GUI Components):
- Title Bar
- Content Area
- Settings Dialog
These are represented in the src/gui directory structure.

b) Configuration Layer:
- API Keys
- Default Settings
- Language Configurations
- Custom Prefix/Suffix Management
Based on src/config directory.

c) API Integration Layer:
- Cerebras
- Groq
- Google Gemini
- Sambanova
- Zhipu
- GLHF
- SiliconFlow
- Local LLM Connection
Based on src/api directory.

##### Component Relationships

- User Interface → Configuration Management (bidirectional)
- Configuration Management → API Services (unidirectional)
- API Services → External LLM Providers (bidirectional)
- GUI Layer → File System (bidirectional, for transcript file handling)

##### Data Flow Representation

- Input Flow: Transcript Files → GUI → API Services → LLM Providers
- Output Flow: LLM Providers → API Services → GUI → User/Export
- Configuration Flow: Settings → All Components

##### Technical Stack Indicators

Labels for key technologies:
- PyQt6 (GUI Framework)
- Python 3.x
- REST APIs (for LLM integration)
- Local file system interaction

##### Additional Elements

- A "Theme Management" component showing light/dark mode switching
- Language switching mechanism between Chinese/English

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef gui fill:#a8d1f0,stroke:#2c3e50
    classDef service fill:#90EE90,stroke:#2c3e50
    classDef external fill:#FFB347,stroke:#2c3e50
    classDef storage fill:#D3D3D3,stroke:#2c3e50

    %% Presentation Layer
    subgraph PresentationLayer["Presentation Layer"]
        MainWindow["Main Window"]
        TitleBar["Title Bar"]
        Sidebar["Sidebar"]
        ContentArea["Content Area"]
        Settings["Settings Dialog"]
        QuickActions["Quick Actions"]
    end

    %% Business Logic Layer
    subgraph BusinessLayer["Business Logic Layer"]
        ConfigService["Configuration Service"]
        LangService["Language Service"]
        APIService["API Service"]
        Utils["Utilities"]
        PrefixConfig["Prefix Configuration"]
    end

    %% External Services Layer
    subgraph ExternalLayer["External Services Layer"]
        subgraph LLMProviders["LLM Providers"]
            Cerebras["Cerebras"]
            Groq["Groq"]
            Gemini["Google Gemini"]
            Sambanova["Sambanova"]
        end
        
        subgraph LocalSystem["Local System"]
            FileSystem["File System"]
            Clipboard["Clipboard"]
        end
    end

    %% Component Relationships
    MainWindow --> TitleBar
    MainWindow --> Sidebar
    MainWindow --> ContentArea
    Sidebar --> QuickActions
    
    MainWindow --> ConfigService
    MainWindow --> LangService
    MainWindow --> APIService
    
    APIService --> LLMProviders
    ConfigService --> LocalSystem
    
    %% Data Flows
    ContentArea -..-> APIService
    APIService -..-> LLMProviders
    FileSystem -..-> ContentArea
    Clipboard -..-> ContentArea

    %% Legend
    subgraph Legend["Legend"]
        L1["GUI Component"]:::gui
        L2["Core Service"]:::service
        L3["External Service"]:::external
        L4["Storage"]:::storage
    end

    %% Component Styles
    class MainWindow,TitleBar,Sidebar,ContentArea,Settings,QuickActions gui
    class ConfigService,LangService,APIService,Utils,PrefixConfig service
    class Cerebras,Groq,Gemini,Sambanova,FileSystem,Clipboard external
    
    %% Click Events
    click MainWindow "https://github.com/Franklyc/TMSpeech-companion/blob/main/src/gui/qt_gui.py"
    click TitleBar "https://github.com/Franklyc/TMSpeech-companion/blob/main/src/gui/title_bar.py"
    click Sidebar "https://github.com/Franklyc/TMSpeech-companion/blob/main/src/gui/sidebar.py"
    click ContentArea "https://github.com/Franklyc/TMSpeech-companion/blob/main/src/gui/content_area.py"
    click Settings "https://github.com/Franklyc/TMSpeech-companion/blob/main/src/gui/settings_dialog.py"
    click APIService "https://github.com/Franklyc/TMSpeech-companion/blob/main/src/api/api.py"
    click ConfigService "https://github.com/Franklyc/TMSpeech-companion/blob/main/src/config/config.py.example"
    click LangService "https://github.com/Franklyc/TMSpeech-companion/blob/main/src/gui/lang.py"
    click Utils "https://github.com/Franklyc/TMSpeech-companion/blob/main/src/gui/utils.py"
    click PrefixConfig "https://github.com/Franklyc/TMSpeech-companion/blob/main/src/gui/prefix.py.example"
```
