# carlrobertoh/proxyai architecture

> Architecture diagram of the GitHub repository carlrobertoh/proxyai, 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/carlrobertoh/proxyai
- Repository: https://github.com/carlrobertoh/proxyai

## Overview

##### Project Type and Purpose
- ProxyAI is an open‐source AI copilot plugin for JetBrains IDEs. Its purpose is to provide an AI-powered code assistant that integrates chat, code completions, in-editor code edits, commit message generation, and more.
- It supports multiple AI providers (OpenAI, Anthropic, Azure, self-hosted models, etc.) and uses telemetry and additional features like image chat and context-aware file referencing.

##### File Structure to Identify Key Components
- Plugin Core & Entry Points:
- UI Components:
– UI-related classes (e.g., tool windows, status bar widgets, chat panels, editors, lookup components) are spread in directories like “src/main/java/ee/carlrobert/codegpt/toolwindow”, “ui”, “checkbox”, “textarea”, etc.
– These modules provide the chat interface, prompt inputs, diff or preview panels, and code preview tooltips.
- Actions & Command Handlers:
– Under “actions” directories (both Java and Kotlin), there are various handlers for editor actions (ask question, open new chat, attach image, etc.), tool window actions, commit message generation, and code completions.
- Code Completions and AI Integration:
– The “codecompletions” packages (both in Java and Kotlin) contain classes for creating requests, processing completion responses, splitting, debouncing, and interacting with external models.
– There are “factory” subdirectories (such as “factory/OpenAIRequestFactory.kt”, “LlamaRequestFactory.kt”, etc.) which abstract the provider-specific integration.
- Telemetry Module:
– The “codegpt-telemetry” directory hosts telemetry functionality. It contains classes for event construction, configuration (e.g., TelemetryConfiguration, FileConfiguration), and dispatching telemetry messages.
- Parsing & Treesitter Integration:
– A separate module “codegpt-treesitter” is present. This module appears to handle comprehensive parsing of code (for context extraction or smart completions) using Treesitter.
- Settings and Configuration:
– The “settings” directories (and respective service submodules like “openai”, “anthropic”, “azure”) provide the configuration UI and persistence for different AI providers, advanced settings, and preferences. These contain both forms and state management code.
- Utility and Supporting Modules:
– There are numerous utility classes for file handling, string manipulation, PSI (program structure interface) utilities, and coroutine dispatchers.
– The Gradle scripts and build modules (e.g., “build.gradle.kts”, “gradle/wrapper”) indicate standard project build and dependency management.

a. Main Components:
– Plugin Core & Lifecycle: Show the entry points (CodeGPTPlugin, Bundle, listeners) integrating with the IntelliJ platform.
– UI Components: Represent the chat tool window, editor-integrated actions, status bar widget, and settings dialogs.
– Telemetry System: A module that captures and sends analytics data from user interactions.
– Treesitter Module: Highlight as a specialized parser component that aids in providing context-aware assistance.
– Configuration & Settings: A separate module which interfaces with user preferences and service configurations.

b. Relationships & Interactions:
– Indicate that the core module dispatches events to either the AI integration module or telemetry module.
– Illustrate how configuration settings feed into the factories to select the correct AI provider.
– Include the integration between the code completions module and external AI services.
– Display the pipelines, such as user input → action handler → code completions request → response parsing → UI update.

c. Architectural Patterns and Design Principles:
– The project uses an event-driven plugin architecture where UI actions, listeners, and service components react to user commands and IDE events.
– There is a clear separation of concerns: UI, business logic (actions and services), communication with external providers (factories), and telemetry.
– Integration layers (factories for different AI providers and treesitter for parsing) abstract external dependencies, keeping the core plugin loosely coupled.

d. Relevant Technologies, Frameworks, and Libraries:
– IntelliJ Platform SDK (plugin development framework) is a foundational part.
– Java and Kotlin are used throughout the project.
– Gradle (with Kotlin DSL) for build and dependency management.
– Telemetry and external AI communication (HTTP or specialized SDK calls) and language parsing libraries (Treesitter integration).

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "IntelliJ Plugin Container"
        subgraph "Plugin Core & Lifecycle"
            PC1["CodeGPT Plugin"]
            PC2["CodeGPT Bundle"]
            PC3["Project Activity"]
            PC4["Update Activity"]
        end

        subgraph "UI Layer"
            UI1["Tool Window Factory"]
            UI2["Tool Window Chat"]
            UI3["General UI Elements"]
            UI4["Kotlin UI Components"]
        end

        subgraph "Action Handlers"
            AC1["Java Actions"]
            AC2["Kotlin Actions"]
        end

        subgraph "AI Integration & Code Completions"
            AI1["Java Code Completions"]
            AI2["Kotlin Code Completions"]
            AI3["Factory Components"]
        end

        subgraph "Telemetry Module"
            TM1["Telemetry Module"]
        end

        subgraph "Parsing Engine (Treesitter)"
            PT1["Treesitter Module"]
        end

        subgraph "Settings & Configuration"
            SC1["Java Settings"]
            SC2["Kotlin Settings"]
            SC3["Kotlin Settings Service"]
        end

        subgraph "Utility & Supporting Modules"
            UT1["Java Utility"]
            UT2["Kotlin Utility"]
        end

        subgraph "External AI Services"
            AIS["External AI Services"]
        end
    end

    %% Initialization Connections from Plugin Core to other layers
    PC1 -->|"init"| UI1
    PC1 -->|"init"| AC1
    PC1 -->|"init"| AI1
    PC1 -->|"init"| TM1
    PC1 -->|"init"| PT1
    PC1 -->|"init"| SC1
    PC1 -->|"init"| UT1

    %% UI triggers actions
    UI1 -->|"trigger"| AC1
    UI4 -->|"trigger"| AC2

    %% Action Handlers processing events
    AC1 -->|"process"| AI1
    AC2 -->|"process"| AI2
    AC1 -->|"send"| TM1
    AC2 -->|"send"| TM1

    %% Settings influence integration and telemetry
    SC1 -->|"configure"| AI3
    SC1 -->|"configure"| TM1

    %% AI Integration interacts with External AI Services
    AI1 -->|"request"| AIS
    AIS -->|"response"| AI1

    %% Class styles
    classDef plugin fill:#ffe6e6,stroke:#ff0000,stroke-width:2px;
    classDef ui fill:#e6f7ff,stroke:#005eff,stroke-width:2px;
    classDef actions fill:#e6ffe6,stroke:#00a000,stroke-width:2px;
    classDef integration fill:#fff0b3,stroke:#ff9900,stroke-width:2px;
    classDef telemetry fill:#f2e6ff,stroke:#9933ff,stroke-width:2px;
    classDef parsing fill:#e6ffff,stroke:#00cccc,stroke-width:2px;
    classDef settings fill:#f9e6ff,stroke:#ff66cc,stroke-width:2px;
    classDef utility fill:#e6ffe6,stroke:#33cc33,stroke-width:2px;
    classDef external fill:#f0f0f0,stroke:#999999,stroke-width:2px;

    class PC1,PC2,PC3,PC4 plugin;
    class UI1,UI2,UI3,UI4 ui;
    class AC1,AC2 actions;
    class AI1,AI2,AI3 integration;
    class TM1 telemetry;
    class PT1 parsing;
    class SC1,SC2,SC3 settings;
    class UT1,UT2 utility;
    class AIS external;

    %% Click Events for Plugin Core & Lifecycle
    click PC1 "https://github.com/carlrobertoh/proxyai/blob/master/src/main/java/ee/carlrobert/codegpt/CodeGPTPlugin.java"
    click PC2 "https://github.com/carlrobertoh/proxyai/blob/master/src/main/java/ee/carlrobert/codegpt/CodeGPTBundle.java"
    click PC3 "https://github.com/carlrobertoh/proxyai/blob/master/src/main/kotlin/ee/carlrobert/codegpt/CodeGPTProjectActivity.kt"
    click PC4 "https://github.com/carlrobertoh/proxyai/blob/master/CodeGPTUpdateActivity.kt"

    %% Click Events for UI Components
    click UI1 "https://github.com/carlrobertoh/proxyai/blob/master/src/main/java/ee/carlrobert/codegpt/toolwindow/ProjectToolWindowFactory.java"
    click UI2 "https://github.com/carlrobertoh/proxyai/tree/master/src/main/java/ee/carlrobert/codegpt/toolwindow/chat"
    click UI3 "https://github.com/carlrobertoh/proxyai/tree/master/src/main/java/ee/carlrobert/codegpt/ui"
    click UI4 "https://github.com/carlrobertoh/proxyai/tree/master/src/main/kotlin/ee/carlrobert/codegpt/toolwindow/ui"

    %% Click Events for Actions & Command Handlers
    click AC1 "https://github.com/carlrobertoh/proxyai/tree/master/src/main/java/ee/carlrobert/codegpt/actions"
    click AC2 "https://github.com/carlrobertoh/proxyai/tree/master/src/main/kotlin/ee/carlrobert/codegpt/actions"

    %% Click Events for Code Completions and AI Integration
    click AI1 "https://github.com/carlrobertoh/proxyai/tree/master/src/main/java/ee/carlrobert/codegpt/completions"
    click AI2 "https://github.com/carlrobertoh/proxyai/tree/master/src/main/kotlin/ee/carlrobert/codegpt/codecompletions"
    click AI3 "https://github.com/carlrobertoh/proxyai/tree/master/src/main/kotlin/ee/carlrobert/codegpt/completions/factory"

    %% Click Event for Telemetry Module
    click TM1 "https://github.com/carlrobertoh/proxyai/tree/master/codegpt-telemetry/src/main/java/ee/carlrobert/codegpt/telemetry"

    %% Click Event for Parsing & Treesitter Integration
    click PT1 "https://github.com/carlrobertoh/proxyai/tree/master/codegpt-treesitter/src/main/java/ee/carlrobert/codegpt/treesitter"

    %% Click Events for Settings & Configuration
    click SC1 "https://github.com/carlrobertoh/proxyai/tree/master/src/main/java/ee/carlrobert/codegpt/settings"
    click SC2 "https://github.com/carlrobertoh/proxyai/tree/master/src/main/kotlin/ee/carlrobert/codegpt/settings"
    click SC3 "https://github.com/carlrobertoh/proxyai/tree/master/src/main/kotlin/ee/carlrobert/codegpt/settings/service"

    %% Click Events for Utility and Supporting Modules
    click UT1 "https://github.com/carlrobertoh/proxyai/tree/master/src/main/java/ee/carlrobert/codegpt/util"
    click UT2 "https://github.com/carlrobertoh/proxyai/tree/master/src/main/kotlin/ee/carlrobert/codegpt/util"
```
