# yaggytter/chrome-extension-awssso architecture

> Architecture diagram of the GitHub repository yaggytter/chrome-extension-awssso, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yaggytter/chrome-extension-awssso
- Repository: https://github.com/yaggytter/chrome-extension-awssso

## Overview

##### Project Type and Purpose
- This is a Chrome Browser Extension whose sole purpose is to enhance the AWS IAM Identity Center (formerly AWS SSO) web console.
- Key functions:
- Inject account name & permission set into the AWS console header
- Allow users to mark favorite accounts and bubble them to the top of the SSO login page

##### File Structure Analysis
- manifest.json: declares permissions (tabs, storage, content_scripts), background and options pages
- background.js: event‐driven background script (message router / storage manager)
- content.js: content script injected into AWS console pages to:
- read account info from the DOM
- apply header modifications (text + CSS)
- reorder favorite accounts on the login page
- _locales/*/messages.json: internationalization support for options page & extension UI
- makezip.sh: packaging script for release

- Main Components:
a. Chrome Browser (host environment)
b. Extension Background Script (background.js)
c. Extension Content Script (content.js)
d. Extension Options UI (options.html/options.js)
e. Chrome Storage (chrome.storage.local / sync)
f. AWS SSO Web Console (external website)

- Interactions & Data Flows:
1. User installs extension → manifest loads background script & registers content injection rules
2. User navigates to AWS SSO console → browser injects content.js into matching pages
3. content.js scrapes account name & permission set from AWS DOM
5. background.js retrieves settings from chrome.storage and returns them to content.js
7. On the SSO login page, content.js reorders DOM elements based on “favorite accounts” list
8. User opens Options Page → options.js loads current settings from background.js (or directly from chrome.storage)

- Architectural Patterns & Principles:
- Message‐passing between content and background scripts (separation of concerns)
- Persistent storage of user configuration in chrome.storage
- DOM‐injection only on AWS console domains (minimal permissions principle)
- i18n using Chrome’s _locales system

## Diagram (Mermaid)

```mermaid
graph TB
    %% Subgraph for Extension
    subgraph "Chrome Browser Extension"
        direction TB
        MANIFEST["manifest.json"]:::config
        BACKGROUND["Background Script"]:::runtime
        CONTENT["Content Script"]:::runtime
        subgraph "Options UI"
            direction TB
            OPT_HTML["Options HTML (options.html)"]:::ui
            OPT_JS["Options JS (options.js)"]:::ui
        end
        CHROMESTORAGE["chrome.storage"]:::storage
        subgraph "i18n Locales"
            direction TB
            M_EN["_locales/en/messages.json"]:::storage
            M_JA["_locales/ja/messages.json"]:::storage
        end
        subgraph "Assets"
            direction TB
            ICONS["icons/"]:::artifact
            SCREENSHOTS["screenshots/"]:::artifact
            MAKEZIP["makezip.sh"]:::artifact
        end

        %% Registration flows
        MANIFEST --> BACKGROUND
        MANIFEST --> CONTENT
        MANIFEST --> OPT_HTML
        MANIFEST --> OPT_JS

        %% Options page flows
        OPT_HTML --> OPT_JS
        OPT_JS -->|"chrome.runtime.sendMessage(read/write settings)"| BACKGROUND
        OPT_JS -->|"chrome.storage.get/set"| CHROMESTORAGE
        BACKGROUND -->|"chrome.storage.get/set"| CHROMESTORAGE

        %% Content script flows
        CONTENT -->|"chrome.runtime.sendMessage(getSettings)"| BACKGROUND
        BACKGROUND -->|"settings data"| CONTENT
        CONTENT -->|"scrape account info / apply CSS & reorder DOM"| AWS

    end

    %% External and User
    USER["User"]:::actor
    AWS["AWS SSO Console"]:::external

    %% User interactions
    USER -->|"installs extension"| MANIFEST
    USER -->|"navigates to SSO console"| AWS
    AWS -->|"injects content.js"| CONTENT
    USER -->|"opens options page"| OPT_HTML

    %% Click events
    click BACKGROUND "https://github.com/yaggytter/chrome-extension-awssso/blob/main/background.js"
    click CONTENT "https://github.com/yaggytter/chrome-extension-awssso/blob/main/content.js"
    click OPT_HTML "https://github.com/yaggytter/chrome-extension-awssso/blob/main/options.html"
    click OPT_JS "https://github.com/yaggytter/chrome-extension-awssso/blob/main/options.js"
    click MANIFEST "https://github.com/yaggytter/chrome-extension-awssso/blob/main/manifest.json"
    click M_EN "https://github.com/yaggytter/chrome-extension-awssso/blob/main/_locales/en/messages.json"
    click M_JA "https://github.com/yaggytter/chrome-extension-awssso/blob/main/_locales/ja/messages.json"
    click ICONS "https://github.com/yaggytter/chrome-extension-awssso/tree/main/icons/"
    click SCREENSHOTS "https://github.com/yaggytter/chrome-extension-awssso/tree/main/screenshots"
    click MAKEZIP "https://github.com/yaggytter/chrome-extension-awssso/blob/main/makezip.sh"

    %% Styles
    classDef runtime fill:#cce5ff,stroke:#3399ff,stroke-width:1px
    classDef storage fill:#d4edda,stroke:#28a745,stroke-width:1px
    classDef ui fill:#fff3cd,stroke:#ffcd39,stroke-width:1px
    classDef external fill:#e2e3e5,stroke:#6c757d,stroke-width:1px
    classDef config fill:#f0f0f0,stroke:#888888,stroke-width:1px
    classDef artifact fill:#f8f9fa,stroke:#adb5bd,stroke-width:1px
    classDef actor fill:#ffffff,stroke:#000000,stroke-width:1px,stroke-dasharray: 5 5
```
