# davidecanton/azure-devops-pr architecture

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

- Interactive diagram: https://gitdiagram.com/davidecanton/azure-devops-pr
- Repository: https://github.com/davidecanton/azure-devops-pr

## Overview

##### Project Type & Purpose
- The README clearly describes that this is a VS Code extension for managing Azure DevOps pull requests.
- The key functionalities include detecting a pull request based on the checked out branch, displaying comments in the editor via VS Code’s Comment API, and supporting operations like adding, replying, and updating comment threads.

##### Analyzing the File Structure and Architectural Components
- Core entry point: The extension is bootstrapped by the file “src/extension.ts”. This file plays the role of initializing the extension when VS Code activates it.
- Controller: “src/controller.ts” likely orchestrates the main commands and interactions triggered by the extension.
- Clients: The “src/clients” directory contains two subdirectories – “real” and “mocks”. These encapsulate the code for interacting with Azure DevOps:
- The “real” clients (e.g., src/clients/real/client.ts) likely make actual REST API calls to Azure DevOps.
- The “mocks” (in src/clients/mocks) are used for testing and simulating API responses.
- Comment Handling: “src/comment-handler.ts” is responsible for managing comment interactions using VS Code’s Comment API.
- Status Bar: “src/status-bar.ts” updates the VS Code status bar with pull request information and provides clickable interactions to open the PR in a browser.
- Supporting Modules: Additional files like configuration (src/config.ts), logging (src/logs.ts), git utilities (src/git-utils.ts), constants (src/constants.ts), and utilities (src/utils.ts) suggest a modular design that cleanly separates concerns such as configuration, logging, API interactions, and business logic.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "VS Code Environment"
        VSCode["VS Code Environment"]:::external
        ExtensionEntry["Extension Entry (extension.ts)"]:::module
    end

    subgraph "Core Extension"
        Controller["Controller Module (controller.ts)"]:::module
        CommentHandler["Comment Handler (src/comment-handler.ts)"]:::module
        StatusBar["Status Bar Module (src/status-bar.ts)"]:::module
    end

    subgraph "Azure DevOps API Clients"
        RealClient["Real Client (src/clients/real/client.ts)"]:::externalModule
        subgraph "Mocks"
            MockClient["Mock Client (src/clients/mocks/client.ts)"]:::externalModule
            MockPR["Mock PR (src/clients/mocks/pr.ts)"]:::externalModule
            MockThreads["Mock Threads (src/clients/mocks/threads.ts)"]:::externalModule
        end
    end

    subgraph "Supporting Modules"
        Config["Configuration (src/config.ts)"]:::support
        GitUtils["Git Utilities (src/git-utils.ts)"]:::support
        Logging["Logging (src/logs.ts)"]:::support
        Constants["Constants (src/constants.ts)"]:::support
        Utils["Utility Functions (src/utils.ts)"]:::support
    end

    subgraph "External Services"
        CommentsAPI["VS Code Comments API"]:::externalService
        StatusBarAPI["VS Code Status Bar API"]:::externalService
        AzureDevOps["Azure DevOps Service"]:::externalService
    end

    %% Data flow connections
    VSCode --> ExtensionEntry
    ExtensionEntry --> Controller

    Controller -->|"fetchPR"| RealClient
    Controller -->|"orFetchPR"| MockClient
    RealClient -->|"RESTcalls"| AzureDevOps
    MockClient -->|"simulateCalls"| AzureDevOps
    MockPR -.-> RealClient
    MockThreads -.-> RealClient

    Controller -->|"manageComments"| CommentHandler
    CommentHandler -->|"uses"| CommentsAPI

    Controller -->|"updateStatus"| StatusBar
    StatusBar -->|"integratesWith"| StatusBarAPI

    Controller -->|"usesConfig"| Config
    Controller --> GitUtils
    Controller --> Logging
    Controller --> Constants
    Controller --> Utils

    %% Click Events
    click ExtensionEntry "https://github.com/davidecanton/azure-devops-pr/blob/main/src/extension.ts"
    click Controller "https://github.com/davidecanton/azure-devops-pr/blob/main/src/controller.ts"
    click RealClient "https://github.com/davidecanton/azure-devops-pr/blob/main/src/clients/real/client.ts"
    click MockClient "https://github.com/davidecanton/azure-devops-pr/blob/main/src/clients/mocks/client.ts"
    click MockPR "https://github.com/davidecanton/azure-devops-pr/blob/main/src/clients/mocks/pr.ts"
    click MockThreads "https://github.com/davidecanton/azure-devops-pr/blob/main/src/clients/mocks/threads.ts"
    click CommentHandler "https://github.com/davidecanton/azure-devops-pr/blob/main/src/comment-handler.ts"
    click StatusBar "https://github.com/davidecanton/azure-devops-pr/blob/main/src/status-bar.ts"
    click Config "https://github.com/davidecanton/azure-devops-pr/blob/main/src/config.ts"
    click GitUtils "https://github.com/davidecanton/azure-devops-pr/blob/main/src/git-utils.ts"
    click Logging "https://github.com/davidecanton/azure-devops-pr/blob/main/src/logs.ts"
    click Constants "https://github.com/davidecanton/azure-devops-pr/blob/main/src/constants.ts"
    click Utils "https://github.com/davidecanton/azure-devops-pr/blob/main/src/utils.ts"

    %% Styles
    classDef external fill:#f9c,stroke:#333,stroke-width:2px;
    classDef module fill:#bbf,stroke:#333,stroke-width:2px;
    classDef externalModule fill:#fbf,stroke:#333,stroke-width:2px;
    classDef support fill:#bfb,stroke:#333,stroke-width:2px;
    classDef externalService fill:#ffb,stroke:#333,stroke-width:2px;
```
