# trypear/pearai-submodule architecture

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

## Overview

##### Main Components

a. IDE Extensions Layer
- VSCode Extension
- IntelliJ Extension
- Common IDE Protocol Interface

b. Core Services Layer
- LLM Integration Services
- Context Providers
- Autocomplete Engine
- Command Handlers
- Indexing Services

c. GUI Layer
- Webview Interface
- Editor Inset Components
- Dialog Systems

d. Infrastructure Layer
- Binary Communication Layer
- Authentication Services
- Analytics Services
- Configuration Management

##### Component Relationships

**[IDE Extensions] → [Core Protocol Layer] → [Core Services] ↔ [External LLMs/Services]**
- ↕                    ↕                   ↕
**[Binary Communication] ← [Configuration] → [GUI Components]**

##### Detailed Component Breakdown

a. IDE Extensions (Blue)
- VSCode Extension
- Command Handlers
- Editor Integration
- Extension Lifecycle
- IntelliJ Extension
- Action Handlers
- Editor Integration
- Plugin Lifecycle

b. Core Services (Green)
- LLM Integration
- Provider Adapters
- Stream Handling
- Token Management
- Context System
- File Context
- Code Context
- Custom Context
- Indexing
- Code Indexer
- Search
- Embeddings

c. GUI Components (Purple)
- Main Chat Interface
- Editor Insets
- Command Palette
- Settings Panels

##### Key Integration Points to Highlight

- Bidirectional communication between IDE extensions and core services
- Flow of code context from IDE to LLM services
- Configuration management affecting all layers
- Authentication flow through the system

##### Implementation Details to Note

- Version/configuration flow indicators

This system design should emphasize the extensible nature of the project, showing how new IDE integrations or LLM providers can be added without major architectural changes.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef ide fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef gui fill:#9b59b6,stroke:#8e44ad,color:white
    classDef infra fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef external fill:#e67e22,stroke:#d35400,color:white

    %% IDE Extensions Layer
    subgraph IDELayer["IDE Extensions Layer"]
        VSCode["VSCode Extension"]
        IntelliJ["IntelliJ Extension"]
        Protocol["Common IDE Protocol"]
    end

    %% Core Services Layer
    subgraph CoreLayer["Core Services Layer"]
        LLM["LLM Integration"]
        Context["Context Providers"]
        Autocomplete["Autocomplete Engine"]
        Commands["Command Handlers"]
        Indexing["Indexing Services"]
    end

    %% GUI Layer
    subgraph GUILayer["GUI Layer"]
        Webview["Webview Interface"]
        EditorInset["Editor Inset Components"]
        Dialogs["Dialog Systems"]
    end

    %% Infrastructure Layer
    subgraph InfraLayer["Infrastructure Layer"]
        Binary["Binary Communication"]
        Auth["Authentication Services"]
        Analytics["Analytics Services"]
        Config["Configuration Management"]
    end

    %% External Services
    ExternalLLM["External LLM Providers"]:::external

    %% Relationships
    VSCode & IntelliJ --> Protocol
    Protocol --> CoreLayer
    CoreLayer <--> ExternalLLM
    Binary --> Protocol
    Config --> CoreLayer
    Config --> GUILayer
    CoreLayer --> GUILayer
    Auth --> CoreLayer
    Analytics --> CoreLayer
    Binary --> GUILayer

    %% Apply styles
    class VSCode,IntelliJ,Protocol ide
    class LLM,Context,Autocomplete,Commands,Indexing core
    class Webview,EditorInset,Dialogs gui
    class Binary,Auth,Analytics,Config infra

    %% Click events
    click VSCode "https://github.com/trypear/pearai-submodule/tree/main/extensions/vscode/"
    click IntelliJ "https://github.com/trypear/pearai-submodule/tree/main/extensions/intellij/"
    click Protocol "https://github.com/trypear/pearai-submodule/tree/main/core/protocol/"
    click LLM "https://github.com/trypear/pearai-submodule/tree/main/core/llm/"
    click Context "https://github.com/trypear/pearai-submodule/tree/main/core/context/providers/"
    click Autocomplete "https://github.com/trypear/pearai-submodule/tree/main/core/autocomplete/"
    click Commands "https://github.com/trypear/pearai-submodule/tree/main/core/commands/"
    click Indexing "https://github.com/trypear/pearai-submodule/tree/main/core/indexing/"
    click Webview "https://github.com/trypear/pearai-submodule/tree/main/gui/src/"
    click EditorInset "https://github.com/trypear/pearai-submodule/tree/main/gui/editorInset/"
    click Dialogs "https://github.com/trypear/pearai-submodule/tree/main/gui/src/components/dialogs/"
    click Binary "https://github.com/trypear/pearai-submodule/tree/main/binary/"
    click Auth "https://github.com/trypear/pearai-submodule/tree/main/core/control-plane/auth/"
    click Analytics "https://github.com/trypear/pearai-submodule/tree/main/core/control-plane/analytics/"
    click Config "https://github.com/trypear/pearai-submodule/tree/main/core/config/"
```
