# aksarav/kubenodeusage architecture

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

- Interactive diagram: https://gitdiagram.com/aksarav/kubenodeusage
- Repository: https://github.com/aksarav/kubenodeusage

## Overview

##### Main Components

a. Core Components:
- Kubernetes Cluster (External System)
- KubeNodeUsage CLI Application
- Kubernetes API Server (External System)
- Metrics Server (External System)
- Local Kubeconfig (.kube/config)

b. Internal Components:
- Metrics Collector
- Data Processor
- Filter Engine
- Output Renderer
- Configuration Manager

##### Component Relationships and Data Flow

**[Kubeconfig] -> [KubeNodeUsage CLI]**
**[KubeNodeUsage CLI] -> [Kubernetes API Server]**
**[Metrics Server] -> [Kubernetes API Server]**

##### Architectural Pattern
The project follows a CLI application pattern with clear separation of concerns, as evidenced by the directory structure:
- `k8s/` - Kubernetes interaction logic
- `utils/` - Common utilities and helpers
- `assets/` - Static resources

- User Interface    |
- (CLI Interface)    |

- ↓

- Application Core    |
- Metrics Collection   |
- Data Processing     |
- Filtering Logic     |
- Output Formatting   |

- ↓

- External Integration  |
- Kubernetes API      |
- Metrics Server      |

##### Implementation Details

- Authentication flow using .kube/config
- Metrics collection pipeline
- Sort functionality

##### Technical Elements

Key technical aspects:
- Go SDK client-go integration
- Kubernetes API communication
- Metrics processing pipeline
- Filter chain implementation
- Output formatting system

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Interface Layer"
        CLI["KubeNodeUsage CLI"]:::cli
    end

    subgraph "Application Core"
        MC["Metrics Collector"]:::core
        DP["Data Processor"]:::core
        FE["Filter Engine"]:::core
        OR["Output Renderer"]:::core
        CM["Configuration Manager"]:::core
        VE["Validation Engine"]:::core
        LS["Logging System"]:::core
    end

    subgraph "External Systems"
        KC["Kubernetes Cluster"]:::external
        KA["Kubernetes API Server"]:::external
        MS["Metrics Server"]:::external
        KC_CONFIG[".kube/config"]:::config
    end

    %% Relationships
    CLI --> CM
    CLI --> MC
    MC --> KA
    MS --> KA
    KA --> KC
    KC_CONFIG --> CLI
    
    MC --> DP
    DP --> FE
    FE --> OR
    
    CM --> VE
    CM --> LS
    
    %% Styling
    classDef cli fill:#2196F3,stroke:#1565C0,color:white
    classDef core fill:#4CAF50,stroke:#388E3C,color:white
    classDef external fill:#FFC107,stroke:#FFA000,color:black
    classDef config fill:#9E9E9E,stroke:#616161,color:white

    %% Click events
    click CLI "https://github.com/AKSarav/KubeNodeUsage/blob/main/main.go"
    click MC "https://github.com/AKSarav/KubeNodeUsage/blob/main/k8s/nodes.go"
    click DP "https://github.com/AKSarav/KubeNodeUsage/blob/main/k8s/nodes.go"
    click CM "https://github.com/AKSarav/KubeNodeUsage/blob/main/utils/base.go"
    click VE "https://github.com/AKSarav/KubeNodeUsage/blob/main/utils/validations.go"
    click LS "https://github.com/AKSarav/KubeNodeUsage/blob/main/utils/logger.go"

    %% Legend
    subgraph Legend
        L1["CLI Component"]:::cli
        L2["Core Component"]:::core
        L3["External System"]:::external
        L4["Configuration"]:::config
    end
```
