# heldercorreia/speedcrunch architecture

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

- Interactive diagram: https://gitdiagram.com/heldercorreia/speedcrunch
- Repository: https://github.com/heldercorreia/speedcrunch

## Overview

SpeedCrunch is a high-precision scientific calculator. Its principal workflow is keyboard entry of an expression, evaluation to a quantity, and display of formatted results; sessions also preserve history and user-defined symbols. The README documents syntax highlighting, completion, a formula book, and constant insertion, which are represented as product capabilities. The sampled source supports the editor–session–evaluator and numeric representation layers; GUI wiring beyond those excerpts is not asserted.

Main entry points: [`src/core/evaluator.cpp`](https://github.com/heldercorreia/speedcrunch/blob/main/src/core/evaluator.cpp) (Expression evaluator), [`src/gui/editor.cpp`](https://github.com/heldercorreia/speedcrunch/blob/main/src/gui/editor.cpp) (Expression editor), [`src/main.cpp`](https://github.com/heldercorreia/speedcrunch/blob/main/src/main.cpp) (Application startup), [`src/core/session.cpp`](https://github.com/heldercorreia/speedcrunch/blob/main/src/core/session.cpp) (Session state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Calculator interface"]
  node_app["Application startup<br/>[main.cpp]"]
  node_editor["Expression editor<br/>[editor.cpp]"]
  node_syntax["Syntax highlighting"]
  node_results["Scrollable results<br/>[resultdisplay.cpp]"]
  node_keypad["Keyboard keypad<br/>[keypad.cpp]"]
  node_mainwindow["Main window<br/>[mainwindow.h]"]
end

subgraph group_runtime["Evaluation and sessions"]
  node_session["Session state<br/>[session.cpp]"]
  node_history["Evaluation history<br/>[sessionhistory.cpp]"]
  node_evaluator["Expression evaluator<br/>[evaluator.cpp]"]
  node_symbols["Symbol context<br/>[symbolcontext.h]"]
  node_functions["Built-in functions<br/>[functions.cpp]"]
  node_units["Units system<br/>[units.cpp]"]
  node_settings["Preferences<br/>[settings.cpp]"]
end

subgraph group_numeric["Numeric engine"]
  node_quantity["Quantities<br/>[quantity.cpp]"]
  node_complex["Complex arithmetic<br/>[cmath.cpp]"]
  node_precision["High precision math<br/>[hmath.cpp]"]
  node_floatnum["Floating-point core"]
end

subgraph group_features["Calculator features"]
  node_completion["Auto-completion<br/>[editor.cpp]"]
  node_book["Formula book<br/>[book.cpp]"]
  node_constants["Constants insertion"]
  node_manual["Help manual<br/>[manualwindow.cpp]"]
end

node_user(("Calculator user"))

node_user -->|"starts"| node_app
node_app -->|"creates"| node_mainwindow
node_user -->|"enters expressions"| node_editor
node_editor -->|"uses session"| node_session
node_editor -->|"creates highlighter"| node_syntax
node_editor -->|"gets evaluator"| node_evaluator
node_session -->|"owns evaluator"| node_evaluator
node_session -->|"stores history"| node_history
node_evaluator -->|"uses symbol context"| node_symbols
node_evaluator -->|"uses functions"| node_functions
node_evaluator -->|"uses user units"| node_units
node_evaluator -->|"produces quantities"| node_quantity
node_quantity -->|"uses complex numbers"| node_complex
node_quantity -->|"uses high precision"| node_precision
node_precision -->|"uses numeric core"| node_floatnum
node_user -->|"uses keyboard input"| node_keypad
node_user -->|"views results"| node_results
node_user -->|"uses completion"| node_completion
node_user -->|"uses formula book"| node_book
node_user -->|"inserts constants"| node_constants
node_user -->|"consults manual"| node_manual
node_app -->|"loads preferences"| node_settings

click node_app "https://github.com/heldercorreia/speedcrunch/blob/main/src/main.cpp"
click node_editor "https://github.com/heldercorreia/speedcrunch/blob/main/src/gui/editor.cpp"
click node_syntax "https://github.com/heldercorreia/speedcrunch/blob/main/src/gui/syntaxhighlighter.cpp"
click node_results "https://github.com/heldercorreia/speedcrunch/blob/main/src/gui/resultdisplay.cpp"
click node_keypad "https://github.com/heldercorreia/speedcrunch/blob/main/src/gui/keypad.cpp"
click node_mainwindow "https://github.com/heldercorreia/speedcrunch/blob/main/src/gui/mainwindow.h"
click node_session "https://github.com/heldercorreia/speedcrunch/blob/main/src/core/session.cpp"
click node_history "https://github.com/heldercorreia/speedcrunch/blob/main/src/core/sessionhistory.cpp"
click node_evaluator "https://github.com/heldercorreia/speedcrunch/blob/main/src/core/evaluator.cpp"
click node_symbols "https://github.com/heldercorreia/speedcrunch/blob/main/src/core/symbolcontext.h"
click node_functions "https://github.com/heldercorreia/speedcrunch/blob/main/src/core/functions.cpp"
click node_units "https://github.com/heldercorreia/speedcrunch/blob/main/src/core/units.cpp"
click node_quantity "https://github.com/heldercorreia/speedcrunch/blob/main/src/math/quantity.cpp"
click node_complex "https://github.com/heldercorreia/speedcrunch/blob/main/src/math/cmath.cpp"
click node_precision "https://github.com/heldercorreia/speedcrunch/blob/main/src/math/hmath.cpp"
click node_floatnum "https://github.com/heldercorreia/speedcrunch/tree/main/src/math/floatnum"
click node_completion "https://github.com/heldercorreia/speedcrunch/blob/main/src/gui/editor.cpp"
click node_book "https://github.com/heldercorreia/speedcrunch/blob/main/src/core/book.cpp"
click node_constants "https://github.com/heldercorreia/speedcrunch/blob/main/src/gui/constantswidget.cpp"
click node_settings "https://github.com/heldercorreia/speedcrunch/blob/main/src/core/settings.cpp"
click node_manual "https://github.com/heldercorreia/speedcrunch/blob/main/src/gui/manualwindow.cpp"

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_app,node_editor,node_syntax,node_results,node_keypad,node_mainwindow,node_user toneBlue
class node_session,node_history,node_evaluator,node_symbols,node_functions,node_units,node_settings toneAmber
class node_quantity,node_complex,node_precision,node_floatnum toneMint
class node_completion,node_book,node_constants,node_manual toneRose
```

## Components

### Calculator interface

- [Application startup](https://github.com/heldercorreia/speedcrunch/blob/main/src/main.cpp): `src/main.cpp`
- [Expression editor](https://github.com/heldercorreia/speedcrunch/blob/main/src/gui/editor.cpp): `src/gui/editor.cpp`
- [Syntax highlighting](https://github.com/heldercorreia/speedcrunch/blob/main/src/gui/syntaxhighlighter.cpp): `src/gui/syntaxhighlighter.cpp`
- [Scrollable results](https://github.com/heldercorreia/speedcrunch/blob/main/src/gui/resultdisplay.cpp): `src/gui/resultdisplay.cpp`
- [Keyboard keypad](https://github.com/heldercorreia/speedcrunch/blob/main/src/gui/keypad.cpp): `src/gui/keypad.cpp`
- [Main window](https://github.com/heldercorreia/speedcrunch/blob/main/src/gui/mainwindow.h): `src/gui/mainwindow.h`

### Evaluation and sessions

- [Session state](https://github.com/heldercorreia/speedcrunch/blob/main/src/core/session.cpp): `src/core/session.cpp`
- [Evaluation history](https://github.com/heldercorreia/speedcrunch/blob/main/src/core/sessionhistory.cpp): `src/core/sessionhistory.cpp`
- [Expression evaluator](https://github.com/heldercorreia/speedcrunch/blob/main/src/core/evaluator.cpp): `src/core/evaluator.cpp`
- [Symbol context](https://github.com/heldercorreia/speedcrunch/blob/main/src/core/symbolcontext.h): `src/core/symbolcontext.h`
- [Built-in functions](https://github.com/heldercorreia/speedcrunch/blob/main/src/core/functions.cpp): `src/core/functions.cpp`
- [Units system](https://github.com/heldercorreia/speedcrunch/blob/main/src/core/units.cpp): `src/core/units.cpp`
- [Preferences](https://github.com/heldercorreia/speedcrunch/blob/main/src/core/settings.cpp): `src/core/settings.cpp`

### Numeric engine

- [Quantities](https://github.com/heldercorreia/speedcrunch/blob/main/src/math/quantity.cpp): `src/math/quantity.cpp`
- [Complex arithmetic](https://github.com/heldercorreia/speedcrunch/blob/main/src/math/cmath.cpp): `src/math/cmath.cpp`
- [High precision math](https://github.com/heldercorreia/speedcrunch/blob/main/src/math/hmath.cpp): `src/math/hmath.cpp`
- [Floating-point core](https://github.com/heldercorreia/speedcrunch/tree/main/src/math/floatnum): `src/math/floatnum`

### Calculator features

- [Auto-completion](https://github.com/heldercorreia/speedcrunch/blob/main/src/gui/editor.cpp): `src/gui/editor.cpp`
- [Formula book](https://github.com/heldercorreia/speedcrunch/blob/main/src/core/book.cpp): `src/core/book.cpp`
- [Constants insertion](https://github.com/heldercorreia/speedcrunch/blob/main/src/gui/constantswidget.cpp): `src/gui/constantswidget.cpp`
- [Help manual](https://github.com/heldercorreia/speedcrunch/blob/main/src/gui/manualwindow.cpp): `src/gui/manualwindow.cpp`

### Other components

- **Calculator user**

## Connections

- Calculator user → Application startup: starts
- Application startup → Main window: creates (evidence: `src/main.cpp`)
- Calculator user → Expression editor: enters expressions
- Expression editor → Session state: uses session (evidence: `src/gui/editor.cpp`)
- Expression editor → Syntax highlighting: creates highlighter (evidence: `src/gui/editor.cpp`)
- Expression editor → Expression evaluator: gets evaluator (evidence: `src/gui/editor.cpp`)
- Session state → Expression evaluator: owns evaluator (evidence: `src/core/session.cpp`)
- Session state → Evaluation history: stores history (evidence: `src/core/session.cpp`)
- Expression evaluator → Symbol context: uses symbol context
- Expression evaluator → Built-in functions: uses functions
- Expression evaluator → Units system: uses user units
- Expression evaluator → Quantities: produces quantities
- Quantities → Complex arithmetic: uses complex numbers
- Quantities → High precision math: uses high precision
- High precision math → Floating-point core: uses numeric core (evidence: `src/math/hmath.cpp`)
- Calculator user → Keyboard keypad: uses keyboard input
- Calculator user → Scrollable results: views results
- Calculator user → Auto-completion: uses completion
- Calculator user → Formula book: uses formula book
- Calculator user → Constants insertion: inserts constants
- Calculator user → Help manual: consults manual
- Application startup → Preferences: loads preferences (evidence: `src/main.cpp`)
