# nicepkg/aide architecture

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

- Interactive diagram: https://gitdiagram.com/nicepkg/aide
- Repository: https://github.com/nicepkg/aide

## Overview

##### Main Components Identification

The system should be divided into these primary components:

a) Extension Core
- Command Management System
- AI Integration Layer
- File System Handlers
- Configuration Management
- I18n System

b) AI Service Providers
- OpenAI Integration
- Azure OpenAI Integration
- Claude (Anthropic) Integration
- Other LLM Providers

c) Feature Modules
- Code Conversion System
- Code Viewer Helper
- Expert Code Enhancer
- Smart Paste Handler
- Batch Processing System
- Variable Renaming System
- AI Query System
- Prompt Management

d) UI Components
- WebView Interface
- Status Bar Integration
- VSCode Command Palette Integration

##### Relationship Mapping

**[VSCode Extension Host] ←→ [Extension Core]**
- ↑
- ↓
**[UI Components] ←→ [Feature Modules] ←→ [AI Service Providers]**
- ↑
- ↓
- [File System Handlers]

##### Specific Implementation Details

a) Data Flow:
- How commands flow from VSCode to the extension
- How AI requests are processed and returned
- Demonstrate file system interactions
- Configuration management flow

b) Key Integration Points:
- VSCode API integration points
- AI service provider interfaces
- File system interaction points
- WebView communication channels

##### Important Architectural Patterns

- Command Pattern (for feature implementations)
- Provider Pattern (for AI services)
- Observer Pattern (for file system watching)
- Factory Pattern (for AI service creation)

##### Technical Stack Highlights

- TypeScript as primary language
- VSCode Extension API
- Various AI Service APIs
- WebView for UI components
- File System APIs

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph VSCode
        VSHost[VSCode Extension Host]
    end

    subgraph Core
        ExtCore[Extension Core]
        CmdMgr[Command Management]
        AILayer[AI Integration Layer]
        FSHandler[File System Handlers]
        Config[Configuration]
        I18n[I18n System]
    end

    subgraph AI
        OpenAI[OpenAI Service]
        AzureAI[Azure OpenAI Service]
        Claude[Claude Service]
        OtherLLM[Other LLM Providers]
    end

    subgraph Features
        CodeConv[Code Conversion]
        CodeView[Code Viewer]
        CodeEnh[Expert Enhancer]
        SmartPaste[Smart Paste]
        BatchProc[Batch Processing]
        VarRename[Variable Renaming]
        AIQuery[AI Query System]
    end

    subgraph UI
        WebView[WebView Interface]
        StatusBar[Status Bar]
        CmdPalette[Command Palette]
    end

    subgraph Support
        Storage[Storage System]
        Logger[Logger]
        Context[Context Management]
        Constants[Constants]
    end

    VSHost <--> ExtCore
    ExtCore --> CmdMgr
    ExtCore --> AILayer
    ExtCore --> FSHandler
    ExtCore --> Config
    ExtCore --> I18n

    AILayer --> OpenAI
    AILayer --> AzureAI
    AILayer --> Claude
    AILayer --> OtherLLM

    CmdMgr --> CodeConv
    CmdMgr --> CodeView
    CmdMgr --> CodeEnh
    CmdMgr --> SmartPaste
    CmdMgr --> BatchProc
    CmdMgr --> VarRename
    CmdMgr --> AIQuery

    ExtCore --> WebView
    ExtCore --> StatusBar
    ExtCore --> CmdPalette

    ExtCore --> Storage
    ExtCore --> Logger
    ExtCore --> Context
    ExtCore --> Constants

    classDef core fill:#a8d1f0
    classDef ai fill:#90EE90
    classDef feature fill:#FFB347
    classDef ui fill:#DDA0DD
    classDef support fill:#F0E68C

    class ExtCore,CmdMgr,AILayer,FSHandler,Config,I18n core
    class OpenAI,AzureAI,Claude,OtherLLM ai
    class CodeConv,CodeView,CodeEnh,SmartPaste,BatchProc,VarRename,AIQuery feature
    class WebView,StatusBar,CmdPalette ui
    class Storage,Logger,Context,Constants support

    click CmdMgr "https://github.com/nicepkg/aide/blob/master/src/extension/commands/index.ts"
    click AILayer "https://github.com/nicepkg/aide/tree/master/src/extension/ai"
    click FSHandler "https://github.com/nicepkg/aide/tree/master/src/extension/file-utils"
    click Config "https://github.com/nicepkg/aide/blob/master/src/extension/config.ts"
    click I18n "https://github.com/nicepkg/aide/blob/master/src/extension/i18n.ts"
    click OpenAI "https://github.com/nicepkg/aide/blob/master/src/extension/ai/model-providers/openai.ts"
    click AzureAI "https://github.com/nicepkg/aide/blob/master/src/extension/ai/model-providers/azure-openai.ts"
    click Claude "https://github.com/nicepkg/aide/blob/master/src/extension/ai/model-providers/claude.ts"
    click CodeConv "https://github.com/nicepkg/aide/tree/master/src/extension/commands/code-convert"
    click CodeView "https://github.com/nicepkg/aide/tree/master/src/extension/commands/code-viewer-helper"
    click CodeEnh "https://github.com/nicepkg/aide/tree/master/src/extension/commands/expert-code-enhancer"
    click SmartPaste "https://github.com/nicepkg/aide/tree/master/src/extension/commands/smart-paste"
    click BatchProc "https://github.com/nicepkg/aide/tree/master/src/extension/commands/batch-processor"
    click VarRename "https://github.com/nicepkg/aide/tree/master/src/extension/commands/rename-variable"
    click AIQuery "https://github.com/nicepkg/aide/tree/master/src/extension/commands/ask-ai"
    click WebView "https://github.com/nicepkg/aide/blob/master/src/extension/providers/webview.ts"
    click StatusBar "https://github.com/nicepkg/aide/blob/master/src/extension/providers/aide-key-usage-statusbar.ts"
    click Storage "https://github.com/nicepkg/aide/blob/master/src/extension/storage.ts"
    click Logger "https://github.com/nicepkg/aide/blob/master/src/extension/logger.ts"
    click Context "https://github.com/nicepkg/aide/blob/master/src/extension/context.ts"
    click Constants "https://github.com/nicepkg/aide/blob/master/src/extension/constants.ts"
```
