# jeremy-feng/bond-calculator architecture

> Architecture diagram of the GitHub repository jeremy-feng/bond-calculator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jeremy-feng/bond-calculator
- Repository: https://github.com/jeremy-feng/bond-calculator

## Overview

##### Identifying the Main Components
- User Interface (UI): This is the front end provided by Streamlit. It renders the interactive web page for inputting bond parameters and displaying the calculated results.
- Calculation Engine: This comprises the business logic for bond computations, mostly encapsulated in functions.py. It performs the core numerical calculations.
- Application Entry Point: The main.py file acts as the entry point that ties together the UI components of Streamlit with the underlying calculation logic in functions.py.
- External Dependencies: Streamlit is a key technology here. Additionally, standard Python libraries may be used for mathematical computations.

##### Relationships and Interactions
- The user interacts with the web page (UI) which is served by Streamlit.
- When the user submits bond parameters, the UI (managed in main.py) passes this data to the calculation engine (functions.py).
- The calculation engine processes the inputs and returns results (price, durations, convexity).
- The results are displayed dynamically on the UI for the user to review.

##### Key Architectural Patterns and Design Principles
- Separation of Concerns: The UI and computation logic are separated into different files (main.py vs. functions.py). This modularity helps in maintaining and extending the codebase.
- Simplicity: Given the small file structure, the project follows a simple yet effective layered approach with a clear split between user interface and business logic.
- Utilization of a Framework: Streamlit streamlines the creation of interactive web applications by abstracting away lower-level web development details.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Nodes
    U("User (Browser)"):::user
    UI("Streamlit Web UI"):::ui
    CE("Calculation Engine"):::calc
    ED("External Dependencies"):::ext

    %% Relationships
    U -->|"webRequest"| UI
    UI -->|"submitParameters"| CE
    CE -->|"returnResults"| UI
    UI -->|"displayResults"| U
    UI -.->|"dependsOn"| ED
    CE -.->|"uses"| ED

    %% Click Events
    click UI "https://github.com/jeremy-feng/bond-calculator/blob/main/main.py"
    click CE "https://github.com/jeremy-feng/bond-calculator/blob/main/functions.py"
    click ED "https://github.com/jeremy-feng/bond-calculator/blob/main/README.md"

    %% Styles
    classDef user fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef ui fill:#87CEFA,stroke:#333,stroke-width:2px;
    classDef calc fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef ext fill:#D3D3D3,stroke:#333,stroke-width:2px;
```
