# bgizdov/gcp-api-key-auditor architecture

> Architecture diagram of the GitHub repository bgizdov/gcp-api-key-auditor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bgizdov/gcp-api-key-auditor
- Repository: https://github.com/bgizdov/gcp-api-key-auditor

## Overview

##### Project type and purpose
- This is an open-source command-line tool written in Python.
- Purpose: audit and validate a Google Cloud Platform API key by programmatically invoking dozens of GCP service endpoints, collecting response statuses, and producing human-readable and machine-readable reports.

##### File structure
- Top level:
- gcp_api_key_auditor.py – core script containing CLI entry point, orchestration logic
- example_usage.py – example of how to invoke the auditor in code
- pyproject.toml – project metadata, dependencies, console script entry
- README.md – documentation
- .gitignore
- No subdirectories: code is organized in a single module.
- CLI installation handled via pyproject.toml, specifying console_scripts for `gcp-api-key-auditor`.

##### README for additional insights
- Two modes: Quick Verification (calls a small set of APIs) and Comprehensive Verification (82+ services across 16 categories).
- Supports multiple input methods: direct key arg, environment variable, file.
- Output: styled console output (indicators ✅, ⚠️, ❌), JSON output, verbose mode.
- Features: rate-limiting logic, retry, project discovery, progress tracking.

##### Detail
- Major subcomponent: Service Registry, Rate Limiter, Retry Logic, Project Discovery.
- Don’t over-abstract: show individual layers/modules to convey where to add new tests, how errors propagate, and where presentation formatting occurs.

## Diagram (Mermaid)

```mermaid
flowchart TD
  subgraph "CLI Layer"
    CLI["CLI Interface / Argument Parser"]:::internal
    ScriptEntry["Console Script Entry"]:::config
    Documentation["Project Documentation"]:::doc
  end

  subgraph "Input Layer"
    InputHandler["Input Handler\n(API key from CLI/env/file)"]:::internal
  end

  subgraph "Core Layer"
    AuditorCore["Auditor Core"]:::internal
    ServiceRegistry["Service Registry\n(list of API tests by category)"]:::internal
    TestExecutor["Test Executor\n(rate-limiting & retries)"]:::internal
    ProjectDiscovery["Project Discovery Submodule"]:::internal
  end

  subgraph "Aggregation & Output Layer"
    ResultsAggregator["Results Aggregator\n(collects statuses & metadata)"]:::internal
    OutputFormatter["Output Formatter"]:::internal
    ConsoleRenderer["Console Renderer\n(emoji/status tables, progress bars)"]:::internal
    JSONSerializer["JSON Serializer"]:::internal
  end

  ExternalGCP[(GCP REST APIs)]:::external
  ExampleUsage["Example Usage Harness"]:::example

  %% Connections
  ScriptEntry --> CLI
  Documentation --- CLI
  CLI -->|"parses args"| InputHandler
  InputHandler -->|"provides API key"| AuditorCore
  ExampleUsage -->|"invokes"| AuditorCore

  AuditorCore --> ServiceRegistry
  AuditorCore --> ProjectDiscovery
  ServiceRegistry --> TestExecutor
  ProjectDiscovery --> ExternalGCP
  TestExecutor --> ExternalGCP
  ExternalGCP --> ResultsAggregator
  ProjectDiscovery --> ResultsAggregator
  ResultsAggregator --> OutputFormatter
  OutputFormatter --> ConsoleRenderer
  OutputFormatter --> JSONSerializer

  %% Click Events
  click CLI "https://github.com/bgizdov/gcp-api-key-auditor/blob/main/gcp_api_key_auditor.py"
  click InputHandler "https://github.com/bgizdov/gcp-api-key-auditor/blob/main/gcp_api_key_auditor.py"
  click AuditorCore "https://github.com/bgizdov/gcp-api-key-auditor/blob/main/gcp_api_key_auditor.py"
  click ServiceRegistry "https://github.com/bgizdov/gcp-api-key-auditor/blob/main/gcp_api_key_auditor.py"
  click TestExecutor "https://github.com/bgizdov/gcp-api-key-auditor/blob/main/gcp_api_key_auditor.py"
  click ProjectDiscovery "https://github.com/bgizdov/gcp-api-key-auditor/blob/main/gcp_api_key_auditor.py"
  click ResultsAggregator "https://github.com/bgizdov/gcp-api-key-auditor/blob/main/gcp_api_key_auditor.py"
  click OutputFormatter "https://github.com/bgizdov/gcp-api-key-auditor/blob/main/gcp_api_key_auditor.py"
  click ConsoleRenderer "https://github.com/bgizdov/gcp-api-key-auditor/blob/main/gcp_api_key_auditor.py"
  click JSONSerializer "https://github.com/bgizdov/gcp-api-key-auditor/blob/main/gcp_api_key_auditor.py"
  click ExampleUsage "https://github.com/bgizdov/gcp-api-key-auditor/blob/main/example_usage.py"
  click ScriptEntry "https://github.com/bgizdov/gcp-api-key-auditor/blob/main/pyproject.toml"
  click Documentation "https://github.com/bgizdov/gcp-api-key-auditor/blob/main/README.md"

  %% Styles
  classDef internal fill:#D6EAF8,stroke:#1F618D,stroke-width:1px
  classDef external fill:#FADBD8,stroke:#C0392B,stroke-width:1px
  classDef example fill:#E8DAEF,stroke:#6C3483,stroke-width:1px
  classDef config fill:#D5F5E3,stroke:#27AE60,stroke-width:1px
  classDef doc fill:#FCF3CF,stroke:#B7950B,stroke-width:1px
```
