# melkeydev/govm architecture

> Architecture diagram of the GitHub repository melkeydev/govm, 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/melkeydev/govm
- Repository: https://github.com/melkeydev/govm

## Overview

##### Main components
- CLI/TUI Interface: The entry point (main.go) handles both command-line commands and the interactive TUI (built using Charm’s Bubbletea library). This component is responsible for receiving user commands like “install”, “use”, “list”, and “help.”
- Internal Modules:
- internal/cli – Contains logic for parsing CLI commands.
- internal/model – Manages the core data structures and business logic behind version management.
- internal/setup – Handles the initial setup (e.g., guiding users through adding the shim directory to PATH).
- internal/styles – Provides styling definitions for the TUI, leveraging libraries like Lipgloss and Charm Bubbles.
- internal/utils – Contains common utilities and helper functions (including version-related utilities).
- External Dependencies & Integrations:
- The official Go download site (go.dev) which is used to fetch and install Go versions.
- The “shim” directory in the user’s home (~/.govm/shim), which acts as a redirector to the currently active Go version.
- Infrastructure & DevOps:
- GitHub workflows, issue templates, and other GitHub configurations are present for CI/CD, semantic versioning with goreleaser, and community contributions.

##### Understand the relationships and interactions
- The user interacts either with the TUI or directly via CLI.
- The main entry point (main.go) routes commands to components in internal/cli.
- The CLI interacts with the core model (internal/model) to execute version management commands.
- The setup component (internal/setup) is invoked during the first-time setup to ensure the shim directory is updated in the user's PATH.
- Styling for the TUI is handled by the internal/styles module, which uses external libraries like Bubbletea, Bubbles, and Lipgloss.
- Utility functions in internal/utils support tasks like version parsing, constant definitions, and managing the overall state.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global entities
    U("User"):::user

    %% Main Application subgraph
    subgraph "Main Application"
        A("CLI/TUI Interface"):::interface
        B("CLI Command Parsing (CLI Handler)"):::module
        C("Core Version Management (Model)"):::module
        D("Setup Manager"):::module
        E("TUI Styling and Rendering"):::module
        F("Utility Functions"):::module
    end

    %% External Dependencies
    G("Official Go Downloads (go.dev)"):::external
    H("Shim Directory (~/.govm/shim)"):::external

    %% DevOps & CI/CD
    I("DevOps & CI/CD"):::devops

    %% Connections from User to Main Application
    U --> A

    %% Connections within Main Application
    A --> B
    A --> D
    A --> E
    B --> C
    F --> B
    F --> C
    F --> D
    F --> E

    %% External Interactions
    C -->|"fetch"| G
    C -->|"redirect"| H
    D -->|"update"| H

    %% DevOps is auxiliary
    I --- A

    %% Click Events
    click A "https://github.com/melkeydev/govm/blob/main/main.go"
    click B "https://github.com/melkeydev/govm/blob/main/internal/cli/cli.go"
    click C "https://github.com/melkeydev/govm/blob/main/internal/model/model.go"
    click D "https://github.com/melkeydev/govm/blob/main/internal/setup/model.go"
    click E "https://github.com/melkeydev/govm/blob/main/internal/styles/constants.go"
    click E "https://github.com/melkeydev/govm/blob/main/internal/styles/styles.go"
    click F "https://github.com/melkeydev/govm/blob/main/internal/utils/constants.go"
    click F "https://github.com/melkeydev/govm/blob/main/internal/utils/utils.go"
    click F "https://github.com/melkeydev/govm/blob/main/internal/utils/version.go"
    click I "https://github.com/melkeydev/govm/blob/main/.github"
    click I "https://github.com/melkeydev/govm/blob/main/.goreleaser.yml"
    click I "https://github.com/melkeydev/govm/tree/main/.github/workflows"

    %% Styles
    classDef user fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef interface fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef module fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef devops fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
```
