# gocarrot/cli-o-mat architecture

> Architecture diagram of the GitHub repository gocarrot/cli-o-mat, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gocarrot/cli-o-mat
- Repository: https://github.com/gocarrot/cli-o-mat

## Overview

##### Main Components Identification

a) CLI Interface Layer
- Root Command Handler (from cmd/root.go)
- Subcommand Handlers (deploy, hosts, images, launch, etc.)

b) AWS Interaction Layer (awsutil/)
- Authentication Handler
- Resource Fetchers (launch templates, security groups, subnets)

c) Configuration Management (config/)
- Credential Cache
- Configuration Constants
- Omat Configuration Handler

d) Utility Layer (util/)
- Error Handling
- Table Formatting

##### Component Relationships

**[User Input] → [CLI Interface Layer] → [AWS Interaction Layer] → [AWS Services]**
- ↑                           ↑

- ↓                          ↓
- [Configuration Layer] ←→ [Utility Layer]

##### Specific Design Elements

- Rectangles: Core components (CLI, AWS, Config)
- Clouds: External services (AWS)

- Blue: CLI interface components
- Green: AWS interaction components
- Yellow: Configuration components
- Gray: Utility components
- Orange: External services

##### Detailed Flow Representation

Following flows:

a) Command Flow:
**User Input → CLI Parser → Command Handler → AWS Utility → AWS API**

b) Authentication Flow:
**Command Handler → Config Layer → Credential Cache → AWS Auth → AWS API**

##### Important Details

- Major subcommands (launch, hosts, templates, etc.)
- Credential management flow
- AWS resource interaction patterns
- Error handling paths

##### Technical Specifications

Technical details:

- Go-based implementation
- AWS SDK integration
- Configuration file handling
- Credential caching mechanism

**[User Interface Layer]**
- ↓
**[Command Processing Layer]**
- ↓
**[AWS Interaction Layer]**
- ↓
**[External Services Layer]**

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph CLI
        UI[User Input]
        Root["Root Command Handler"]
        Deploy["Deploy Command"]
        Hosts["Hosts Command"]
        Launch["Launch Command"]
        Templates["Templates Command"]
        Version["Version Command"]
    end

    subgraph AWS
        Auth["Authentication Handler"]
        LTFetch["Launch Template Fetcher"]
        LTVFetch["Launch Template Versions"]
        SGFetch["Security Groups Fetcher"]
        SubnetFetch["Subnet Fetcher"]
    end

    subgraph Config
        CredCache[(Credential Cache)]
        Consts["Configuration Constants"]
        OmatConfig["Omat Configuration"]
    end

    subgraph Util
        ErrorHandle["Error Handling"]
        TableFormat["Table Formatting"]
    end

    AWSCloud((AWS Services)):::external

    UI --> Root
    Root --> Deploy
    Root --> Hosts
    Root --> Launch
    Root --> Templates
    Root --> Version

    Deploy & Hosts & Launch & Templates --> Auth
    Auth --> LTFetch & LTVFetch & SGFetch & SubnetFetch
    LTFetch & LTVFetch & SGFetch & SubnetFetch --> AWSCloud

    Auth --> CredCache
    CredCache --> Consts
    Consts --> OmatConfig

    ErrorHandle --> Root
    TableFormat --> Root

    %% Click Events
    click Root "https://github.com/GoCarrot/cli-o-mat/blob/main/cmd/root.go"
    click Deploy "https://github.com/GoCarrot/cli-o-mat/blob/main/cmd/deploy.go"
    click Hosts "https://github.com/GoCarrot/cli-o-mat/blob/main/cmd/hosts.go"
    click Launch "https://github.com/GoCarrot/cli-o-mat/blob/main/cmd/launch.go"
    click Templates "https://github.com/GoCarrot/cli-o-mat/blob/main/cmd/templates.go"
    click Version "https://github.com/GoCarrot/cli-o-mat/blob/main/cmd/version.go"
    click Auth "https://github.com/GoCarrot/cli-o-mat/blob/main/awsutil/auth.go"
    click LTFetch "https://github.com/GoCarrot/cli-o-mat/blob/main/awsutil/fetch_launch_templates.go"
    click LTVFetch "https://github.com/GoCarrot/cli-o-mat/blob/main/awsutil/fetch_launch_template_versions.go"
    click SGFetch "https://github.com/GoCarrot/cli-o-mat/blob/main/awsutil/fetch_security_groups.go"
    click SubnetFetch "https://github.com/GoCarrot/cli-o-mat/blob/main/awsutil/fetch_subnets.go"
    click CredCache "https://github.com/GoCarrot/cli-o-mat/blob/main/config/credential_cache.go"
    click Consts "https://github.com/GoCarrot/cli-o-mat/blob/main/config/consts.go"
    click OmatConfig "https://github.com/GoCarrot/cli-o-mat/blob/main/config/omat.go"
    click ErrorHandle "https://github.com/GoCarrot/cli-o-mat/blob/main/util/errors.go"
    click TableFormat "https://github.com/GoCarrot/cli-o-mat/blob/main/util/table.go"

    %% Styling
    classDef cli fill:#2374ab
    classDef aws fill:#2a9d8f
    classDef config fill:#e9c46a
    classDef util fill:#grey
    classDef external fill:#e76f51

    class UI,Root,Deploy,Hosts,Launch,Templates,Version cli
    class Auth,LTFetch,LTVFetch,SGFetch,SubnetFetch aws
    class CredCache,Consts,OmatConfig config
    class ErrorHandle,TableFormat util
    class AWSCloud external
```
