# jaebradley/github-personal-access-token-generator-cli architecture

> Architecture diagram of the GitHub repository jaebradley/github-personal-access-token-generator-cli, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jaebradley/github-personal-access-token-generator-cli
- Repository: https://github.com/jaebradley/github-personal-access-token-generator-cli

## Overview

##### Project type and purpose
- This is an open-source Node.js command-line utility (“github-personal-access-token-generator-cli”) whose sole purpose is to walk a user through creating a GitHub personal access token without leaving the terminal.

##### File structure
- Top level: various config files (.babelrc, ESLint, Travis CI), package.json
- __mocks__ directory: mock implementation of @octokit/rest for testing
- src/
- executables/ghpat.js — the CLI entry point (hooked in package.json “bin”)
- prompters/ — modules to prompt for credentials, scopes, reason, 2FA
- createPersonalAccessToken.js — orchestrates the API call
- tokenGenerator.js — logic to assemble request parameters
- usernameValidator.js + test — validates GitHub usernames
- scopes.js — list of available GitHub scopes

##### README
- Confirms usage (“ghpat”), lists required inputs, says the token will be copied to the clipboard

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Invocation
    User["User"]:::external
    User -->|"invokes ghpat"| CLI

    %% CLI Launcher
    CLI["CLI Launcher (ghpat)"]:::frontend
    click CLI "https://github.com/jaebradley/github-personal-access-token-generator-cli/blob/master/src/executables/ghpat.js"

    %% Prompters Subgraph
    subgraph "Prompters"
        BasicAuth["BasicAuthentication Prompter"]:::frontend
        click BasicAuth "https://github.com/jaebradley/github-personal-access-token-generator-cli/blob/master/src/prompters/basicAuthentication.js"
        Permissions["Permissions/Scopes Prompter"]:::frontend
        click Permissions "https://github.com/jaebradley/github-personal-access-token-generator-cli/blob/master/src/prompters/basicPermissions.js"
        Reason["Reason Prompt Module"]:::frontend
        click Reason "https://github.com/jaebradley/github-personal-access-token-generator-cli/blob/master/src/prompters/reason.js"
        TwoFactor["TwoFactorAuthenticationCode Prompter"]:::frontend
        click TwoFactor "https://github.com/jaebradley/github-personal-access-token-generator-cli/blob/master/src/prompters/twoFactorAuthenticationCode.js"
    end

    %% Core Logic
    Validator["Username Validator"]:::core
    click Validator "https://github.com/jaebradley/github-personal-access-token-generator-cli/blob/master/src/usernameValidator.js"
    TokenGen["Token Generator"]:::core
    click TokenGen "https://github.com/jaebradley/github-personal-access-token-generator-cli/blob/master/src/tokenGenerator.js"
    Scopes["Scopes Definition"]:::core
    click Scopes "https://github.com/jaebradley/github-personal-access-token-generator-cli/blob/master/src/scopes.js"
    APIClient["GitHub API Client"]:::core
    click APIClient "https://github.com/jaebradley/github-personal-access-token-generator-cli/blob/master/src/createPersonalAccessToken.js"

    %% External Services
    Clipboard["Clipboard Integration"]:::external
    Console["Console Output"]:::external

    %% Test Layer
    subgraph "Testing Layer"
        Mocks["@octokit/rest Mock"]:::test
        click Mocks "https://github.com/jaebradley/github-personal-access-token-generator-cli/blob/master/__mocks__/@octokit/rest.js"
        UsernameTest["UsernameValidator Test"]:::test
        click UsernameTest "https://github.com/jaebradley/github-personal-access-token-generator-cli/blob/master/src/usernameValidator.test.js"
    end

    %% Data Flow
    CLI --> BasicAuth
    BasicAuth --> Permissions
    Permissions --> Reason
    Reason --> TwoFactor
    TwoFactor --> Validator
    Validator --> TokenGen
    TokenGen --> Scopes
    TokenGen --> APIClient
    APIClient --> Clipboard
    Clipboard --> Console
    APIClient -->|error or success| Console

    %% Test Interactions
    Mocks --- APIClient
    UsernameTest --- Validator

    %% Styles
    classDef frontend fill:#c2f0c2,stroke:#2a5934,color:#000
    classDef core fill:#c2d9f7,stroke:#10347b,color:#000
    classDef external fill:#fce5cd,stroke:#b35f00,color:#000
    classDef test fill:#d9d9d9,stroke:#7a7a7a,color:#000
```
