# scarowar/pear-review architecture

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

- Interactive diagram: https://gitdiagram.com/scarowar/pear-review
- Repository: https://github.com/scarowar/pear-review

## Overview

##### Main Components

a. VS Code Integration Layer
- Extension Host Process
- Command Registration System
- Status Bar Integration
- Editor Integration (for inline annotations)

b. Core Pear Review Engine
- Code Analysis Module
- Review Generation System
- Settings Management
- Git Integration Service

c. External Dependencies
- GitHub Copilot API
- Git System
- VS Code API

**[VS Code Editor Layer] → [Pear Review Extension Layer] → [External Services Layer]**

##### Component Relationships

Use the following connection types:

##### Key Flows

a. Review Trigger Flow:
- [File Save/Manual Trigger] → [Extension Host] → [Review Engine] → [Copilot API] → [Review Results] → [Editor Annotations]

b. Settings Flow:
- [VS Code Settings] → [Extension Config] → [Review Engine Behavior]

c. Git Integration Flow:
- [Git Working Directory] → [Git Service] → [Changed Files Detection] → [Review Scope]

##### Important Details

- Command Registration System showing the three main commands:
- Review
- Toggle Auto Review
- Toggle Review Annotations

- Editor Integration showing:
- Inline annotation system
- Review comment display
- Code change detection

##### Architectural Patterns to Highlight

- Event-driven architecture for VS Code integration
- Observer pattern for file changes
- Strategy pattern for different types of code analysis
- Factory pattern for review comment generation

##### Technical Stack Indicators

Following technologies:
- TypeScript (main implementation language)
- VS Code Extension API
- GitHub Copilot API
- Git

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef vscode fill:#4a9eff,color:white
    classDef core fill:#4CAF50,color:white
    classDef external fill:#9E9E9E,color:white
    classDef config fill:#FF9800,color:white

    %% VS Code Integration Layer
    subgraph VSCode["VS Code Integration Layer"]
        ExtHost["Extension Host"]:::vscode
        CmdReg["Commands Registry"]:::vscode
        StatusBar["Status Bar Integration"]:::vscode
        VSApi["VS Code API Integration"]:::vscode
    end

    %% Core Pear Review Engine
    subgraph Core["Core Pear Review Engine"]
        CodeAnalysis["Code Analysis Module"]:::core
        ReviewGen["Review Generation System"]:::core
        GitService["Git Integration Service"]:::core
        Settings["Settings Management"]:::core
    end

    %% External Services
    subgraph External["External Services"]
        Copilot["GitHub Copilot"]:::external
        GitLocal["Git Local Repository"]:::external
    end

    %% Configuration Components
    subgraph Config["Configuration"]
        ExtConfig["Extension Configuration"]:::config
        TSConfig["TypeScript Config"]:::config
        DevConfig["Development Config"]:::config
        Linting["Linting & Code Quality"]:::config
    end

    %% Relationships
    ExtHost --> CmdReg
    ExtHost --> StatusBar
    ExtHost --> VSApi
    VSApi --> CodeAnalysis
    CodeAnalysis --> ReviewGen
    ReviewGen --> Copilot
    GitService --> GitLocal
    Settings --> ExtConfig

    %% Click events for component mapping
    click ExtHost "https://github.com/scarowar/pear-review/blob/main/src/extension.ts"
    click ExtConfig "https://github.com/scarowar/pear-review/blob/main/package.json"
    click TSConfig "https://github.com/scarowar/pear-review/blob/main/tsconfig.json"
    click DevConfig "https://github.com/scarowar/pear-review/blob/main/.vscode-test.mjs"
    click Linting "https://github.com/scarowar/pear-review/blob/main/eslint.config.mjs"

    %% Legend
    subgraph Legend
        L1["VS Code Components"]:::vscode
        L2["Core Components"]:::core
        L3["External Services"]:::external
        L4["Configuration"]:::config
    end
```
