# aws-samples/aws-auto-inventory architecture

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

- Interactive diagram: https://gitdiagram.com/aws-samples/aws-auto-inventory
- Repository: https://github.com/aws-samples/aws-auto-inventory

## Overview

##### Main Components

a. Core Components:
- Input Handler (Configuration Processing)
- Scan Orchestrator (Main Controller)
- AWS Service Scanner (Worker)
- Output Manager (Results Handler)

b. External Components:
- AWS Services (200+ services)
- AWS Regions
- File System (JSON output)
- AWS Authentication

**Top Layer: User Interface / Input**
**↓**
**Middle Layer: Core Processing**
**↓**
**Bottom Layer: AWS Integration**

##### Key Elements

a. Input Flow:
- Configuration Files (JSON)
- Command Line Arguments
- AWS Credentials

b. Processing Components:
- Parallel Processing Manager (Threading)
- Service Scanner Pool
- Region Scanner Pool
- Retry Handler with Exponential Backoff

c. Output Components:
- JSON File Writer
- Logging System

##### Specific Design Elements

- Rectangles: Core processing components (Blue)
- Clouds: AWS Services (Orange)
- Diamonds: Decision points (Yellow)

##### Component Relationships

**Input Handler → Scan Orchestrator → Service Scanner Pool**
- ↓                     ↓
- Region Manager  ←→    AWS API Clients
- ↓                     ↓
- Retry Handler   →    AWS Services/Regions
- ↓
- Output Manager

##### Technical Details

- Python 3.6+ Runtime
- Boto3 SDK Integration
- Multithreading capabilities
- Error handling mechanisms
- Configuration parameters
- Authentication flow

##### Important Notes

- Concurrent execution model
- Error handling and retry mechanism
- Scalability of regions and services
- Configuration flexibility
- Authentication flow with AWS

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        Config[".devcontainer/config.yaml"]
        CLI["Command Line Interface"]
        Creds["AWS Credentials"]
    end

    subgraph Core
        ScanBuilder["Scan Builder"]
        MainOrch["Main Orchestrator"]
        ServiceDef["Service Definitions"]
        RetryHandler["Retry Handler"]
    end

    subgraph Execution
        ThreadPool["Thread Pool Manager"]
        RegionMgr["Region Manager"]
        ServiceScanner["Service Scanner"]
    end

    subgraph AWS
        APIClient["AWS API Client"]
        Services["AWS Services"]
        Regions["AWS Regions"]
    end

    subgraph Output
        JsonWriter["JSON Writer"]
        Logger["Logging System"]
        Templates["Output Templates"]
    end

    %% Connections
    Config --> ScanBuilder
    CLI --> MainOrch
    Creds --> APIClient
    
    ScanBuilder --> MainOrch
    MainOrch --> ThreadPool
    ServiceDef --> ServiceScanner
    
    ThreadPool --> RegionMgr
    ThreadPool --> ServiceScanner
    
    RegionMgr --> APIClient
    ServiceScanner --> APIClient
    
    APIClient --> Services
    APIClient --> Regions
    
    ServiceScanner --> RetryHandler
    RetryHandler --> APIClient
    
    ServiceScanner --> JsonWriter
    ServiceScanner --> Logger
    JsonWriter --> Templates

    %% Click Events
    click Config "https://github.com/aws-samples/aws-auto-inventory/blob/main/.devcontainer/config.yaml"
    click MainOrch "https://github.com/aws-samples/aws-auto-inventory/blob/main/scan.py"
    click ScanBuilder "https://github.com/aws-samples/aws-auto-inventory/blob/main/scan_builder.py"
    click ServiceDef "https://github.com/aws-samples/aws-auto-inventory/tree/main/scan/sample/services"
    click Templates "https://github.com/aws-samples/aws-auto-inventory/tree/main/scan/sample"

    %% Styling
    classDef core fill:#2374ab
    classDef input fill:#57a773
    classDef aws fill:#ff8c42
    classDef output fill:#41337a
    classDef execution fill:#c49991

    class ScanBuilder,MainOrch,ServiceDef,RetryHandler core
    class Config,CLI,Creds input
    class APIClient,Services,Regions aws
    class JsonWriter,Logger,Templates output
    class ThreadPool,RegionMgr,ServiceScanner execution

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Input Components"]:::input
        L3["AWS Integration"]:::aws
        L4["Output Handling"]:::output
        L5["Execution Control"]:::execution
    end
```
