# authorsauravkushwaha/scientific-calculator architecture

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

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

## Overview

This is a Tkinter scientific calculator with a deliberately separate, GUI-independent calculation engine. The main workflow is user input in the GUI, live preview or evaluation through the engine, safe expression evaluation, and display of the result. The engine also manages angle mode, memory, and calculation history. The README documents additional scientific functions and security behavior; excerpts do not show every implementation detail, so the graph omits uncertain internal links.

Main entry points: [`calculator_engine.py`](https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/calculator_engine.py) (Calculator engine), [`scientific_calculator.py`](https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/scientific_calculator.py) (Tkinter app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Calculator interface"]
  node_gui["Tkinter app"]
  node_expression["Expression entry"]
  node_preview["Live preview"]
  node_history_ui["History panel"]
end

subgraph group_calculation["Calculation core"]
  node_engine["Calculator engine"]
  node_preprocessing["Expression preprocessing"]
  node_evaluator["Safe evaluator"]
  node_formatting["Number formatting"]
end

subgraph group_state["Calculator state"]
  node_angle["Angle mode"]
  node_memory["Memory register"]
  node_history["Calculation history"]
end

node_user(("Calculator user"))

node_user -->|"enters expression"| node_expression
node_user -->|"uses controls"| node_gui
node_gui -->|"builds interface"| node_expression
node_expression -->|"triggers preview"| node_preview
node_preview -->|"calls peek"| node_engine
node_gui -->|"calls evaluate"| node_engine
node_engine -->|"normalizes input"| node_preprocessing
node_engine -->|"evaluates expression"| node_evaluator
node_evaluator -->|"reads mode"| node_angle
node_engine -->|"formats result"| node_formatting
node_engine -->|"updates history"| node_history
node_engine -->|"manages memory"| node_memory
node_gui -->|"toggles mode"| node_angle
node_gui -->|"uses memory controls"| node_memory
node_gui -->|"refreshes panel"| node_history_ui
node_history_ui -->|"reads entries"| node_history
node_engine -->|"returns result"| node_gui

click node_gui "https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/scientific_calculator.py"
click node_expression "https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/scientific_calculator.py"
click node_preview "https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/scientific_calculator.py"
click node_history_ui "https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/scientific_calculator.py"
click node_engine "https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/calculator_engine.py"
click node_preprocessing "https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/calculator_engine.py"
click node_evaluator "https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/calculator_engine.py"
click node_formatting "https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/calculator_engine.py"
click node_angle "https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/calculator_engine.py"
click node_memory "https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/calculator_engine.py"
click node_history "https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/calculator_engine.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_gui,node_expression,node_preview,node_history_ui,node_user toneBlue
class node_engine,node_preprocessing,node_evaluator,node_formatting toneAmber
class node_angle,node_memory,node_history toneMint
```

## Components

### Calculator interface

- [Tkinter app](https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/scientific_calculator.py): `scientific_calculator.py`
- [Expression entry](https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/scientific_calculator.py): `scientific_calculator.py`
- [Live preview](https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/scientific_calculator.py): `scientific_calculator.py`
- [History panel](https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/scientific_calculator.py): `scientific_calculator.py`

### Calculation core

- [Calculator engine](https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/calculator_engine.py): `calculator_engine.py`
- [Expression preprocessing](https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/calculator_engine.py): `calculator_engine.py`
- [Safe evaluator](https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/calculator_engine.py): `calculator_engine.py`
- [Number formatting](https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/calculator_engine.py): `calculator_engine.py`

### Calculator state

- [Angle mode](https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/calculator_engine.py): `calculator_engine.py`
- [Memory register](https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/calculator_engine.py): `calculator_engine.py`
- [Calculation history](https://github.com/authorsauravkushwaha/scientific-calculator/blob/main/calculator_engine.py): `calculator_engine.py`

### Other components

- **Calculator user**

## Connections

- Calculator user → Expression entry: enters expression
- Calculator user → Tkinter app: uses controls
- Tkinter app → Expression entry: builds interface
- Expression entry → Live preview: triggers preview
- Live preview → Calculator engine: calls peek
- Tkinter app → Calculator engine: calls evaluate
- Calculator engine → Expression preprocessing: normalizes input
- Calculator engine → Safe evaluator: evaluates expression
- Safe evaluator → Angle mode: reads mode
- Calculator engine → Number formatting: formats result
- Calculator engine → Calculation history: updates history
- Calculator engine → Memory register: manages memory
- Tkinter app → Angle mode: toggles mode
- Tkinter app → Memory register: uses memory controls
- Tkinter app → History panel: refreshes panel
- History panel → Calculation history: reads entries
- Calculator engine → Tkinter app: returns result
