# djotaku/amortization architecture

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

- Interactive diagram: https://gitdiagram.com/djotaku/amortization
- Repository: https://github.com/djotaku/amortization

## Overview

##### Project type and purpose
- This is a standalone Python amortization-table generator.
- It supports two “front ends”: a command-line interface (amortization.py) and a Qt GUI (amortization-gui.py + gui.py + gui.ui).
- Core function: compute payment schedules and output as CSV or on-screen/Qt table.

##### File structure
- Top-level scripts:
– amortization.py   → CLI entry point
– amortization-gui.py → GUI entry point
– gui.py            → GUI controller (loads .ui, handles signals)
– gui.ui            → Qt Designer UI definition
– test.py           → simple tests or demo harness
- Core library:
– amortization.py (also contains core logic if imported)
- Config/dependencies:
– requirements.txt  → lists Python packages (e.g., PyQt5 or PySide2)
- CI/CD:
– .github/workflows/*.yml → lint and build on Linux/Windows

##### Pull extra insights from the README
- Command-line flags (–csv, –screen, –P, –i, –n)
- Optional “extraprincipal” file for extra payments
- GUI uses Qt; on calculation writes amort.csv + populates a table widget

##### Main components & their interactions
a. Components:
1. User (CLI)
2. User (GUI)
3. CLI Front-end (amortization.py main)
4. GUI Front-end (amortization-gui.py & gui.py + gui.ui)
5. Core Engine / Business Logic (amortization module: calculation functions)
6. Optional Input (extraprincipal file)
7. Output writer (CSV generator)
8. Layer (terminal stdout or Qt TableView)
9. Tests (test.py)
10. CI/CD pipelines (.github/workflows)
b. Interactions:
– CLI front-end parses arguments → calls CoreEngine.calculate_schedule()
– GUI front-end loads UI → on “Calculate” → reads fields → calls CoreEngine.calculate_schedule()
– CoreEngine reads extraprincipal file (if present) → computes amortization schedule
– CoreEngine returns a data structure (list of rows)
– Output writer:
- If CLI+–csv → write CSV to disk
- If CLI+–screen → print to stdout
- If GUI → populate Qt TableView + write amort.csv
c. Architectural pattern
- Model-View-Controller–like separation:
– Model = CoreEngine (pure calculation)
– View+Controller = CLI parser or Qt widgets + gui.py
- Single process, modular Python packages
d. Key technologies
– Python 3.x
– argparse (CLI parsing)
– csv module
– PyQt5 or PySide2 for GUI
– Qt Designer (.ui file)
– GitHub Actions for CI

## Diagram (Mermaid)

```mermaid
flowchart TD
    UserCLI((User CLI)):::external
    UserGUI((User GUI)):::external

    subgraph "Front-Ends"
        CLI_FE["amortization.py\n(CLI Front-end)"]:::frontend
        GUI_FE["amortization-gui.py\n(GUI Entry Point)"]:::frontend
        GUI_ctrl["gui.py\n(Controller/View)"]:::frontend
        GUI_ui["gui.ui\n(UI Definition)"]:::frontend
    end

    subgraph "Core Engine"
        Core["amortization.py\n(Core Logic)"]:::core
    end

    subgraph "I/O"
        ExtraFile["extraprincipal.csv\n(Optional Input)"]:::io
        CSV_Out["amort.csv\n(CSV Output)"]:::io
        Requirements["requirements.txt"]:::io
    end

    subgraph "Tests & CI/CD"
        Tests["test.py"]:::ci
        subgraph "CI/CD Pipelines"
            Lint["lint.yml"]:::ci
            PR["pullrequest.yml"]:::ci
            WinBuild["windowsbuild.yml"]:::ci
        end
    end

    ExternalFS[(File System)]:::external
    DisplayTerminals[(Terminal / Qt Table)]:::external

    %% Connections
    UserCLI -->|invokes| CLI_FE
    CLI_FE -->|parses args| Core
    UserGUI -->|launches| GUI_FE
    GUI_FE -->|loads UI| GUI_ctrl
    GUI_ctrl -->|handles signals| Core
    Core -->|reads| ExtraFile
    Core -->|writes| CSV_Out
    Core -->|returns data| DisplayTerminals
    CLI_FE -->|uses| Requirements
    GUI_FE -->|uses| Requirements
    Tests -->|tests| Core
    Tests -->|uses| Requirements
    Requirements -->|installs deps| Core
    CSV_Out -->|stored in| ExternalFS

    %% Click Events
    click CLI_FE "https://github.com/djotaku/amortization/blob/master/amortization.py"
    click GUI_FE "https://github.com/djotaku/amortization/blob/master/amortization-gui.py"
    click GUI_ctrl "https://github.com/djotaku/amortization/blob/master/gui.py"
    click GUI_ui "https://github.com/djotaku/amortization/blob/master/gui.ui"
    click Core "https://github.com/djotaku/amortization/blob/master/amortization.py"
    click Tests "https://github.com/djotaku/amortization/blob/master/test.py"
    click Lint "https://github.com/djotaku/amortization/blob/master/.github/workflows/lint.yml"
    click PR "https://github.com/djotaku/amortization/blob/master/.github/workflows/pullrequest.yml"
    click WinBuild "https://github.com/djotaku/amortization/blob/master/.github/workflows/windowsbuild.yml"
    click Requirements "https://github.com/djotaku/amortization/blob/master/requirements.txt"
    click ExternalFS "https://github.com/djotaku/amortization/blob/master/README.md"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#004080,stroke-width:1px
    classDef core fill:#DFF2BF,stroke:#4F8A10,stroke-width:1px
    classDef io fill:#FFE0B2,stroke:#E65100,stroke-width:1px
    classDef ci fill:#E0E0E0,stroke:#6D6D6D,stroke-width:1px
    classDef external fill:#F5F5F5,stroke:#999999,stroke-width:1px
```
