# arjnpdl/calculator architecture

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

- Interactive diagram: https://gitdiagram.com/arjnpdl/calculator
- Repository: https://github.com/arjnpdl/calculator

## Overview

##### Main components
- User Interface (UI) Component: This is built with PySimpleGUI. It displays buttons, input fields, and results.
- Event Handling Component: Although not split into separate files, the code likely includes an event loop that listens for user interactions (e.g., button clicks or key presses).
- Calculation/Logic Component: Contains functions or logic to perform the basic arithmetic operations like addition, subtraction, multiplication, and division.

##### Establish relationships and interactions
- The UI Component captures user inputs (such as numbers and operations).
- The Event Handling Component intercepts these inputs, triggering the appropriate events.
- The Calculation Component processes these inputs (performing arithmetic operations) and sends back the result.
- The UI updates with the calculation result.

##### Design principles
- Even though the implementation is in one file, the separation of concerns is present (event handling vs. computation vs. rendering).
- A simple event-driven model, which is typical for GUI applications, is used.

##### Relevant technologies
- PySimpleGUI is the key framework used for the GUI.
- Python itself ties all components together in a single executable file.

## Diagram (Mermaid)

```mermaid
graph TD
    UI["User Interface (PySimpleGUI)"]:::ui
    EH["Event Loop / Input Handler"]:::controller
    CL["Calculation Logic"]:::model

    UI -->|"captures_input"| EH
    EH -->|"triggers_calculation"| CL
    CL -->|"returns_result"| UI

    click UI "https://github.com/arjnpdl/calculator/blob/main/calculator.py"
    click EH "https://github.com/arjnpdl/calculator/blob/main/calculator.py"
    click CL "https://github.com/arjnpdl/calculator/blob/main/calculator.py"

    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef controller fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef model fill:#FFD700,stroke:#000,stroke-width:2px;
```
