# biati-digital/alfred-calculate-anything architecture

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

- Interactive diagram: https://gitdiagram.com/biati-digital/alfred-calculate-anything
- Repository: https://github.com/biati-digital/alfred-calculate-anything

## Overview

##### External Services Layer
- Fixer.io API (Currency rates)
- CoinMarketCap API (Cryptocurrency rates)

##### Data Stores
- Local Cache Storage
- Configuration Storage
- Language Files Storage
- Currency/Crypto Data Storage

##### Use a top-down approach with these layers
**[User Input Layer (Alfred)]**
- ↓
**[Natural Language Processing Layer]**
- ↓
**[Core Processing Layer]**
- ↓
**[Tool Modules Layer]**
- ↓
**[External Services Layer]**

##### Component Relationships

**[Input] → [Natural Language Processor] → [Calculator Engine]**
- ↓
- [Tool Modules] ←→ [External Services]
- ↓
- [Cache Storage]

##### Specific elements

a) Input Processing:
- How Alfred input is parsed through the natural language processor
- Language file integration points

b) Calculator Engine:
- Connection to different tool modules
- Configuration points

c) Data Flow:
- API calls to external services
- Caching mechanisms
- How results are formatted and returned to Alfred

##### Technical Details

- PHP as the primary language
- Alfred workflow integration points
- API endpoints for currency and crypto
- Cache storage mechanism
- Configuration file locations

**→ Data Flow**
**⇄ Two-way Communication**
**□ Core Component**
**○ Tool Module**
**◇ External Service**
**▽ Data Store**

##### The configuration and customization options

This system design should reflect the workflow's ability to handle multiple calculation types while maintaining performance through caching and modular design, as evidenced by the project structure and README documentation.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        AI[Alfred Interface]
        PH[Process Handler]
    end

    subgraph NLP[Natural Language Processing Layer]
        LP[Language Processor]
        LF[Language Files]
    end

    subgraph Core[Core Processing Layer]
        CE[Calculator Engine]
        TI[Tool Interface]
        CM[Configuration Manager]
    end

    subgraph Tools[Tool Modules Layer]
        CUR[Currency Converter]
        CRY[Cryptocurrency Converter]
        UN[Units Converter]
        TC[Time Calculator]
        VAT[VAT Calculator]
        PC[Percentage Calculator]
        PX[PX/EM/REM Converter]
        DS[Data Storage Calculator]
    end

    subgraph External[External Services Layer]
        FX[Fixer.io API]
        CMC[CoinMarketCap API]
    end

    subgraph Storage[Data Storage Layer]
        CS[Cache Storage]
        CF[Configuration Storage]
        CDS[Currency/Crypto Data]
    end

    AI --> PH
    PH --> LP
    LP --> CE
    LP <--> LF
    CE <--> TI
    CE <--> CM
    TI --> Tools
    CUR <--> FX
    CRY <--> CMC
    Tools <--> CS
    CM <--> CF
    CUR & CRY <--> CDS

    click AI "https://github.com/biati-digital/alfred-calculate-anything/blob/master/alfred/Alfred.php"
    click PH "https://github.com/biati-digital/alfred-calculate-anything/blob/master/process.php"
    click CUR "https://github.com/biati-digital/alfred-calculate-anything/blob/master/workflow/tools/currency.php"
    click CRY "https://github.com/biati-digital/alfred-calculate-anything/blob/master/workflow/tools/cryptocurrency.php"
    click UN "https://github.com/biati-digital/alfred-calculate-anything/blob/master/workflow/tools/units.php"
    click TC "https://github.com/biati-digital/alfred-calculate-anything/blob/master/workflow/tools/time.php"
    click VAT "https://github.com/biati-digital/alfred-calculate-anything/blob/master/workflow/tools/vat.php"
    click PC "https://github.com/biati-digital/alfred-calculate-anything/blob/master/workflow/tools/percentage.php"
    click PX "https://github.com/biati-digital/alfred-calculate-anything/blob/master/workflow/tools/pxemrem.php"
    click DS "https://github.com/biati-digital/alfred-calculate-anything/blob/master/workflow/tools/datastorage.php"
    click TI "https://github.com/biati-digital/alfred-calculate-anything/blob/master/workflow/tools/calculatorinterface.php"
    click CF "https://github.com/biati-digital/alfred-calculate-anything/blob/master/workflow.ini"
    click LF "https://github.com/biati-digital/alfred-calculate-anything/tree/master/lang/"
    click CDS "https://github.com/biati-digital/alfred-calculate-anything/blob/master/data/crypto-currencies.json"
    click CS "https://github.com/biati-digital/alfred-calculate-anything/blob/master/workflow/lib/clear.php"

    classDef core fill:#2374ab
    classDef tool fill:#2a9d8f
    classDef external fill:#e76f51
    classDef storage fill:#8338ec
    classDef input fill:#grey

    class AI,PH input
    class LP,CE,TI,CM core
    class CUR,CRY,UN,TC,VAT,PC,PX,DS tool
    class FX,CMC external
    class CS,CF,CDS,LF storage
```
