# markwragg/powershell-currencyconverter architecture

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

- Interactive diagram: https://gitdiagram.com/markwragg/powershell-currencyconverter
- Repository: https://github.com/markwragg/powershell-currencyconverter

## Overview

##### Project type and purpose
- This is an open-source PowerShell module (“CurrencyConverter”) that wraps two external currency-conversion APIs (ExchangeRate-API for fiat currencies, Coinbase for crypto). It exposes a suite of cmdlets (Convert-Currency, Get-ExchangeRate, etc.) and implements local caching to minimize API calls.

##### File structure
- Top-level directories:
- CurrencyConverter/
– Public/ : exported cmdlets
– Private/ : internal helper functions
– CurrencyConverter.psm1 & .psd1 : module entry and manifest
- Build/ : build, test, deployment scripts (Psake, PSDeploy, PSScriptAnalyzer)
- Tests/ : Pester tests organized by cmdlet and common rules
- Documentation/ : markdown docs per cmdlet
- CI configs: .github/workflows, azure-pipelines.yml
- Patterns & concerns:
- Clear separation of Public API vs. Private implementation
- External HTTP dependency encapsulated in Private functions
- Disk-based cache layer for rate results
- Automated build & QA (linting, tests, packaging, publish to PSGallery)

##### README for additional insights
- Cmdlet list & relationships: conversion vs. retrieval vs. formatting
- Caching behavior, optional API key parameter
- Data flow: PowerShell → cmdlet → cache lookup → external API if needed → parse JSON → return PS object/string

##### Details
- Module boundaries: which files define the Public API vs. implementation
- Cache storage location (disk path) and TTL behavior
- Optional branches: “with API key” vs. “without API key” flows
- CI steps: lint → test → package → deploy

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Styles
    classDef host fill:#F5B041,stroke:#D35400;
    classDef publicLayer fill:#D6EAF8,stroke:#3498DB;
    classDef privateLayer fill:#EBF5FB,stroke:#5DADE2;
    classDef cache fill:#ABEBC6,stroke:#27AE60;
    classDef external fill:#FADBD8,stroke:#E74C3C;
    classDef devops fill:#FCF3CF,stroke:#F1C40F;

    %% PowerShell Host
    PSHost["PowerShell Host"]:::host

    %% Module Entry
    subgraph "CurrencyConverter Module"
        direction TB
        Manifest["Module Manifest"]:::publicLayer
        Entry["Module Entry Script"]:::publicLayer

        subgraph "Public Cmdlets"    
            direction TB
            ConvertCurrency["Convert-Currency Cmdlet"]:::publicLayer
            GetExchangeRate["Get-ExchangeRate Cmdlet"]:::publicLayer
            ConvertCrypto["Convert-CryptoCurrency Cmdlet"]:::publicLayer
            GetCryptoRate["Get-CryptoExchangeRate Cmdlet"]:::publicLayer
            GetCrypto["Get-CryptoCurrency Cmdlet"]:::publicLayer
            GetCurrency["Get-Currency Cmdlet"]:::publicLayer
            FormatCurrency["Format-Currency Cmdlet"]:::publicLayer
            SupportedFiat["SupportedCurrency.csv"]:::publicLayer
            SupportedCrypto["SupportedCryptoCurrency.csv"]:::publicLayer
        end

        subgraph "Private Helpers"
            direction TB
            CacheManager["Cache Manager"]:::privateLayer
            HTTPClient["HTTP Client"]:::privateLayer
            Parser["JSON Parser"]:::privateLayer
            UnixTimeHelper["ConvertFrom-UnixTime"]:::privateLayer
        end
    end

    %% Cache Storage
    CacheStore["Disk Cache (Local FS)"]:::cache

    %% External APIs
    ExchangeAPI["ExchangeRate-API"]:::external
    CoinbaseAPI["Coinbase API"]:::external

    %% DevOps Pipeline
    subgraph "CI/CD Pipeline"
        direction TB
        Lint["PSScriptAnalyzer"]:::devops
        Tests["Pester Tests"]:::devops
        Build["PSake Build"]:::devops
        Package["PSDeploy"]:::devops
        GitHubActions["GitHub Actions"]:::devops
        AzurePipelines["Azure Pipelines"]:::devops
    end

    %% Data Flow
    PSHost -->|"invokes cmdlet"| ConvertCurrency
    PSHost -->|"invokes cmdlet"| GetExchangeRate
    PSHost -->|"invokes cmdlet"| ConvertCrypto
    PSHost -->|"invokes cmdlet"| GetCryptoRate
    PSHost -->|"invokes cmdlet"| GetCrypto
    PSHost -->|"invokes cmdlet"| GetCurrency
    PSHost -->|"invokes cmdlet"| FormatCurrency

    %% Public to Private
    ConvertCurrency -->|calls| CacheManager
    GetExchangeRate -->|calls| CacheManager
    ConvertCrypto -->|calls| CacheManager
    GetCryptoRate -->|calls| CacheManager
    GetCrypto -->|calls| CacheManager
    GetCurrency -->|calls| CacheManager

    %% Cache Logic
    CacheManager -->|reads/writes| CacheStore
    CacheManager -->|on miss| HTTPClient
    HTTPClient -->|HTTPS request| ExchangeAPI
    HTTPClient -->|HTTPS request| CoinbaseAPI
    ExchangeAPI -->|JSON response| Parser
    CoinbaseAPI -->|JSON response| Parser
    Parser -->|PS Object| ConvertCurrency
    Parser -->|PS Object| GetExchangeRate
    Parser -->|PS Object| ConvertCrypto
    Parser -->|PS Object| GetCryptoRate
    Parser -->|PS Object| GetCrypto
    Parser -->|PS Object| GetCurrency

    %% DevOps Flow
    GitHubActions -->|on push| Lint
    GitHubActions --> Tests
    GitHubActions --> Build
    GitHubActions --> Package
    AzurePipelines -->|CI/CD| Lint
    AzurePipelines --> Tests
    AzurePipelines --> Build
    AzurePipelines --> Package

    %% Click Events
    click Manifest "https://github.com/markwragg/powershell-currencyconverter/blob/main/CurrencyConverter/CurrencyConverter.psd1"
    click Entry "https://github.com/markwragg/powershell-currencyconverter/blob/main/CurrencyConverter/CurrencyConverter.psm1"
    click ConvertCurrency "https://github.com/markwragg/powershell-currencyconverter/blob/main/CurrencyConverter/Public/Convert-Currency.ps1"
    click GetExchangeRate "https://github.com/markwragg/powershell-currencyconverter/blob/main/CurrencyConverter/Public/Get-ExchangeRate.ps1"
    click ConvertCrypto "https://github.com/markwragg/powershell-currencyconverter/blob/main/CurrencyConverter/Public/Convert-CryptoCurrency.ps1"
    click GetCryptoRate "https://github.com/markwragg/powershell-currencyconverter/blob/main/CurrencyConverter/Public/Get-CryptoExchangeRate.ps1"
    click GetCrypto "https://github.com/markwragg/powershell-currencyconverter/blob/main/CurrencyConverter/Public/Get-CryptoCurrency.ps1"
    click GetCurrency "https://github.com/markwragg/powershell-currencyconverter/blob/main/CurrencyConverter/Public/Get-Currency.ps1"
    click FormatCurrency "https://github.com/markwragg/powershell-currencyconverter/blob/main/CurrencyConverter/Public/Format-Currency.ps1"
    click SupportedFiat "https://github.com/markwragg/powershell-currencyconverter/blob/main/CurrencyConverter/Public/SupportedCurrency.csv"
    click SupportedCrypto "https://github.com/markwragg/powershell-currencyconverter/blob/main/CurrencyConverter/Public/SupportedCryptoCurrency.csv"
    click UnixTimeHelper "https://github.com/markwragg/powershell-currencyconverter/blob/main/CurrencyConverter/Private/ConvertFrom-UnixTime.ps1"
    click CacheManager "https://github.com/markwragg/powershell-currencyconverter/tree/main/CurrencyConverter/Private/"
    click HTTPClient "https://github.com/markwragg/powershell-currencyconverter/tree/main/CurrencyConverter/Private/"
    click Parser "https://github.com/markwragg/powershell-currencyconverter/tree/main/CurrencyConverter/Private/"
    click Lint "https://github.com/markwragg/powershell-currencyconverter/blob/main/PSScriptAnalyzerSettings.psd1"
    click GitHubActions "https://github.com/markwragg/powershell-currencyconverter/blob/main/.github/workflows/PSScriptAnalyzer.yml"
    click AzurePipelines "https://github.com/markwragg/powershell-currencyconverter/blob/main/azure-pipelines.yml"
    click Tests "https://github.com/markwragg/powershell-currencyconverter/tree/main/Tests/Common/"
    click Tests "https://github.com/markwragg/powershell-currencyconverter/blob/main/Tests/Convert-Currency.tests.ps1"
    click Tests "https://github.com/markwragg/powershell-currencyconverter/blob/main/Tests/Get-ExchangeRate.tests.ps1"
    click Tests "https://github.com/markwragg/powershell-currencyconverter/blob/main/Tests/Convert-CryptoCurrency.tests.ps1"
    click Tests "https://github.com/markwragg/powershell-currencyconverter/blob/main/Tests/Get-CrypyoExchangeRate.tests.ps1"
    click Tests "https://github.com/markwragg/powershell-currencyconverter/blob/main/Tests/Get-CryptoCurrency.tests.ps1"
    click Tests "https://github.com/markwragg/powershell-currencyconverter/blob/main/Tests/Get-Currency.tests.ps1"
    click Tests "https://github.com/markwragg/powershell-currencyconverter/blob/main/Tests/Format-Currency.tests.ps1"
    click Tests "https://github.com/markwragg/powershell-currencyconverter/blob/main/Tests/ConvertFrom-UnixTime.tests.ps1"
    click Build "https://github.com/markwragg/powershell-currencyconverter/tree/main/Build/"
    click Build "https://github.com/markwragg/powershell-currencyconverter/blob/main/Build/build.depend.psd1"
    click Build "https://github.com/markwragg/powershell-currencyconverter/blob/main/Build/build.psake.ps1"
    click Build "https://github.com/markwragg/powershell-currencyconverter/blob/main/Build/build.ps1"
    click Build "https://github.com/markwragg/powershell-currencyconverter/blob/main/Build/deploy.psdeploy.ps1"
    click Documentation "https://github.com/markwragg/powershell-currencyconverter/blob/main/Documentation/Convert-Currency.md"
    click Documentation "https://github.com/markwragg/powershell-currencyconverter/blob/main/Documentation/Get-ExchangeRate.md"
    click Documentation "https://github.com/markwragg/powershell-currencyconverter/blob/main/Documentation/Convert-CryptoCurrency.md"
    click Documentation "https://github.com/markwragg/powershell-currencyconverter/blob/main/Documentation/Get-CryptoExchangeRate.md"
    click Documentation "https://github.com/markwragg/powershell-currencyconverter/blob/main/Documentation/Get-CryptoCurrency.md"
    click Documentation "https://github.com/markwragg/powershell-currencyconverter/blob/main/Documentation/Get-Currency.md"
    click Documentation "https://github.com/markwragg/powershell-currencyconverter/blob/main/Documentation/Format-Currency.md"
    click Manifest "https://github.com/markwragg/powershell-currencyconverter/blob/main/CurrencyConverter/CurrencyConverter.psd1"
    click Entry "https://github.com/markwragg/powershell-currencyconverter/blob/main/CurrencyConverter/CurrencyConverter.psm1"

    %% Classes
    class Manifest,Entry,ConvertCurrency,GetExchangeRate,ConvertCrypto,GetCryptoRate,GetCrypto,GetCurrency,FormatCurrency,SupportedFiat,SupportedCrypto publicLayer
    class CacheManager,HTTPClient,Parser,UnixTimeHelper privateLayer
    class CacheStore cache
    class ExchangeAPI,CoinbaseAPI external
    class Lint,Tests,Build,Package,GitHubActions,AzurePipelines devops
    class PSHost host
```
