# deviceinsight/azctx architecture

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

- Interactive diagram: https://gitdiagram.com/deviceinsight/azctx
- Repository: https://github.com/deviceinsight/azctx

## Overview

##### Project Type and Its Purpose
- This is a lightweight command line tool written in Go. Its aim is to simplify working with the official Azure CLI by allowing users to more easily change their default subscription/account and resource group.
- It’s inspired by kubectx, so its design encourages quick context switching using a command line interface.
- Key external dependencies include the Azure CLI and fzf for fuzzy searching and interactive selection.

##### File Structure
- The project is very compact with most code in “main.go” and dependency management in “go.mod.”
- There is a GitHub workflows directory showing automation for releases. The .goreleaser.yaml file indicates that the project uses GoReleaser to package and distribute the binary.
- The file tree hints at a single binary project where the majority of business logic is concentrated in one or a few files (focusing on CLI interaction, integration with az cli, and launching fzf).

##### Key Components to Highlight
a. Command Line Interface (CLI):
- At the front-end of the tool is the CLI where the user starts the process.

b. Core Application Logic (Main Go Application):
- The "main.go" file houses the core logic. This includes invoking the Azure CLI commands to retrieve existing subscriptions/accounts and resource groups.
- It controls the logic to integrate with fzf to provide an interactive selection experience.

c. External Dependencies:
- Azure CLI: The application calls the az cli to retrieve subscription information and possibly manipulate the context.
- fzf: Used to enhance user interaction via fuzzy search when listing options.

d. Build and Release Automation:
- GitHub Actions Workflows: Automated tasks (as seen in “.github/workflows/release.yml”) handle testing, building, and releasing the tool.
- GoReleaser: Configured via “.goreleaser.yaml” to package the application and manage releases.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    subgraph "User Interaction"
        A("CLI User"):::user
    end

    %% Core Application
    subgraph "Core Application"
        B("CLI Interface (main.go)"):::internal
    end

    %% External Dependencies
    subgraph "External Dependencies"
        C("Azure CLI Integration"):::external
        D("fzf Integration"):::external
    end

    %% Project Configuration
    subgraph "Project Configuration"
        E1("go.mod"):::config
        E2(".goreleaser.yaml"):::config
    end

    %% Build and Release Pipeline
    subgraph "Build and Release Pipeline"
        F("GitHub Actions Workflow (.github/workflows/release.yml)"):::automation
    end

    %% Connections
    A -->|"UserInput"| B
    B -->|"CommandExecution"| C
    B -->|"CommandExecution"| D
    B -->|"TriggerBuild"| F
    E1 -->|"Packaging"| F
    E2 -->|"Packaging"| F

    %% Click Events
    click B "https://github.com/deviceinsight/azctx/blob/main/main.go"
    click E1 "https://github.com/deviceinsight/azctx/blob/main/go.mod"
    click E2 "https://github.com/deviceinsight/azctx/blob/main/.goreleaser.yaml"
    click F "https://github.com/deviceinsight/azctx/blob/main/.github/workflows/release.yml"

    %% Styles
    classDef user fill:#f9c,stroke:#333,stroke-width:2px;
    classDef internal fill:#bbf,stroke:#333,stroke-width:2px;
    classDef external fill:#cfc,stroke:#333,stroke-width:2px;
    classDef config fill:#fcf,stroke:#333,stroke-width:2px;
    classDef automation fill:#ff9,stroke:#333,stroke-width:2px;
```
