# kashisood/ccy-calc architecture

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

- Interactive diagram: https://gitdiagram.com/kashisood/ccy-calc
- Repository: https://github.com/kashisood/ccy-calc

## Overview

##### Project type and purpose
- This is a standalone backend microservice (“Ccy-calc”) built with Spring Boot and Maven.
- Its responsibility is to receive currency‐conversion requests, look up exchange rates (in an H2 database and/or in-memory cache), apply any business logic, and return a conversion result.

##### File structure
- Top-level artifacts:
- pom.xml / mvnw → Maven build & wrapper
- logs/ → runtime Log4j2 logs
- src/main/java/com/anz/curr/exchange/springcore:
- App.java / SpringBootMavenStarterApplication.java → Spring Boot entry points
- request/ → request‐DTOs (CurrencyRequest)
- processor/ → core business logic (CurrencyProcessor)
- dao/ → data access (CurrencyMappingDAO, ExchangeRateDao)
- entity/ → JPA or in-memory entities (CurrencyEntity, RateMap, CurrencyMatrix)
- cache/ → in-memory rate cache (CurrencyExchangeMappingCache, ExchangeRate)
- Response/ → response‐DTOs (ResponseObject)
- src/main/resources:
- application.properties → Spring Boot config
- data.sql / data-h2.sql → initial H2 data load scripts
- log4j2.xml → logging configuration
- Tests mirror the same packages under src/test/java.

##### README
- README only contains the project name (“Ccy-calc”), confirming there is no separate frontend or external services—this is a pure backend service.

##### Detailed capturing of essential elements
- Don’t omit the cache layer — it’s central to performance.
- Initial SQL data load (data.sql → H2) as part of application startup.
- Retry or error flows if relevant (e.g., DB unavailable → error response).

Summary

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Client
    Client["Client (REST Caller)"]:::external

    %% API Layer
    subgraph "API Layer"
        direction TB
        Controller["HTTP Controller"]:::api
        StarterApp["SpringBootMavenStarterApplication"]:::api
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        direction TB
        ProcessorIface["Processor Interface"]:::business
        CurrencyProcessor["CurrencyProcessor"]:::business
    end

    %% Cache Layer
    subgraph "Cache Layer"
        direction TB
        CurrencyCache["CurrencyExchangeMappingCache"]:::cache
        ExchangeRateModel["ExchangeRate"]:::cache
        CurrencyRateHelper["CurrencyExchangeRate"]:::cache
    end

    %% DAO Layer
    subgraph "DAO Layer"
        direction TB
        CurrencyMappingDAO["CurrencyMappingDAO"]:::dao
        ExchangeRateDao["ExchangeRateDao"]:::dao
    end

    %% Database
    H2DB["H2 Database"]:::db

    %% Logging Subsystem
    Logger["Log4j2 Logger"]:::logger

    %% Data Load Scripts
    subgraph "DB Initialization"
        direction TB
        DataSQL["data.sql"]:::script
        H2SQL["data-h2.sql"]:::script
    end

    %% Relationships
    Client -->|"POST /convert"| Controller
    Controller -->|"start application"| StarterApp
    Controller -->|"processRequest()"| ProcessorIface
    ProcessorIface -->|implements| CurrencyProcessor
    CurrencyProcessor -->|"lookupRate()"| CurrencyCache
    CurrencyCache -->|"cache hit|return rate"| CurrencyProcessor
    CurrencyCache -->|"cache miss|fetch() "| CurrencyMappingDAO
    CurrencyMappingDAO -->|"query() "| H2DB
    ExchangeRateDao -->|"query() "| H2DB
    H2DB -->|"result set"| CurrencyMappingDAO
    H2DB -->|"result set"| ExchangeRateDao
    CurrencyMappingDAO -->|"map to cache"| CurrencyCache
    CurrencyProcessor -->|"build ResponseObject"| Controller
    Controller -->|"return ResponseObject"| Client

    %% Initialization Flow
    DataSQL -->|init scripts| H2DB
    H2SQL -->|init scripts| H2DB

    %% Logging Arrows
    Controller -->|logs events| Logger
    CurrencyProcessor -->|logs events| Logger
    CurrencyCache -->|logs events| Logger
    CurrencyMappingDAO -->|logs events| Logger
    ExchangeRateDao -->|logs events| Logger
    H2DB -->|logs events| Logger

    %% Click Events
    click StarterApp "https://github.com/kashisood/ccy-calc/blob/master/src/main/java/com/anz/curr/exchange/SpringBootMavenStarterApplication.java"
    click Controller "https://github.com/kashisood/ccy-calc/blob/master/src/main/java/com/anz/curr/exchange/springcore/App.java"
    click CurrencyRequest "https://github.com/kashisood/ccy-calc/blob/master/src/main/java/com/anz/curr/exchange/springcore/request/CurrencyRequest.java"
    click CurrencyProcessor "https://github.com/kashisood/ccy-calc/blob/master/src/main/java/com/anz/curr/exchange/springcore/processor/CurrencyProcessor.java"
    click ProcessorIface "https://github.com/kashisood/ccy-calc/blob/master/src/main/java/com/anz/curr/exchange/springcore/processor/Processor.java"
    click CurrencyCache "https://github.com/kashisood/ccy-calc/blob/master/src/main/java/com/anz/curr/exchange/springcore/cache/CurrencyExchangeMappingCache.java"
    click ExchangeRateModel "https://github.com/kashisood/ccy-calc/blob/master/src/main/java/com/anz/curr/exchange/springcore/cache/ExchangeRate.java"
    click CurrencyRateHelper "https://github.com/kashisood/ccy-calc/blob/master/src/main/java/com/anz/curr/exchange/springcore/cache/CurrencyExchangeRate.java"
    click CurrencyMappingDAO "https://github.com/kashisood/ccy-calc/blob/master/src/main/java/com/anz/curr/exchange/springcore/dao/CurrencyMappingDAO.java"
    click ExchangeRateDao "https://github.com/kashisood/ccy-calc/blob/master/src/main/java/com/anz/curr/exchange/springcore/dao/ExchangeRateDao.java"
    click DataSQL "https://github.com/kashisood/ccy-calc/blob/master/src/main/resources/data.sql"
    click H2SQL "https://github.com/kashisood/ccy-calc/blob/master/src/main/resources/data-h2.sql"
    click Logger "https://github.com/kashisood/ccy-calc/blob/master/src/main/resources/log4j2.xml"

    %% Styles
    classDef external fill:#f2f2f2,stroke:#333,stroke-width:1px
    classDef api fill:#d0e6f7,stroke:#333,stroke-width:1px
    classDef business fill:#d4edda,stroke:#333,stroke-width:1px
    classDef cache fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef dao fill:#ffe5b4,stroke:#333,stroke-width:1px
    classDef db fill:#cfe2ff,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef logger fill:#e2e3e5,stroke:#333,stroke-width:1px
    classDef script fill:#f8d7da,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2
```
