# nbcamp-week7-team6/ukhyun-exchange-rate-calculator architecture

> Architecture diagram of the GitHub repository nbcamp-week7-team6/ukhyun-exchange-rate-calculator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator
- Repository: https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator

## Overview

##### Project type and purpose
- This is an iOS mobile application (“exchange-rate-calculator”) built in Swift using an MVVM + Clean Architecture pattern.
- Its purpose is to allow users to view and calculate currency exchange rates, cache recent rates locally, and save favorite currencies.

##### File structure
- Top-level “exchange-rate-calculator” folder contains:
- Application – AppDelegate, SceneDelegate, Assets, Storyboards
- Presentation – Views, ViewControllers, ViewModels, and ViewModel State/Action definitions
- Domain – Plain Swift Model types (CurrencyData, ExchangeRateData)
- Manager – networking (NetworkManager), caching (ExchangeRateCacheManager), favorites (FavoriteCurrencyManager)
- Core Data model & generated classes (CachedExchangeRate, FavoriteCurrency)
- Utility extensions (UIViewController, Double)

##### README
- Confirms MVVM + Clean Architecture as the guiding principles.

- User Interface Layer
– Views & ViewControllers (MainView, CalculatorView, ExchangeRateCellView, CalculatorViewController, etc.)
- Presentation Layer
– ViewModels + State machine (CalculatorViewModel, ViewModelState, ViewModelAction)
- Domain Layer
– Core data-free business models (CurrencyData, ExchangeRateData)
- Data Layer
– NetworkManager (fetch live rates from external API)
– ExchangeRateCacheManager & FavoriteCurrencyManager (persist/read Core Data entities)
– Core Data persistent store (Model.xcdatamodeld → CachedExchangeRate, FavoriteCurrency)
- Infrastructure / Application Layer
– AppDelegate / SceneDelegate (lifecycle, dependency assembly)
- External Services
– Third-party Exchange-Rate API over HTTPS

1. User taps in the UI → ViewController
2. ViewController invokes ViewModel methods (Action)
3. ViewModel calls Domain layer or directly calls Manager interfaces
4. Managers handle:
– NetworkManager → External API → returns JSON → Domain models
– CacheManager ↔ Core Data store
– FavoriteCurrencyManager ↔ Core Data store
5. ViewModel assembles new State and publishes it to the ViewController
6. ViewController updates Views

c. Architectural patterns & design principles
- MVVM separation: UI code in ViewControllers/Views; logic in ViewModels; pure models in Domain; side-effects in Managers.
- Clean Architecture boundaries: Presentation → Domain → Data → External.
- Dependency inversion: managers are abstracted behind protocols (where applicable).
- Single Responsibility: each layer/component has one clear role.

d. Key technologies & frameworks
- Swift + UIKit
- Core Data (persistent store)
- URLSession in NetworkManager
- Xcode project structure (.xcassets, Storyboards)
- MVVM + Clean Architecture

##### Details to capture
- AppDelegate/SceneDelegate initializing the root ViewController and injecting dependencies (e.g., NetworkManager, CacheManager).
- ViewController ↔ ViewModel binding (events & state).
- Delineate the two data paths: live-fetch (NetworkManager → Domain) vs. cache/favorites (Core Data).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Infrastructure Layer
    subgraph "Infrastructure / Application Layer"
        direction TB
        AppDelegate["AppDelegate"]:::infrastructure
        SceneDelegate["SceneDelegate"]:::infrastructure
    end

    %% UI Layer
    subgraph "UI Layer" 
        direction TB
        MainView["MainView"]:::ui
        CalculatorView["CalculatorView"]:::ui
        ExchangeRateCellView["ExchangeRateCellView"]:::ui
        RootVC["Root ViewController"]:::ui
        CalculatorVC["CalculatorViewController"]:::ui
        ExchangeRateCell["ExchangeRateTableViewCell"]:::ui
        LaunchStory["LaunchScreen.storyboard"]:::ui
        Assets["Assets.xcassets"]:::ui
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        VMProtocol["ViewModel Protocol"]:::presentation
        CalculatorVM["CalculatorViewModel"]:::presentation
        VMState["ViewModelState"]:::presentation
        VMAction["ViewModelAction"]:::presentation
        CalcState["CalculatorViewModelState"]:::presentation
        CalcAction["CalculatorViewModelAction"]:::presentation
    end

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        CurrencyData["CurrencyData"]:::domain
        ExchangeRateData["ExchangeRateData"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        NetworkManager["NetworkManager"]:::data
        CacheManager["ExchangeRateCacheManager"]:::data
        FavoriteManager["FavoriteCurrencyManager"]:::data
        subgraph "Core Data Store"
            direction TB
            CachedRate["CachedExchangeRate"]:::coredatadb
            FavoriteEntity["FavoriteCurrency"]:::coredatadb
        end
    end

    %% External Services
    subgraph "External Services"
        direction TB
        API["Exchange-Rate API"]:::external
    end

    %% Connections
    AppDelegate --> SceneDelegate
    SceneDelegate --> RootVC
    RootVC -->|binds to| CalculatorVC
    CalculatorVC -->|user action| CalculatorVM
    RootVC -->|user action| CalculatorVM
    CalculatorVC -->|renders state| CalculatorView
    CalculatorVM -->|updates| VMState
    VMState -->|drives| CalculatorVC
    CalculatorVM -->|uses| CurrencyData
    CalculatorVM -->|uses| ExchangeRateData
    CalculatorVM -->|calls| NetworkManager
    CalculatorVM -->|calls| CacheManager
    CalculatorVM -->|calls| FavoriteManager
    NetworkManager -->|fetches| API
    CacheManager --- CachedRate
    FavoriteManager --- FavoriteEntity

    %% Click Events
    click AppDelegate "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Application/AppDelegate.swift"
    click SceneDelegate "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Application/SceneDelegate.swift"
    click MainView "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Presentation/Views/MainView.swift"
    click CalculatorView "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Presentation/Views/CalculatorView.swift"
    click ExchangeRateCellView "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Presentation/Views/ExchangeRateCellView.swift"
    click RootVC "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Presentation/ViewControllers/ViewController.swift"
    click CalculatorVC "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Presentation/ViewControllers/CalculatorViewController.swift"
    click ExchangeRateCell "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Presentation/ViewControllers/ExchangeRateTableViewCell.swift"
    click LaunchStory "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Application/Base.lproj/LaunchScreen.storyboard"
    click Assets "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Application/Assets.xcassets"
    click VMProtocol "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Presentation/ViewModels/ViewModel.swift"
    click CalculatorVM "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Presentation/ViewModels/CalculatorViewModel.swift"
    click VMState "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Presentation/State/ViewModelState.swift"
    click VMAction "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Presentation/State/ViewModelAction.swift"
    click CalcState "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Presentation/State/CalculatorViewModelState.swift"
    click CalcAction "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Presentation/State/CalculatorViewModelAction.swift"
    click CurrencyData "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Domain/Model/CurrencyData.swift"
    click ExchangeRateData "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Domain/Model/ExchangeRateData.swift"
    click NetworkManager "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Manager/NetworkManager.swift"
    click CacheManager "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Manager/ExchangeRateCacheManager.swift"
    click FavoriteManager "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/Manager/FavoriteCurrencyManager.swift"
    click CachedRate "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/CachedExchangeRate+CoreDataClass.swift"
    click FavoriteEntity "https://github.com/nbcamp-week7-team6/ukhyun-exchange-rate-calculator/blob/main/exchange-rate-calculator/exchange-rate-calculator/FavoriteCurrency+CoreDataClass.swift"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#000;
    classDef presentation fill:#D2F8D2,stroke:#28A745,color:#000;
    classDef domain fill:#FFF8C4,stroke:#E09F3E,color:#000;
    classDef data fill:#FFE5B4,stroke:#FF8C00,color:#000;
    classDef infrastructure fill:#E0E0E0,stroke:#A0A0A0,color:#000;
    classDef external fill:#E6D0F4,stroke:#800080,color:#000;
    classDef coredatadb fill:#FFFFFF,stroke:#A0522D,stroke-dasharray: 5 5,color:#000;
    class CalculatorVC,RootVC ui
    classDef cylinder shape:cylinder
    class CachedRate,FavoriteEntity coredatadb
    class API external
    class NetworkManager,CacheManager,FavoriteManager data
    class AppDelegate,SceneDelegate infrastructure
```
