# olasunkanmi-se/codebuddy architecture

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

- Interactive diagram: https://gitdiagram.com/olasunkanmi-se/codebuddy
- Repository: https://github.com/olasunkanmi-se/codebuddy

## Overview

##### Project Type & Purpose
- CodeBuddy is a Visual Studio Code extension designed as an AI coding assistant that integrates multiple generative AI providers. Its main purpose is to enhance coding productivity by offering features such as code generation, refactoring, inline chat, unit test creation, and more.
- The project contains both the VS Code extension components (e.g., commands, webview UI, and integration with the VS Code editor) and underlying core application parts (like AI agents, memory, services, infrastructure, and provider integrations).

##### File Structure and Architecture Breakdown
- Top-Level Directories:
- “src”: Houses the core application.
◦ “agents”: Contains various AI agents for orchestration and prompting.
◦ “application”: Defines constants and interfaces that serve as a contract between layers.
◦ “commands”: Implementation of VS Code commands (each mapped to a specific feature, e.g., code-completion, comment generation, refactoring).
◦ “infrastructure”: Contains subdirectories for HTTP services, logging, repository (code storage, database management), and storage mechanisms.
◦ “llms”: Integrations for multiple language models (Anthropic, Gemini, Groq, etc.).
◦ “memory”: Implements memory systems (context, summarization, sliding, unconstrained) to handle session and context management.
◦ “providers”: Implements integrations with external services and interfaces that drive features (web view events, secret storage, code actions).
◦ “services”: Provides business logic (e.g., code indexing, context retrieval, embedding, GitHub authentication, file handling).
◦ “webview”: Contains code for VS Code webview supporting the React-based UI.
- “webviewUi”: Contains a React-based implementation of the extension’s UI (with details for themes, components, and configuration).

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% VS Code Extension Frontend
    subgraph "VS Code Extension Frontend"
        CE["Editor Interface"]:::frontend
        CL["Commands Layer"]:::frontend
        WV1["Webview (VS Code)"]:::frontend
        WV2["Webview (React UI)"]:::frontend
    end

    %% Core Application Layer
    subgraph "Core Application"
        AA["AI Agents"]:::core
        MS["Memory System"]:::core
        subgraph "Application Services"
            BL["Business Logic"]:::core
            AI["Application Interfaces"]:::core
        end
        subgraph "Infrastructure Layer"
            HTTP["HTTP Services"]:::infra
            LOG["Logging"]:::infra
            REP["Repository"]:::infra
            LS["Local Storage"]:::infra
        end
    end

    %% AI Providers
    subgraph "AI Providers"
        LLM["Language Model Integrations"]:::provider
        ESP["External Service Providers"]:::provider
    end

    %% Storage Layer
    subgraph "Storage Layer"
        DB["Database (SQLite)"]:::storage
        FS["File System"]:::storage
        VD["Vector Database"]:::storage
    end

    %% Connections between VS Code Extension Frontend
    CE -->|"UserInput"| CL
    CL -->|"ProcessRequest"| AA
    CL -->|"UIUpdate"| WV1

    %% Connections within Core Application
    AA -->|"ContextManagement"| MS
    AA -->|"Orchestration"| BL
    AA -->|"ContractCall"| AI

    %% Connections to Infrastructure
    AA -->|"APIRequest"| HTTP
    HTTP -->|"APICall"| LLM
    HTTP -->|"APICall"| ESP
    HTTP -->|"Feedback"| WV1

    %% Connections from Application Services to Storage
    BL -->|"DataAccess"| DB
    BL -->|"FileAccess"| FS
    BL -->|"EmbedData"| VD
    AI -->|"RepositoryAccess"| REP

    %% Memory System stores context to Storage
    MS -->|"StoreContext"| DB

    %% Styling Classes
    classDef frontend fill:#cce5ff,stroke:#2a6592,stroke-width:2px;
    classDef core fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef infra fill:#f8d7da,stroke:#a71d2a,stroke-width:2px;
    classDef provider fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef storage fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;

    %% Click Events
    click CE "https://github.com/olasunkanmi-se/codebuddy/blob/main/src/extension.ts"
    click CL "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/commands"
    click WV1 "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/webview"
    click WV2 "https://github.com/olasunkanmi-se/codebuddy/tree/main/webviewUi"
    click AA "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/agents"
    click MS "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/memory"
    click BL "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/services"
    click AI "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/application"
    click HTTP "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/infrastructure/http"
    click LOG "https://github.com/olasunkanmi-se/codebuddy/blob/main/src/infrastructure/logger/logger.ts"
    click REP "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/infrastructure/repository"
    click LS "https://github.com/olasunkanmi-se/codebuddy/blob/main/src/infrastructure/storage/local-storage.ts"
    click LLM "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/llms"
    click ESP "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/providers"
    click DB "https://github.com/olasunkanmi-se/codebuddy/tree/main/src/infrastructure/repository"
    click FS "https://github.com/olasunkanmi-se/codebuddy/blob/main/src/services/file-system.ts"
```
