# un0tec/awssopilot architecture

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

- Interactive diagram: https://gitdiagram.com/un0tec/awssopilot
- Repository: https://github.com/un0tec/awssopilot

## Overview

##### Project type and purpose
- This project is a command-line tool written in JavaScript (Node.js) that automates AWS SSO logins across multiple profiles. Its core functionality revolves around authenticating users using various methods (email/password, phone call, or app-based verification) and then invoking an external tool (yawsso) to set up the corresponding IAM credentials.

##### File structure
- The project has a minimal structure with only a few top-level files:
- awssopilot.js – Likely the entry point handling the command-line interactions and login automation.
- update-notifier.js – A helper module to notify users about updates.
- package.json and package-lock.json – Manage dependencies and project metadata.
- LICENSE and README.md – Documentation and licensing.
- There’s no folder separation (like “src” or “lib”), so the project is lightweight and single-module oriented.

##### Break down the main components
a. Command-Line Interface (CLI): This is the entry point (awssopilot.js) that handles parsing of command-line arguments and options such as profile names, update check, help, and version.
b. Configuration Loader: A module (within awssopilot.js or a helper function) that reads the user’s configuration file (awssopilot.config) from the appropriate OS-specific location.
c. Authentication Handler: The core logic that initiates the AWS SSO login process and supports different login methods (app-based or phone call).
d. AWS SSO Connector: A representation of the network interaction with AWS SSO endpoints (for example, loading the URL for login verification and code approval).
e. Credentials Integration: The component that triggers yawsso integration after a successful SSO login, setting up the corresponding IAM credentials.
f. Update Notifier: A side module (update-notifier.js) that checks and notifies users of available updates when the tool is executed.

##### Relationships and interactions between components
- The CLI component accepts input (profile names, options) and then invokes the Configuration Loader to read the user’s credentials and profile details.
- Once loaded, the Authentication Handler uses the provided details to interact with the AWS SSO Connector, which performs network calls for obtaining user codes and handling login approval.
- After successful authentication, the Credentials Integration component is triggered to execute yawsso, configuring IAM credentials for the authenticated profile.
- Independently, the Update Notifier checks if there is a new release available and notifies the user if needed.

##### Architectural patterns and design principles
- The tool follows a modular design even though it is contained in a few files. Each distinct functionality (e.g., configuration loading, authentication, network interaction, and update notification) should have a well-defined role.
- Depicting a pipeline where each module passes along data to the next, emphasizing separation of concerns.

##### Including relevant technologies
- Technologies and libraries include Node.js (runtime), npm for package management, and external AWS SSO endpoints for authentication.
- The integration with yawsso should be highlighted as an external dependency or service that further processes the credentials.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "AWS SSO Login Flow"
        ConfigLoader["Configuration Loader"]:::core
        AuthHandler["Authentication Handler"]:::core
        SSOConnector["AWS SSO Connector"]:::core
        Credentials["Credentials Integration (yawsso call)"]:::core
    end

    CLI["Command-Line Interface (CLI)"]:::cli
    UpdateNotifier["Update Notifier"]:::util

    CLI -->|"loads"| ConfigLoader
    ConfigLoader -->|"initiates"| AuthHandler
    AuthHandler -->|"calls"| SSOConnector
    SSOConnector -->|"integrates"| Credentials
    CLI -->|"checks"| UpdateNotifier

    click CLI "https://github.com/un0tec/awssopilot/blob/main/awssopilot.js"
    click ConfigLoader "https://github.com/un0tec/awssopilot/blob/main/awssopilot.js"
    click AuthHandler "https://github.com/un0tec/awssopilot/blob/main/awssopilot.js"
    click SSOConnector "https://github.com/un0tec/awssopilot/blob/main/awssopilot.js"
    click Credentials "https://github.com/un0tec/awssopilot/blob/main/awssopilot.js"
    click UpdateNotifier "https://github.com/un0tec/awssopilot/blob/main/update-notifier.js"

    classDef cli fill:#f6d186,stroke:#333,stroke-width:2px;
    classDef core fill:#abe2fb,stroke:#333,stroke-width:2px;
    classDef util fill:#d0e9a0,stroke:#333,stroke-width:2px;
```
