# 0southboss0/expression-calculator architecture

> Architecture diagram of the GitHub repository 0southboss0/expression-calculator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/0southboss0/expression-calculator
- Repository: https://github.com/0southboss0/expression-calculator

## Overview

This is a Tkinter expression calculator. A user enters an expression and activates calculation; the view dispatches to the presenter, which asks the model to tokenize the input, convert tokens to postfix notation, and evaluate the result, then displays the value or an error. The README documents arithmetic, trigonometric, and other mathematical functions. The model excerpt is partial, so internal tokenizer and evaluator details are represented at the documented stage level.

Main entry points: [`presenter.py`](https://github.com/0southboss0/expression-calculator/blob/main/presenter.py) (Calculation presenter), [`view.py`](https://github.com/0southboss0/expression-calculator/blob/main/view.py) (Tkinter calculator view), [`model.py`](https://github.com/0southboss0/expression-calculator/blob/main/model.py) (Postfix evaluator), [`main.py`](https://github.com/0southboss0/expression-calculator/blob/main/main.py) (Application entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_view["Tkinter calculator view<br/>[view.py]"]
end

subgraph group_app["Application flow"]
  node_main["Application entry<br/>[main.py]"]
  node_presenter["Calculation presenter<br/>[presenter.py]"]
end

subgraph group_calc["Expression calculation"]
  node_tokenize["Expression tokenizer<br/>[model.py]"]
  node_shunting["Shunting-yard conversion<br/>[model.py]"]
  node_evaluate["Postfix evaluator<br/>[model.py]"]
end

node_user(("Calculator user"))
node_math["Python math"]
node_numpy["NumPy functions"]

node_main -->|"creates and initializes"| node_view
node_main -->|"wires"| node_presenter
node_user -->|"enters expression"| node_view
node_view -->|"dispatches calculation"| node_presenter
node_presenter -->|"reads input"| node_view
node_presenter -->|"tokenizes input"| node_tokenize
node_tokenize -->|"returns tokens"| node_presenter
node_presenter -->|"converts tokens"| node_shunting
node_shunting -->|"returns postfix"| node_presenter
node_presenter -->|"evaluates postfix"| node_evaluate
node_evaluate -->|"calls functions"| node_math
node_evaluate -->|"calls trig functions"| node_numpy
node_presenter -->|"displays result or error"| node_view

click node_main "https://github.com/0southboss0/expression-calculator/blob/main/main.py"
click node_view "https://github.com/0southboss0/expression-calculator/blob/main/view.py"
click node_presenter "https://github.com/0southboss0/expression-calculator/blob/main/presenter.py"
click node_tokenize "https://github.com/0southboss0/expression-calculator/blob/main/model.py"
click node_shunting "https://github.com/0southboss0/expression-calculator/blob/main/model.py"
click node_evaluate "https://github.com/0southboss0/expression-calculator/blob/main/model.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_view,node_user toneBlue
class node_main,node_presenter toneAmber
class node_tokenize,node_shunting,node_evaluate toneMint
class node_math,node_numpy toneIndigo
```

## Components

### User interface

- [Tkinter calculator view](https://github.com/0southboss0/expression-calculator/blob/main/view.py): `view.py`

### Application flow

- [Application entry](https://github.com/0southboss0/expression-calculator/blob/main/main.py): `main.py`
- [Calculation presenter](https://github.com/0southboss0/expression-calculator/blob/main/presenter.py): `presenter.py`

### Expression calculation

- [Expression tokenizer](https://github.com/0southboss0/expression-calculator/blob/main/model.py): `model.py`
- [Shunting-yard conversion](https://github.com/0southboss0/expression-calculator/blob/main/model.py): `model.py`
- [Postfix evaluator](https://github.com/0southboss0/expression-calculator/blob/main/model.py): `model.py`

### Other components

- **Calculator user**
- **Python math**
- **NumPy functions**

## Connections

- Application entry → Tkinter calculator view: creates and initializes
- Application entry → Calculation presenter: wires
- Calculator user → Tkinter calculator view: enters expression
- Tkinter calculator view → Calculation presenter: dispatches calculation
- Calculation presenter → Tkinter calculator view: reads input
- Calculation presenter → Expression tokenizer: tokenizes input
- Expression tokenizer → Calculation presenter: returns tokens
- Calculation presenter → Shunting-yard conversion: converts tokens
- Shunting-yard conversion → Calculation presenter: returns postfix
- Calculation presenter → Postfix evaluator: evaluates postfix
- Postfix evaluator → Python math: calls functions
- Postfix evaluator → NumPy functions: calls trig functions
- Calculation presenter → Tkinter calculator view: displays result or error
