# roadiehouse/pcproblemsolver architecture

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

- Interactive diagram: https://gitdiagram.com/roadiehouse/pcproblemsolver
- Repository: https://github.com/roadiehouse/pcproblemsolver

## Overview

##### Main Components

a) Frontend Layer:
- UI Components (PyQt5-based)
- Chat Interface
- Screenshot Capture System
- Input Handling

b) Application Core:
- Message Handler
- Screenshot Processor
- Worker System (for async operations)

c) AI Integration Layer:
- Mistral AI Client
- OpenAI Integration (backup/alternative)

d) External Services:
- Mistral AI API
- (Optional) OpenAI API

**┌─────────────────────────────────────────────┐**
- UI Layer                    │
- (ui/interface.py, chat_bubble.py,          │
- typing_indicator.py)                      │
- ┤
- Application Core               │
- (app/handlers.py, screenshot.py,           │
- worker.py)                                │
- ┤
- AI Service Layer               │
- (app/mistral.py, openai.py)               │
- ┘

##### Component Relationships

- User interaction → UI Layer
- UI Layer → Application Core (for processing)
- Application Core → AI Service Layer
- AI Service Layer → External APIs

##### Detailed Component Breakdown

UI Layer:
- Main Interface (ui/interface.py)
- Chat Bubbles (ui/chat_bubble.py)
- Typing Indicator (ui/typing_indicator.py)
- Styling (ui/resources/styles.qss)

Application Core:
- Message Handlers (app/handlers.py)
- Screenshot Processor (app/screenshot.py)
- Async Worker (app/worker.py)
- Resource Management (app/resource_path.py)

AI Integration:
- Mistral Client (app/mistral.py)
- OpenAI Client (app/openai.py)

##### Additional Elements

- Data flow indicators showing how screenshots and messages move through the system
- State management between components
- Error handling paths
- Configuration management (environment variables, API keys)

##### Key Architectural Patterns to Highlight

- Singleton pattern for Mistral client
- Event-driven architecture for UI interactions
- Asynchronous processing for API calls
- Resource management system

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef ai fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef legend fill:none,stroke:#666,color:#666

    %% UI Layer
    subgraph UI
        Interface["Main Interface"]:::ui
        ChatBubbles["Chat Bubbles"]:::ui
        TypingIndicator["Typing Indicator"]:::ui
        Styling["UI Styling"]:::ui
    end

    %% Application Core
    subgraph Core
        MessageHandler["Message Handler"]:::core
        ScreenshotProc["Screenshot Processor"]:::core
        AsyncWorker["Async Worker"]:::core
        ResourceMgmt["Resource Management"]:::core
    end

    %% AI Integration Layer
    subgraph AI
        MistralClient["Mistral Client"]:::ai
        OpenAIClient["OpenAI Client"]:::ai
    end

    %% External Services
    subgraph External
        MistralAPI["Mistral AI API"]:::external
        OpenAIAPI["OpenAI API"]:::external
    end

    %% Relationships
    Interface --> MessageHandler
    Interface --> ScreenshotProc
    ChatBubbles --> Interface
    TypingIndicator --> Interface
    Styling --> Interface
    
    MessageHandler --> AsyncWorker
    ScreenshotProc --> AsyncWorker
    AsyncWorker --> MistralClient
    AsyncWorker --> OpenAIClient
    ResourceMgmt --> MessageHandler
    
    MistralClient --> MistralAPI
    OpenAIClient --> OpenAIAPI

    %% Legend
    subgraph Legend
        UI_Legend["UI Components"]:::ui
        Core_Legend["Core Components"]:::core
        AI_Legend["AI Components"]:::ai
        Ext_Legend["External Services"]:::external
    end

    %% Click Events
    click Interface "https://github.com/RoadieHouse/PCProblemSolver/blob/main/ui/interface.py"
    click ChatBubbles "https://github.com/RoadieHouse/PCProblemSolver/blob/main/ui/chat_bubble.py"
    click TypingIndicator "https://github.com/RoadieHouse/PCProblemSolver/blob/main/ui/typing_indicator.py"
    click Styling "https://github.com/RoadieHouse/PCProblemSolver/blob/main/ui/resources/styles.qss"
    click MessageHandler "https://github.com/RoadieHouse/PCProblemSolver/blob/main/app/handlers.py"
    click ScreenshotProc "https://github.com/RoadieHouse/PCProblemSolver/blob/main/app/screenshot.py"
    click AsyncWorker "https://github.com/RoadieHouse/PCProblemSolver/blob/main/app/worker.py"
    click ResourceMgmt "https://github.com/RoadieHouse/PCProblemSolver/blob/main/app/resource_path.py"
    click MistralClient "https://github.com/RoadieHouse/PCProblemSolver/blob/main/app/mistral.py"
    click OpenAIClient "https://github.com/RoadieHouse/PCProblemSolver/blob/main/app/openai.py"
```
