# suhailult777/ai-vscode-extension architecture

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

- Interactive diagram: https://gitdiagram.com/suhailult777/ai-vscode-extension
- Repository: https://github.com/suhailult777/ai-vscode-extension

## Overview

##### Main Components
- VS Code Host Environment – This is where the extension is installed and activated (via the Command Palette using the “Chat with Jarvis” command).
- Jarvis Extension Core – Represented by the primary source file (src/extension.ts) that contains the extension’s activation logic, event handlers, and interaction hooks with the VS Code API.
- Testing Suite – Located under src/test (e.g., extension.test.ts) that contains unit/integration tests for the extension.
- Ollama Service – An external dependency that must be installed and run locally. This component is responsible for AI model interactions (with the deepseek-r1 model) and streaming responses.
- Configuration & Metadata – Files like package.json, tsconfig.json, and others which define activation events, command contributions, and build settings.

##### Relationships and Interactions
- When a user triggers the “Chat with Jarvis” command in VS Code, the extension’s activationEvent is fired, and the main extension file (extension.ts) is executed.
- The extension then communicates with the locally running Ollama instance (via the Ollama Node.js dependency) for processing AI chat requests.
- Ollama processes the request (using the pulled deepseek-r1 model) and streams responses back to the extension.
- Responses and chat UI updates are shown within the VS Code window.
- Additionally, errors (such as issues with model availability) and developer logs are handled (and visible via the Developer Tools or the Output panel).

##### Architectural Patterns and Technologies
- The project adheres to the modular architecture typical of VS Code extensions, separating core logic (activation/command handling) from testing.
- The dependency on Ollama introduces an external service integration pattern, where the extension acts as a client sending requests and handling streaming responses.
- Use of Node.js, TypeScript, and npm as package management/build system are key technology choices.
- The setup in package.json (activationEvents and contributes.commands) demonstrates a clear separation of extension declaration and execution logic.

##### Detail
- That every major component—VS Code integration, AI communication, configuration settings, and testing—is clearly represented.
- Depending on your audience’s preference, you could further annotate components with technologies (e.g., Node.js, TypeScript, Ollama) to provide context on the technology stack.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "VS Code Host Environment"
        VSC("VS Code Host Environment"):::vscode
        CMD("Command Palette: 'Chat with Jarvis'"):::vscode
    end

    subgraph "Jarvis Extension Core"
        EXT("Extension Core (src/extension.ts)"):::core
    end

    subgraph "Configuration & Metadata"
        PKG("package.json"):::config
        TSC("tsconfig.json"):::config
    end

    subgraph "Testing Suite"
        TEST("extension.test.ts"):::testing
    end

    OS("Ollama Service (deepseek-r1)"):::external

    CMD -->|"activates"| EXT
    PKG -->|"configures"| EXT
    TSC -->|"configures"| EXT
    EXT -->|"sendsChatRequest"| OS
    OS -->|"streamsResponse"| EXT
    EXT -->|"updatesUI"| VSC
    TEST -->|"tests"| EXT

    click EXT "https://github.com/suhailult777/ai-vscode-extension/blob/master/src/extension.ts"
    click TEST "https://github.com/suhailult777/ai-vscode-extension/blob/master/src/test/extension.test.ts"
    click PKG "https://github.com/suhailult777/ai-vscode-extension/blob/master/package.json"
    click TSC "https://github.com/suhailult777/ai-vscode-extension/blob/master/tsconfig.json"

    classDef vscode fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef core fill:#c8e6c9,stroke:#1b5e20,stroke-width:2px;
    classDef testing fill:#f8bbd0,stroke:#880e4f,stroke-width:2px;
    classDef config fill:#e1bee7,stroke:#6a1b9a,stroke-width:2px;
    classDef external fill:#ffe082,stroke:#ff6f00,stroke-width:2px;
```
