# manudiv16/eaws architecture

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

- Interactive diagram: https://gitdiagram.com/manudiv16/eaws
- Repository: https://github.com/manudiv16/eaws

## Overview

##### Project Type and Purpose
- EAWS is a **Go-based CLI tool** built with Cobra for interacting with AWS services (ECS, CloudWatch Logs, CodePipeline).

##### File Structure
- **cmd/**: Houses each Cobra command (container, logs, pipeline, root).
- **main.go** & **cmd/root.go**: CLI entry point and initialization.
- **scripts & config**: install.sh, uninstall.sh, setup-completion.sh for installation; .github/workflows for CI/CD.
- **Formula/**: Homebrew formula for package distribution.

##### Main Components
a. **Client Layer (CLI Frontend)**
- User’s Terminal
- eaws binary (main.go + cmd/ package)
- Cobra command parser & promptui interactive prompts
b. **Application Logic Layer**
- Command handlers (container.go, logs_query.go, pipeline.go, etc.)
- internal/utils for:
- AWS SDK v2 wrappers
- AWS profile resolution (including granted integration)
c. **External Dependencies**
- AWS SDK for Go v2 (network calls to AWS APIs)
- promptui library (interactive selection)
d. **AWS Services (Remote)**
- Amazon ECS
- CloudWatch Logs
- CodePipeline
e. **Configuration & Environment**
- AWS credentials & profiles (~/.aws)
- Environment variables (AWS_PROFILE, NO_COLOR)
f. **Deployment/Installation**
- Shell install scripts (install.sh/uninstall.sh)
- Homebrew Formula
- CI/CD pipelines (.github/workflows)

##### Relationships & Data Flow
- User types `eaws <command>` → Cobra parses command → invokes corresponding handler.
- Handler uses internal/utils to:
- Resolve AWS profile (CLI flag, env var, granted)
- Initialize AWS SDK client
- Make API calls to AWS services
- Process & format response
- Render colorized output or interactive prompt.
- CLI → Command Parser → Handler → AWS SDK → AWS Service
- AWS Service → AWS SDK → Handler → CLI Output.
- Side-flows:
- CLI reads config from local file system
- Installation scripts write binary to `/usr/local/bin` / Homebrew.

##### Key Architectural Patterns
- **Modular CLI commands** via Cobra (each command in its own file).
- **Adapter/Wrapper** pattern in internal/utils around AWS SDK.
- **Separation of concerns**: parsing, business logic, AWS integration, and output formatting are distinct modules.
- **Interactive UI abstraction** via promptui.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CLI Frontend
    subgraph "CLI Frontend"
        UT[/"User Terminal"/]:::frontend
        Main["main.go"]:::frontend
        Root["cmd/root.go"]:::frontend
    end

    %% Application Logic Layer
    subgraph "Application Logic" 
        direction TB
        subgraph "Cobra Commands"
            Container["cmd/container.go"]:::logic
            ContainerConnect["cmd/container_connect.go"]:::logic
            ContainerList["cmd/container_list.go"]:::logic
            Logs["cmd/logs.go"]:::logic
            LogsQuery["cmd/logs_query.go"]:::logic
            LogsView["cmd/logs_view.go"]:::logic
            Pipeline["cmd/pipeline.go"]:::logic
        end
        subgraph "Internal Utils"
            AWSWr["internal/utils/aws.go"]:::logic
            AWSHelp["internal/utils/aws_help.go"]:::logic
            Colors["internal/utils/colors.go"]:::logic
        end
    end

    %% External Dependencies
    subgraph "External Libraries" 
        AWS_SDK["AWS SDK for Go v2"]:::external
        PromptUI["promptui"]:::external
        ColorLib["fatih/color"]:::external
    end

    %% AWS Services
    subgraph "AWS Services (Remote)"
        ECS["Amazon ECS"]:::aws
        LogsSvc["CloudWatch Logs"]:::aws
        PipelineSvc["CodePipeline"]:::aws
    end

    %% Configuration & Environment
    subgraph "Config & Env" 
        Creds["AWS Credentials (~/.aws)"]:::config
        EnvVars["Env Vars (AWS_PROFILE, NO_COLOR)"]:::config
    end

    %% Deployment & Installation
    subgraph "Deployment / Installation"
        InstallSh["install.sh"]:::config
        InstallLocal["install-local.sh"]:::config
        Uninstall["uninstall.sh"]:::config
        SetupComp["setup-completion.sh"]:::config
        Formula["Formula/eaws.rb"]:::config
        ReleaseWF[".github/workflows/release.yml"]:::config
        UpdateWF[".github/workflows/update-homebrew-formula.yml"]:::config
    end

    %% Legend
    subgraph "Legend"
        LF["CLI Frontend"]:::frontend
        LL["Application Logic"]:::logic
        LE["External Libraries"]:::external
        LA["AWS Services"]:::aws
        LC["Config & Installation"]:::config
    end

    %% Connections
    UT --> Main --> Root
    Root --> Container
    Root --> ContainerConnect
    Root --> ContainerList
    Root --> Logs
    Root --> LogsQuery
    Root --> LogsView
    Root --> Pipeline

    Container --> AWSWr
    ContainerConnect --> AWSWr
    ContainerList --> AWSWr
    Logs --> AWSWr
    LogsQuery --> AWSWr
    LogsView --> AWSWr
    Pipeline --> AWSWr

    AWSWr --> AWS_SDK
    AWSHelp --> AWS_SDK
    Colors --> ColorLib

    AWS_SDK --> ECS
    AWS_SDK --> LogsSvc
    AWS_SDK --> PipelineSvc

    Root --> Creds
    Root --> EnvVars

    UT -.-> SetupComp
    UT -.-> InstallSh
    UT -.-> InstallLocal
    UT -.-> Uninstall
    InstallSh --> Formula
    ReleaseWF --> Formula
    UpdateWF --> Formula

    %% Click Events
    click Main "https://github.com/manudiv16/eaws/blob/main/main.go"
    click Root "https://github.com/manudiv16/eaws/blob/main/cmd/root.go"
    click Container "https://github.com/manudiv16/eaws/blob/main/cmd/container.go"
    click ContainerConnect "https://github.com/manudiv16/eaws/blob/main/cmd/container_connect.go"
    click ContainerList "https://github.com/manudiv16/eaws/blob/main/cmd/container_list.go"
    click Logs "https://github.com/manudiv16/eaws/blob/main/cmd/logs.go"
    click LogsQuery "https://github.com/manudiv16/eaws/blob/main/cmd/logs_query.go"
    click LogsView "https://github.com/manudiv16/eaws/blob/main/cmd/logs_view.go"
    click Pipeline "https://github.com/manudiv16/eaws/blob/main/cmd/pipeline.go"
    click AWSWr "https://github.com/manudiv16/eaws/blob/main/internal/utils/aws.go"
    click AWSHelp "https://github.com/manudiv16/eaws/blob/main/internal/utils/aws_help.go"
    click Colors "https://github.com/manudiv16/eaws/blob/main/internal/utils/colors.go"
    click InstallSh "https://github.com/manudiv16/eaws/blob/main/install.sh"
    click InstallLocal "https://github.com/manudiv16/eaws/blob/main/install-local.sh"
    click Uninstall "https://github.com/manudiv16/eaws/blob/main/uninstall.sh"
    click SetupComp "https://github.com/manudiv16/eaws/blob/main/setup-completion.sh"
    click Formula "https://github.com/manudiv16/eaws/blob/main/Formula/eaws.rb"
    click ReleaseWF "https://github.com/manudiv16/eaws/blob/main/.github/workflows/release.yml"
    click UpdateWF "https://github.com/manudiv16/eaws/blob/main/.github/workflows/update-homebrew-formula.yml"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#2b6cb0,color:#000;
    classDef logic fill:#d4edda,stroke:#238636,color:#000;
    classDef external fill:#ffe5b4,stroke:#d97706,color:#000;
    classDef aws fill:#e9d8fd,stroke:#7b2cbf,color:#000;
    classDef config fill:#e2e8f0,stroke:#475569,color:#000;
```
