# hic-infra/hic-aws-costing-tools architecture

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

- Interactive diagram: https://gitdiagram.com/hic-infra/hic-aws-costing-tools
- Repository: https://github.com/hic-infra/hic-aws-costing-tools

## Overview

##### Main Components

a) Input Layer:
- AWS Cost Explorer API Interface
- Command-Line Interface (CLI)
- Configuration Handlers (for AWS credentials and roles)

b) Core Processing Layer:
- Cost Data Processor
- Dimension/Tag Handler
- Data Aggregation Engine

c) Output Layer:
- Report Formatters (CSV, Markdown, Flat format)
- Data Export Handlers

##### Component Relationships

**[AWS Cost Explorer API] → [Authentication Handler (IAM/Role)] → [Cost Data Processor]**
- ↓
**[CLI Input] → [Configuration Parser] → [Dimension/Tag Handler] → [Data Aggregation Engine]**
- ↓
- [Report Formatters] → [Output]

##### Key Technical Elements to Highlight

- Rectangles: Core processing components
- Hexagons: Input/Output interfaces
- Rounded rectangles: Processing modules

- Blue: AWS services and interactions
- Green: Data processing components
- Orange: Input/Output components
- Gray: Configuration and utility components

##### Important Details

a) Data Flow Annotations:
- Cost data flow
- Configuration parameters
- Authentication flow

b) Key Features:
- Dimension grouping (Account, Service, Tags)
- Granularity options (daily/monthly)
- Output format options (CSV, markdown, flat)

##### Architecture Patterns to Emphasize

- Command Pattern: For CLI operations
- Strategy Pattern: For different output formats
- Adapter Pattern: For AWS API interaction

##### Implementation Details

Relationship between:
- main.py (CLI entry point)
- aws_costs.py (Core business logic)
- Test fixtures (dummy-proj and dummy-services)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        CE[(AWS Cost Explorer)]
        CLI[Command Line Interface]
        CH[Configuration Handler]
    end

    subgraph Processing
        CDP[Cost Data Processor]
        DTH[Dimension/Tag Handler]
        DAE[Data Aggregation Engine]
        AH[Authentication Handler]
    end

    subgraph Output
        RF[Report Formatters]
        EX[Data Export]
    end

    CE --> AH
    AH --> CDP
    CLI --> CH
    CH --> DTH
    CDP --> DTH
    DTH --> DAE
    DAE --> RF
    RF --> EX

    %% Component Mappings
    click CLI "https://github.com/hic-infra/hic-aws-costing-tools/blob/main/hic_aws_costing_tools/main.py"
    click CDP "https://github.com/hic-infra/hic-aws-costing-tools/blob/main/hic_aws_costing_tools/aws_costs.py"
    click CH "https://github.com/hic-infra/hic-aws-costing-tools/blob/main/pyproject.toml"
    click DTH "https://github.com/hic-infra/hic-aws-costing-tools/blob/main/tests/dummy-proj/get_dimension_values-LINKED_ACCOUNT.json"
    click RF "https://github.com/hic-infra/hic-aws-costing-tools/blob/main/tests/dummy-proj/test-costs_to_table.json"

    %% Styling
    classDef aws fill:#2674B2,stroke:#fff,stroke-width:2px,color:#fff
    classDef process fill:#90EE90,stroke:#333,stroke-width:1px
    classDef io fill:#FFA500,stroke:#333,stroke-width:1px
    classDef config fill:#D3D3D3,stroke:#333,stroke-width:1px

    class CE aws
    class CDP,DTH,DAE process
    class CLI,EX io
    class CH,AH config

    %% Legend
    subgraph Legend
        L1[AWS Services]:::aws
        L2[Processing Components]:::process
        L3[Input/Output]:::io
        L4[Configuration]:::config
    end
```
