# dbarnesmathworks/swap-pricer architecture

> Architecture diagram of the GitHub repository dbarnesmathworks/swap-pricer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dbarnesmathworks/swap-pricer
- Repository: https://github.com/dbarnesmathworks/swap-pricer

## Overview

##### Main Components
- App / Frontend: The “App” folder contains the GUI built using MATLAB’s App Designer (SwapPricingSimple.mlapp) and helper functions (getSwapsMAT.m, getYieldCurveFRED.m) that likely fetch required market data.
- Model / Backend Logic: The “Model” folder hosts the core pricing logic (e.g., priceSwapDiscount.m) that implements the mathematical models for discounting and swap pricing.
- Development and Testing Environment: The “Development” folder (with Swap_Development.mlx) and the “Test” folder (with TestSwapPricerAccuracy.m) provide scripts for development experiments and testing the accuracy of the pricing model.
- Resources: The “resources” directory, with its nested “project” folders containing numerous XML files, appears to supply configuration data, metadata, or additional domain-specific definitions needed by the project.

##### Out the Relationships and Data Flows
- The Frontend (App) receives user inputs and possibly triggers data retrieval (via getSwapsMAT.m and getYieldCurveFRED.m) to obtain real-time or configured market data.
- Upon receiving input data, the App communicates with the Backend (Model), calling functions like priceSwapDiscount.m to execute the core financial calculations.
- The outputs from the Model are then fed back to the App to display pricing results.
- The Testing and Development components validate that the pricing calculations and overall accuracy align with expectations.
- The Resources component provides ancillary configuration and possibly data feeds that might enhance or influence the model’s behavior.

##### Architectural Patterns and Design Principles
- Separation of Concerns: There is a clear demarcation between the frontend (presentation layer in App) and the backend (financial modeling in Model), with testing and development scripts isolated in their respective folders.
- Modularization: Independent modules (for UI, pricing logic, and tests) ensure maintainability and extensibility.
- Data Flow Emphasis: The fetching of market data via distinct functions (getSwapsMAT.m and getYieldCurveFRED.m) indicates a design that isolates data acquisition from computational logic.

##### Relevant Technologies
- MATLAB and its App Designer framework.
- MathWorks Financial Instruments Toolbox which underpins the pricing logic.
- MATLAB project files (SwapPricer.prj) that bundle the project configuration and dependencies.
- XML-based resource files may be used for configuration or data inputs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User Input"]:::user

    subgraph "App (UI)"
        A1["SwapPricingSimple (UI)"]:::frontend
        A2["getSwapsMAT (Data Retrieval)"]:::frontend
        A3["getYieldCurveFRED (Data Retrieval)"]:::frontend
    end

    subgraph "Model (Pricing Engine)"
        M1["priceSwapDiscount (Pricing Engine)"]:::backend
    end

    subgraph "Development/Testing Scripts"
        D1["Swap_Development.mlx"]:::devtest
        T1["TestSwapPricerAccuracy.m"]:::devtest
    end

    R["Resources (Configuration/Data)"]:::resources

    User -->|"initiates"| A1
    A1 -->|"calls_getSwapsMAT"| A2
    A1 -->|"calls_getYieldCurveFRED"| A3
    A1 -->|"sendsRequest"| M1
    M1 -->|"returnsPrice"| A1
    R -->|"config-data"| A1
    R -->|"config-data"| M1
    D1 -->|"validates"| M1
    T1 -->|"validates"| M1

    click A1 "https://github.com/dbarnesmathworks/swap-pricer/blob/main/App/SwapPricingSimple.mlapp"
    click A2 "https://github.com/dbarnesmathworks/swap-pricer/blob/main/App/getSwapsMAT.m"
    click A3 "https://github.com/dbarnesmathworks/swap-pricer/blob/main/App/getYieldCurveFRED.m"
    click M1 "https://github.com/dbarnesmathworks/swap-pricer/blob/main/Model/priceSwapDiscount.m"
    click D1 "https://github.com/dbarnesmathworks/swap-pricer/blob/main/Development/Swap_Development.mlx"
    click T1 "https://github.com/dbarnesmathworks/swap-pricer/blob/main/Test/TestSwapPricerAccuracy.m"
    click R "https://github.com/dbarnesmathworks/swap-pricer/tree/main/resources/"

    classDef frontend fill:#ADD8E6,stroke:#0A74DA,stroke-width:2px,color:#000;
    classDef backend fill:#98FB98,stroke:#008000,stroke-width:2px;
    classDef devtest fill:#FFD700,stroke:#FF8C00,stroke-width:2px;
    classDef resources fill:#D3D3D3,stroke:#696969,stroke-width:2px;
    classDef user fill:#E6E6FA,stroke:#800080,stroke-width:2px;
```
