# one2nc/cloudlens architecture

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

- Interactive diagram: https://gitdiagram.com/one2nc/cloudlens
- Repository: https://github.com/one2nc/cloudlens

## Overview

##### Main Components Identification

The system can be broken down into these major components:

a) Core Application Layer:
- Command Interface (cmd/)
- User Interface (internal/ui/)
- View Management (internal/view/)
- Model Layer (internal/model/)

b) Cloud Provider Interfaces:
- AWS Integration (internal/aws/)
- GCP Integration (internal/gcp/)

c) Data Access Layer:
- DAO Layer (internal/dao/)
- Rendering Layer (internal/render/)

**┌─────────────────────────────────────────────────────┐**
- User Interface                      │
- (Terminal-based UI with k9s-like navigation)        │
- ┤
- View Layer                         │
- (Resource-specific views: EC2, S3, VM, Storage)     │
- ┤
- Model Layer                        │
- (Data models and business logic)                    │
- ┬──────────────────────────────────┤
- AWS Interface  │         GCP Interface            │

- ┴──────────────────────────────────┤
- DAO Layer                          │
- (Data Access Objects for cloud resources)           │
- ┤
- Cloud Provider SDKs                    │
- (AWS SDK, GCP SDK, LocalStack)             │
- ┘

##### Key Relationships to Highlight

a) Command Flow:
- User input → UI Layer → View Layer → Cloud Interface → DAO → Cloud Provider
- Response data flows in reverse

b) Resource Management:
- How different resource types (EC2, S3, VM, Storage) are handled through the layers

##### Implementation Details

- Supported cloud services:
- AWS: EC2, S3, EBS, VPC, SQS, Lambda, IAM
- GCP: VM, Storage, Disks, Snapshots, Images

- Terminal UI components:
- Navigation system
- Resource viewers
- Command interface

##### External Dependencies

- Integration points with:
- AWS SDK
- GCP SDK
- LocalStack (for development)

Remember to emphasize the read-only nature of the tool and its security considerations regarding credential handling, as mentioned in the README's note section.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph CLI
        CMD["Command Interface"]
        RootCmd["Root Command"]
        AWSCmd["AWS Commands"]
        GCPCmd["GCP Commands"]
        UpdateCmd["Update Command"]
    end

    subgraph UI
        AppUI["Main App UI"]:::ui
        ErrorUI["Error Handler"]:::ui
        TableUI["Table Interface"]:::ui
        MenuUI["Menu System"]:::ui
    end

    subgraph Views
        MainView["Main View"]:::view
        BrowserView["Browser View"]:::view
        LiveView["Live View"]:::view
    end

    subgraph Models
        DataModels["Data Models"]:::model
        CmdBuffer["Command Buffer"]:::model
        Registry["Registry"]:::model
    end

    subgraph "AWS Integration"
        EC2Service["EC2 Service"]:::aws
        S3Service["S3 Service"]:::aws
        LambdaService["Lambda Service"]:::aws
        IAMService["IAM Service"]:::aws
    end

    subgraph "GCP Integration"
        VMService["VM Service"]:::gcp
        StorageService["Storage Service"]:::gcp
        DiskService["Disk Service"]:::gcp
    end

    subgraph "Data Access"
        EC2DAO["EC2 DAO"]:::dao
        S3DAO["S3 DAO"]:::dao
        VMDAO["VM DAO"]:::dao
        StorageDAO["Storage DAO"]:::dao
    end

    subgraph Rendering
        EC2Renderer["EC2 Renderer"]:::render
        S3Renderer["S3 Renderer"]:::render
        VMRenderer["VM Renderer"]:::render
        StorageRenderer["Storage Renderer"]:::render
    end

    subgraph Config
        CloudConfig["Cloud Config"]:::config
        MainConfig["Main Config"]:::config
        StylesConfig["Styles Config"]:::config
    end

    ColorFormat["Color Formatter"]:::util

    %% Relationships
    CMD --> RootCmd
    CMD --> AWSCmd
    CMD --> GCPCmd
    CMD --> UpdateCmd

    RootCmd --> AppUI
    AppUI --> MainView
    MainView --> BrowserView
    MainView --> LiveView

    BrowserView --> DataModels
    LiveView --> DataModels
    DataModels --> Registry
    DataModels --> CmdBuffer

    Registry --> EC2Service
    Registry --> S3Service
    Registry --> VMService
    Registry --> StorageService

    EC2Service --> EC2DAO
    S3Service --> S3DAO
    VMService --> VMDAO
    StorageService --> StorageDAO

    EC2DAO --> EC2Renderer
    S3DAO --> S3Renderer
    VMDAO --> VMRenderer
    StorageDAO --> StorageRenderer

    AppUI --> ErrorUI
    AppUI --> TableUI
    AppUI --> MenuUI

    AppUI --> CloudConfig
    AppUI --> MainConfig
    AppUI --> StylesConfig

    TableUI --> ColorFormat
    MenuUI --> ColorFormat

    %% Click Events
    click CMD "https://github.com/one2nc/cloudlens/tree/main/cmd/"
    click RootCmd "https://github.com/one2nc/cloudlens/blob/main/cmd/root.go"
    click AWSCmd "https://github.com/one2nc/cloudlens/blob/main/cmd/aws.go"
    click GCPCmd "https://github.com/one2nc/cloudlens/blob/main/cmd/gcp.go"
    click UpdateCmd "https://github.com/one2nc/cloudlens/blob/main/cmd/update.go"
    click AppUI "https://github.com/one2nc/cloudlens/blob/main/internal/ui/app.go"
    click ErrorUI "https://github.com/one2nc/cloudlens/blob/main/internal/ui/dialog/error.go"
    click TableUI "https://github.com/one2nc/cloudlens/blob/main/internal/ui/table.go"
    click MenuUI "https://github.com/one2nc/cloudlens/blob/main/internal/ui/menu.go"
    click MainView "https://github.com/one2nc/cloudlens/blob/main/internal/view/app.go"
    click BrowserView "https://github.com/one2nc/cloudlens/blob/main/internal/view/browser.go"
    click LiveView "https://github.com/one2nc/cloudlens/blob/main/internal/view/live_view.go"
    click DataModels "https://github.com/one2nc/cloudlens/blob/main/internal/model/types.go"
    click CmdBuffer "https://github.com/one2nc/cloudlens/blob/main/internal/model/cmd_buff.go"
    click Registry "https://github.com/one2nc/cloudlens/blob/main/internal/model/registry.go"
    click EC2Service "https://github.com/one2nc/cloudlens/blob/main/internal/aws/ec2.go"
    click S3Service "https://github.com/one2nc/cloudlens/blob/main/internal/aws/s3.go"
    click LambdaService "https://github.com/one2nc/cloudlens/blob/main/internal/aws/lambda.go"
    click IAMService "https://github.com/one2nc/cloudlens/blob/main/internal/aws/iam.go"
    click VMService "https://github.com/one2nc/cloudlens/blob/main/internal/gcp/vm.go"
    click StorageService "https://github.com/one2nc/cloudlens/blob/main/internal/gcp/storage.go"
    click DiskService "https://github.com/one2nc/cloudlens/blob/main/internal/gcp/disks.go"
    click EC2DAO "https://github.com/one2nc/cloudlens/blob/main/internal/dao/ec2.go"
    click S3DAO "https://github.com/one2nc/cloudlens/blob/main/internal/dao/s3.go"
    click VMDAO "https://github.com/one2nc/cloudlens/blob/main/internal/dao/vm.go"
    click StorageDAO "https://github.com/one2nc/cloudlens/blob/main/internal/dao/storage.go"
    click EC2Renderer "https://github.com/one2nc/cloudlens/blob/main/internal/render/ec2.go"
    click S3Renderer "https://github.com/one2nc/cloudlens/blob/main/internal/render/s3.go"
    click VMRenderer "https://github.com/one2nc/cloudlens/blob/main/internal/render/vm.go"
    click StorageRenderer "https://github.com/one2nc/cloudlens/blob/main/internal/render/storage.go"
    click CloudConfig "https://github.com/one2nc/cloudlens/blob/main/internal/config/cloud_config.go"
    click MainConfig "https://github.com/one2nc/cloudlens/blob/main/internal/config/config.go"
    click StylesConfig "https://github.com/one2nc/cloudlens/blob/main/internal/config/styles.go"
    click ColorFormat "https://github.com/one2nc/cloudlens/blob/main/internal/color/color.go"

    %% Styles
    classDef ui fill:#3498db
    classDef view fill:#2ecc71
    classDef model fill:#f1c40f
    classDef aws fill:#e74c3c
    classDef gcp fill:#9b59b6
    classDef dao fill:#1abc9c
    classDef render fill:#34495e
    classDef config fill:#95a5a6
    classDef util fill:#7f8c8d
```
