# overmindtech/cli architecture

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

- Interactive diagram: https://gitdiagram.com/overmindtech/cli
- Repository: https://github.com/overmindtech/cli

## Overview

##### Project type and purpose
- This is a full-featured, open-source CLI tool (“Overmind CLI”) written in Go.
- Purpose: Provide a chat-assistant and Terraform wrapper that connects to multiple infrastructure “sources” (AWS, Kubernetes, etc.), uncovers dependencies (“blast radius”), surfaces risks, and integrates with the Overmind cloud service via protobuf/Connect APIs.

##### File structure
- Top-level “cmd” and “main.go”: CLI entrypoint implemented with Cobra.
- “auth/”: authentication middleware & NATS auth client.
- “discovery/”: core discovery engine that orchestrates resource adapters over a NATS message bus.
- “aws-source/”, “k8s-source/”, “stdlib-source/”: three separate “source” binaries (micro-services/adapters) that connect to AWS, Kubernetes, and standard data sources.
- “sdp-go/”: shared protobuf definitions, Connect transport stubs, and client libraries used by the CLI to call the Overmind cloud API.
- “sdpcache/”: local in-memory caching layer for discovery data.
- “tfutils/”: Terraform plan parsing & mapping helpers.
- “tracing/”: observability/tracing hooks.
- Config/build files: Dockerfiles, GitHub workflows, Terraform, package.json (for asset builds), goreleaser, etc.

##### Extract insights from the README
- Overmind CLI wraps Terraform commands and provides an interactive “explore” mode that queries real-time infrastructure state.
- Architecture: Local CLI + pluggable sources + messaging (NATS) + remote Overmind API connectivity.

## Diagram (Mermaid)

```mermaid
flowchart TD
    direction TB

    User["User"]:::external
    User --> CLI["CLI (overmind)"]:::local

    subgraph "CLI (overmind)"
        direction TB
        Auth["Auth Module"]:::local
        Commands["Cobra Commands"]:::local
        TF["Terraform Wrapper (tfutils)"]:::local
        SDPClient["Overmind Cloud API Client (sdp-go)"]:::local
        Tracing["Tracing / Observability"]:::local
    end

    CLI --> Auth
    CLI --> Commands
    CLI --> TF
    CLI --> SDPClient
    CLI --> Tracing

    Commands -->|"start discovery"| NATS["NATS Broker"]:::nats
    NATS <--> DiscoveryEngine["Discovery Engine"]:::local
    DiscoveryEngine --> sdpcache["Cache Layer (sdpcache)"]:::cache
    DiscoveryEngine --> NATS

    subgraph "Source Adapters"
        direction TB
        AwsSrc["aws-source Adapter"]:::local
        K8sSrc["k8s-source Adapter"]:::local
        StdSrc["stdlib-source Adapter"]:::local
    end

    NATS --> AwsSrc
    NATS --> K8sSrc
    NATS --> StdSrc
    AwsSrc -->|"snapshots"| NATS
    K8sSrc -->|"snapshots"| NATS
    StdSrc -->|"snapshots"| NATS

    Commands -->|"terraform plan/apply"| TerraformCLI["Terraform CLI"]:::external
    TerraformCLI --> TF
    TF --> DiscoveryEngine
    TF --> SDPClient

    subgraph "Remote Overmind Cloud"
        direction TB
        OvermindAPI["Overmind Cloud API"]:::cloud
    end
    SDPClient --> OvermindAPI

    %% Click Events
    click CLI "https://github.com/overmindtech/cli/blob/main/main.go"
    click Commands "https://github.com/overmindtech/cli/tree/main/cmd/"
    click Auth "https://github.com/overmindtech/cli/tree/main/auth/"
    click DiscoveryEngine "https://github.com/overmindtech/cli/tree/main/discovery/"
    click AwsSrc "https://github.com/overmindtech/cli/tree/main/aws-source/"
    click K8sSrc "https://github.com/overmindtech/cli/tree/main/k8s-source/"
    click StdSrc "https://github.com/overmindtech/cli/tree/main/stdlib-source/"
    click sdpcache "https://github.com/overmindtech/cli/tree/main/sdpcache/"
    click TF "https://github.com/overmindtech/cli/tree/main/tfutils/"
    click SDPClient "https://github.com/overmindtech/cli/tree/main/sdp-go/"
    click Tracing "https://github.com/overmindtech/cli/tree/main/tracing/"

    %% Styles
    classDef local fill:#c8e6c9,stroke:#2e7d32,color:#000;
    classDef cache fill:#bbdefb,stroke:#1976d2,color:#000;
    classDef cloud fill:#ffe0b2,stroke:#ef6c00,color:#000;
    classDef nats fill:#e0e0e0,stroke:#424242,color:#000;
    classDef external fill:#f5f5f5,stroke:#9e9e9e,color:#000;
```
