Skip to content

app

Streamlit web interface for the refinance calculator.

main()

Render the refinance calculator Streamlit application.

Source code in src/refi_calculator/web/app.py
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
def main() -> None:
    """Render the refinance calculator Streamlit application."""
    logger.debug("Rendering Streamlit refinance calculator main screen.")
    ensure_option_state()
    st.set_page_config(
        page_title="Refinance Calculator",
        layout="wide",
    )

    st.title("Refinance Calculator")
    st.write(
        "Use the inputs below to compare refinancing scenarios, cash-out needs, "
        "and after-tax impacts before reviewing the cumulative savings timeline.",
    )

    calc_tab, analysis_tab, visuals_tab, market_tab, options_tab, info_tab = st.tabs(
        [
            "Calculator",
            "Analysis",
            "Loan Visualizations",
            "Market",
            "Options",
            "Info",
        ],
    )

    inputs: CalculatorInputs | None = None
    analysis: RefinanceAnalysis | None = None

    with calc_tab:
        inputs = collect_inputs()
        analysis = run_analysis(inputs)
        render_results(inputs, analysis)

    if inputs is None or analysis is None:
        return

    sensitivity_data, holding_period_data, amortization_data = prepare_auxiliary_data(inputs)

    with analysis_tab:
        render_analysis_tab(inputs, sensitivity_data, holding_period_data)

    with visuals_tab:
        render_loan_visualizations_tab(analysis, amortization_data)

    with market_tab:
        render_market_tab()

    with options_tab:
        render_options_tab(inputs)

    with info_tab:
        render_info_tab()