# otnansirk/vscode-casing-convention architecture

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

- Interactive diagram: https://gitdiagram.com/otnansirk/vscode-casing-convention
- Repository: https://github.com/otnansirk/vscode-casing-convention

## Overview

##### Project Type and Purpose
- Type: A VSCode editor extension implemented in TypeScript
- Purpose: Provide a suite of text transformation commands (casing conversions, JSON tools, base64, UUIDs, translation) via the VSCode Command, CodeAction, and Hover APIs

##### High-Level Architectural Components
- VSCode Host (Extension Host process)
- Activation & Registration Module (src/extension.ts)
- Command Module (src/commands)
- Code Action Module (src/code-actions)
- Hover Module (src/hovers)
- Handler Functions (src/commands/handler, src/code-actions/handler, src/hovers/handler)
- Helper Library (src/helpers)
- Exception Layer (src/exception)
- External Services
– Translation service via google-translate-token (@types/google-translate-token.d.ts)

##### Component Relationships & Data Flows
1. Extension Activation
– VSCode starts the extension by invoking the `activate` function in src/extension.ts
– Registers components with VSCode API:
- commands via `commands.registerCommand`
- code actions via `CodeActionProvider`
- hover provider via `HoverProvider`
2. User Interaction
– User invokes a command (via Command Palette or keybinding) OR
– VSCode requests code actions OR
– User hovers over text
3. Command/CodeAction/Hover Dispatch
– VSCode routes the request to the appropriate provider (command handler, code action handler, or hover handler)
– The module’s register file (e.g., src/commands/commandRegister.ts) maps identifiers (e.g., “casing-convention.camelCase”) to handler functions
4. Handler Execution
– Handler receives editor context and selected text
– Uses helper functions (src/helpers) for splitting, case transformations, JSON operations, etc.
– May throw custom exceptions (src/exception/HasNoSelected.ts) if preconditions fail
– For translation handlers, calls out to the external translation token library and translation API
5. VSCode Edit
– Handlers create and apply `TextEdit` operations via the VSCode API to transform the document

##### Architectural Patterns & Design Principles
- Modular separation: commands, code-actions, hovers are isolated sub-systems
- Command Pattern: each transformation encapsulated in a handler with a clear interface
- Single Responsibility: helpers handle utility tasks, exceptions isolate error types
- Lazy activation: extension activates on commands, minimizing startup cost

##### Details to Capture
- Activation flow in extension.ts (how and when modules register)
- Registry files (commandProvider.ts, codeActionRegister.ts, codeActionRegister.ts, codeActionRegister.ts)
- Handler grouping by feature (casing, JSON, base64, UUID, translation)
- Helper functions for low-level tasks (object2UrlParams, splitWords)
- Custom exception for missing selection

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% VSCode and Host
    UI["VSCode Editor UI"]:::vscodeApp
    Host["Extension Host"]:::vscodeApp

    UI -->|"activate"| ActivationModule
    ActivationModule["Activation Module\n(extension.ts)"]:::extension
    click ActivationModule "https://github.com/otnansirk/vscode-casing-convention/blob/2.x/src/extension.ts"

    Host --> ActivationModule

    subgraph "Registries"
        CmdRegistry["Command Registry"]:::extension
        CodeActionRegistry["CodeAction Registry"]:::extension
        HoverRegistry["Hover Registry"]:::extension
    end

    subgraph "Handlers"
        CmdHandlers["Command Handlers"]:::extension
        CodeActionHandlers["CodeAction Handlers"]:::extension
        HoverHandlers["Hover Handlers"]:::extension
    end

    ActivationModule -->|"registerCommand"| CmdRegistry
    ActivationModule -->|"registerCodeAction"| CodeActionRegistry
    ActivationModule -->|"registerHover"| HoverRegistry

    CmdRegistry -->|"executeHandler"| CmdHandlers
    CodeActionRegistry -->|"provideCodeActions"| CodeActionHandlers
    HoverRegistry -->|"provideHover"| HoverHandlers

    %% External modules
    Helpers["Helper Library"]:::helper
    Exceptions["Exception Layer"]:::helper
    ExternalService["External Translation Service"]:::external
    VSCodeAPI["VSCode Editor API"]:::api

    CmdHandlers --> Helpers
    CodeActionHandlers --> Helpers
    HoverHandlers --> Helpers

    CmdHandlers --> Exceptions
    CodeActionHandlers --> Exceptions
    HoverHandlers --> Exceptions

    %% Translation handlers use external
    HoverHandlers --> ExternalService
    CmdHandlers --> ExternalService
    CodeActionHandlers --> ExternalService

    CmdHandlers -->|"applyTextEdit"| VSCodeAPI
    CodeActionHandlers -->|"applyTextEdit"| VSCodeAPI
    HoverHandlers -->|"applyTextEdit"| VSCodeAPI

    VSCodeAPI --> UI

    %% Click Events for components
    click CmdRegistry "https://github.com/otnansirk/vscode-casing-convention/blob/2.x/src/commands/commandRegister.ts"
    click CmdProvidersDir "https://github.com/otnansirk/vscode-casing-convention/tree/2.x/src/commands"
    click CommandProvider "https://github.com/otnansirk/vscode-casing-convention/blob/2.x/src/commands/commandProvider.ts"
    click CmdHandlers "https://github.com/otnansirk/vscode-casing-convention/tree/2.x/src/commands/handler"
    click CodeActionsDir "https://github.com/otnansirk/vscode-casing-convention/tree/2.x/src/code-actions"
    click CodeActionRegister "https://github.com/otnansirk/vscode-casing-convention/blob/2.x/src/code-actions/codeActionRegister.ts"
    click CodeActionHandlers "https://github.com/otnansirk/vscode-casing-convention/tree/2.x/src/code-actions/handler"
    click HoversDir "https://github.com/otnansirk/vscode-casing-convention/tree/2.x/src/hovers"
    click HoverRegister "https://github.com/otnansirk/vscode-casing-convention/blob/2.x/src/hovers/codeActionRegister.ts"
    click HoverHandlers "https://github.com/otnansirk/vscode-casing-convention/tree/2.x/src/hovers/handler"
    click Helpers "https://github.com/otnansirk/vscode-casing-convention/tree/2.x/src/helpers"
    click Exceptions "https://github.com/otnansirk/vscode-casing-convention/tree/2.x/src/exception"
    click ExternalService "https://github.com/otnansirk/vscode-casing-convention/blob/2.x/@types/google-translate-token.d.ts"

    %% Directory click placeholder
    CmdProvidersDir(["Command Module\n(src/commands)"]):::extension
    CodeActionsDir(["Code Action Module\n(src/code-actions)"]):::extension
    HoversDir(["Hover Module\n(src/hovers)"]):::extension

    classDef vscodeApp fill:#D0E6FF,stroke:#0366d6,color:#0366d6;
    classDef extension fill:#C8F7C5,stroke:#228B22,color:#228B22;
    classDef helper fill:#FFF3C4,stroke:#DAA520,color:#DAA520;
    classDef external fill:#FFD3B6,stroke:#FF8C00,color:#FF8C00;
    classDef api fill:#E8EAF6,stroke:#3F51B5,color:#3F51B5;
```
