# gradusnikov/eclipse-chatgpt-plugin architecture

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

- Interactive diagram: https://gitdiagram.com/gradusnikov/eclipse-chatgpt-plugin
- Repository: https://github.com/gradusnikov/eclipse-chatgpt-plugin

## Overview

##### Project Type and Purpose
- This is an Eclipse IDE plugin (OSGi-based) named AssistAI. Its purpose is to integrate a Large Language Model (LLM) assistant into Eclipse, providing code refactoring, documentation, test generation, chat, error fixing, vision, and tool-based extensions via the Model Context Protocol (MCP).

##### High-Level Architectural Components
a. Eclipse OSGi Container
- Hosts two main bundles:
- com.github.gradusnikov.eclipse.plugin.assistai.dependencies
- com.github.gradusnikov.eclipse.plugin.assistai.main
b. AssistAI Dependencies Bundle
- Provides third-party libraries: Jackson (JSON), Flexmark (Markdown), Selenium, PDFBox, Tika, Reactor, byte-buddy, MCP core, etc.
c. AssistAI Main Bundle
- UI Layer
- ChatView (Eclipse ViewPart)
- ChatViewPresenter
- Wizards & Dialogs (ApplyPatchWizardHelper)
- Context menus & handlers (AssistAI…Handler classes)
- CSS/JS for rendering
- Core Domain Layer
- Chat model (ChatMessage, Conversation, FunctionCall, Incoming)
- Prompt management (PromptLoader, ChatMessageFactory, Prompts)
- Repository (PromptRepository, ModelApiDescriptorRepository)
- Preferences (Model & MCP Server settings)
- Networking Layer
- LanguageModelClient (HTTP clients for OpenAI, Anthropic, Gemini, DeepSeek, etc.)
- Stream subscribers (AppendMessageToViewSubscriber, FunctionCallSubscriber, PrintMessageSubscriber)
- MCP Client Layer
- MCP client factory (McpClientServerFactory, InMemoryTransport)
- Built-in MCP servers (DuckDuckSearch, EclipseIntegrations, Time server, Memory server, WebPageReader)
- MCP services (CodeAnalysisService, EditorService, GitService, MavenService, etc.)
- Job Scheduling
- Eclipse Jobs API (SendConversationJob, ExecuteFunctionCallJob)
- Tools & Utilities
- File/tool helpers (AssistaiSharedFiles, ImageUtilities, ContentTypeDetector, UISynchronizeCallable)

##### External Dependencies & Services
- LLM Providers via HTTPS (OpenAI, Claude, Gemini, DeepSeek, etc.)
- MCP Servers (stdio-based processes you configure in preferences)
- Eclipse workspace and file system for reading/modifying resources
- Optional: Vision model interactions for images

##### Data Flow & Interactions
1. User invokes a command via context menu or toolbar → Handler
2. Handler builds a Conversation with PromptLoader & ChatMessageFactory
3. Handler schedules a SendConversationJob
4. Job calls LanguageModelClient through a provider (configured HTTP client)
5. Streamed LLM responses are published to subscribers
6. Subscribers update ChatView (UI) and/or trigger FunctionCall jobs
7. FunctionCallJob interacts with MCP client → external MCP server → returns data
8. UI presents enriched results; user may apply patch via ApplyPatchWizardHelper

##### Architectural Patterns and Principles
- OSGi modularity: clear separation of dependencies vs. main code
- MVC/MVP in UI: ChatView (view) + ChatViewPresenter (presenter) + model classes
- Reactor/Subscriber pattern for streaming LLM responses
- Job-based async execution via Eclipse Jobs API
- Dependency injection via OSGi service registry (Activator registers services)
- Repository pattern for prompts & model descriptors
- Adapter pattern in Network clients for different LLM protocols

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Eclipse OSGi Container"
        subgraph "Dependencies Bundle"
            Dep["Third-party libs (Jackson, Flexmark, Reactor, etc.)"]:::dependencies
        end
        subgraph "Main Bundle"
            subgraph "UI Layer"
                ChatView["ChatView"]:::ui
                ChatPresenter["ChatViewPresenter"]:::ui
                ApplyPatch["ApplyPatchWizardHelper"]:::ui
                subgraph "Handlers"
                    H1["AssistAICodeRefactorHandler"]:::ui
                    H2["AssistAIDiscussCodeHandler"]:::ui
                    H3["AssistAIFixErrorsHandler"]:::ui
                    H4["AssistAIJavaDocHandler"]:::ui
                    H5["AssistAIUnitTestHandler"]:::ui
                    H6["AssistAiGenerateGitCommentHandler"]:::ui
                end
            end
            subgraph "Core Domain Layer"
                subgraph "Chat Model"
                    CM1["ChatMessage"]:::domain
                    CM2["Conversation"]:::domain
                    CM3["FunctionCall"]:::domain
                    CM4["Incoming"]:::domain
                    CM5["Attachment"]:::domain
                end
                subgraph "Prompt Management"
                    PM1["PromptLoader"]:::domain
                    PM2["ChatMessageFactory"]:::domain
                    PM3["Prompts"]:::domain
                    PM4["MarkdownParser"]:::domain
                    PromptsFiles["MD Prompt Files"]:::domain
                end
                subgraph "Repositories"
                    Repo1["PromptRepository"]:::domain
                    Repo2["ModelApiDescriptorRepository"]:::domain
                end
                subgraph "Preferences"
                    Pref1["PreferenceConstants"]:::domain
                    Pref2["PreferenceInitializer"]:::domain
                    PrefMCP["McpServerPreferencePage"]:::domain
                    PrefModel["ModelListPreferencePage"]:::domain
                    PrefPrompt["PromptsPreferencePage"]:::domain
                end
            end
            subgraph "Networking Layer"
                subgraph "HTTP Clients"
                    LC["LanguageModelClient"]:::network
                    OAI["OpenAIStreamJavaHttpClient"]:::network
                    ANT["AnthropicStreamJavaHttpClient"]:::network
                    GEM["GeminiStreamJavaHttpClient"]:::network
                    DSS["DeepSeekStreamJavaHttpClient"]:::network
                end
                subgraph "Subscribers"
                    S1["AppendMessageToViewSubscriber"]:::network
                    S2["FunctionCallSubscriber"]:::network
                    S3["PrintMessageSubscriber"]:::network
                end
            end
            subgraph "MCP Client Layer"
                subgraph "Transport & Factory"
                    MF["McpClientServerFactory"]:::mcp
                    IMT["InMemoryTransport"]:::mcp
                end
                subgraph "Built-in Servers"
                    B1["DuckDuckSearchMcpServer"]:::mcp
                    B2["EclipseIntegrationsMcpServer"]:::mcp
                    B3["EclipseCodeEditingMcpServer"]:::mcp
                    B4["TimeMcpServer"]:::mcp
                    B5["MemoryMcpServer"]:::mcp
                    B6["ReadWebPageMcpServer"]:::mcp
                    BAll["McpServerBuiltins"]:::mcp
                end
                subgraph "Services"
                    Svc1["CodeAnalysisService"]:::mcp
                    Svc2["CodeEditingService"]:::mcp
                    Svc3["EditorService"]:::mcp
                    Svc4["GitService"]:::mcp
                    Svc5["JavaDocService"]:::mcp
                    Svc6["MavenService"]:::mcp
                    Svc7["ProjectService"]:::mcp
                    Svc8["ResourceService"]:::mcp
                    Svc9["UnitTestService"]:::mcp
                end
            end
            subgraph "Job Scheduler"
                J1["SendConversationJob"]:::jobs
                J2["ExecuteFunctionCallJob"]:::jobs
            end
            subgraph "Tools & Utilities"
                T1["AssistaiSharedFiles"]:::tools
                T2["ImageUtilities"]:::tools
                T3["ContentTypeDetector"]:::tools
                T4["UISynchronizeCallable"]:::tools
            end
        end
    end

    %% Relationships
    ChatView --> ChatPresenter
    ChatPresenter --> H1
    ChatPresenter --> H2
    ChatPresenter --> H3
    ChatPresenter --> H4
    ChatPresenter --> H5
    ChatPresenter --> H6

    H1 --> PM1
    H1 --> PM2
    H1 --> J1
    H2 --> PM1
    H2 --> PM2
    H2 --> J1
    H3 --> PM1
    H3 --> PM2
    H3 --> J1
    H4 --> PM1
    H4 --> PM2
    H4 --> J1
    H5 --> PM1
    H5 --> PM2
    H5 --> J1
    H6 --> PM1
    H6 --> PM2
    H6 --> J1

    J1 --> LC
    LC --> S1
    LC --> S2
    LC --> S3

    S1 --> ChatView
    S2 --> J2
    S3 --> ChatView

    J2 --> MF
    MF --> B1
    MF --> B2
    MF --> B3
    MF --> B4
    MF --> B5
    MF --> B6
    MF --> BAll

    B1 --> Svc1
    B2 --> Svc2
    B3 --> Svc3
    B4 --> Svc4
    B5 --> Svc5
    B6 --> Svc6
    BAll --> Svc7
    BAll --> Svc8
    BAll --> Svc9

    LC --> ExternalLLM["External LLM APIs"]:::external
    MF --> ExternalMCP["External MCP Servers"]:::external

    %% Click Events
    click Dep "https://github.com/gradusnikov/eclipse-chatgpt-plugin/blob/main/plugins/com.github.gradusnikov.eclipse.plugin.assistai.dependencies"
    click ChatView "https://github.com/gradusnikov/eclipse-chatgpt-plugin/blob/main/plugins/com.github.gradusnikov.eclipse.plugin.assistai.main/src/com/github/gradusnikov/eclipse/assistai/view/ChatView.java"
    click ChatPresenter "https://github.com/gradusnikov/eclipse-chatgpt-plugin/blob/main/plugins/com.github.gradusnikov.eclipse.plugin.assistai.main/src/com/github/gradusnikov/eclipse/assistai/view/ChatViewPresenter.java"
    click ApplyPatch "https://github.com/gradusnikov/eclipse-chatgpt-plugin/blob/main/plugins/com.github.gradusnikov.eclipse.plugin.assistai.main/src/com/github/gradusnikov/eclipse/assistai/view/ApplyPatchWizardHelper.java"
    click H1 "https://github.com/gradusnikov/eclipse-chatgpt-plugin/tree/main/plugins/com.github.gradusnikov.eclipse.plugin.assistai.main/src/com/github/gradusnikov/eclipse/assistai/handlers/"
    click CM1 "https://github.com/gradusnikov/eclipse-chatgpt-plugin/tree/main/plugins/com.github.gradusnikov.eclipse.plugin.assistai.main/src/com/github/gradusnikov/eclipse/assistai/chat/"
    click PM1 "https://github.com/gradusnikov/eclipse-chatgpt-plugin/blob/main/plugins/com.github.gradusnikov.eclipse.plugin.assistai.main/src/com/github/gradusnikov/eclipse/assistai/prompt/PromptLoader.java"
    click PromptsFiles "https://github.com/gradusnikov/eclipse-chatgpt-plugin/tree/main/plugins/com.github.gradusnikov.eclipse.plugin.assistai.main/prompts/"
    click Repo1 "https://github.com/gradusnikov/eclipse-chatgpt-plugin/blob/main/plugins/com.github/gradusnikov.eclipse.plugin.assistai.main/src/com/github/gradusnikov/eclipse/assistai/repository/PromptRepository.java"
    click Repo2 "https://github.com/gradusnikov/eclipse-chatgpt-plugin/blob/main/plugins/com.github.gradusnikov.eclipse.plugin.assistai.main/src/com/github/gradusnikov/eclipse/assistai/repository/ModelApiDescriptorRepository.java"
    click PrefMCP "https://github.com/gradusnikov/eclipse-chatgpt-plugin/blob/main/preferences/mcp/McpServerPreferencePage.java"
    click PrefModel "https://github.com/gradusnikov/eclipse-chatgpt-plugin/blob/main/preferences/models/ModelListPreferencePage.java"
    click PrefPrompt "https://github.com/gradusnikov/eclipse-chatgpt-plugin/blob/main/preferences/prompts/PromptsPreferencePage.java"
    click LC "https://github.com/gradusnikov/eclipse-chatgpt-plugin/tree/main/plugins/com.github.gradusnikov.eclipse.plugin.assistai.main/src/com/github/gradusnikov/eclipse/assistai/network/clients/"
    click S1 "https://github.com/gradusnikov/eclipse-chatgpt-plugin/tree/main/plugins/com.github.gradusnikov.eclipse.plugin.assistai.main/src/com/github/gradusnikov/eclipse/assistai/network/subscribers/"
    click MF "https://github.com/gradusnikov/eclipse-chatgpt-plugin/blob/main/plugins/com.github.gradusnikov.eclipse.plugin.assistai.main/src/com/github/gradusnikov/eclipse/assistai/mcp/McpClientServerFactory.java"
    click B1 "https://github.com/gradusnikov/eclipse-chatgpt-plugin/tree/main/plugins/com.github.gradusnikov.eclipse.plugin.assistai.main/src/com/github/gradusnikov/eclipse/assistai/mcp/servers/"
    click Svc1 "https://github.com/gradusnikov/eclipse-chatgpt-plugin/tree/main/plugins/com.github.gradusnikov.eclipse.plugin.assistai.main/src/com/github/gradusnikov/eclipse/assistai/mcp/services/"
    click J1 "https://github.com/gradusnikov/eclipse-chatgpt-plugin/blob/main/plugins/com.github.gradusnikov.eclipse.plugin.assistai.main/src/com/github/gradusnikov/eclipse/assistai/jobs/SendConversationJob.java"
    click J2 "https://github.com/gradusnikov/eclipse-chatgpt-plugin/blob/main/plugins/com.github.gradusnikov.eclipse.plugin.assistai.main/src/com/github/gradusnikov/eclipse/assistai/jobs/ExecuteFunctionCallJob.java"
    click T1 "https://github.com/gradusnikov/eclipse-chatgpt-plugin/tree/main/plugins/com.github.gradusnikov.eclipse.plugin.assistai.main/src/com/github/gradusnikov/eclipse/assistai/tools/"

    %% Styles
    classDef ui fill:#D0E6FF,stroke:#0066CC,color:#000
    classDef domain fill:#E6F6D0,stroke:#339900,color:#000
    classDef network fill:#FFE6CC,stroke:#FF8000,color:#000
    classDef mcp fill:#E6D0FF,stroke:#8000FF,color:#000
    classDef jobs fill:#FFD0D0,stroke:#CC0000,color:#000
    classDef tools fill:#F0F0F0,stroke:#666666,color:#000
    classDef dependencies fill:#CCCCCC,stroke:#333333,color:#000
    classDef external fill:#EEEEEE,stroke:#888888,color:#000
```
