Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Building Fralculator: an offline-first, step-by-step calculator in Electron

Description and use

Fralculator is an offline‑first Electron calculator that shows step‑by‑step PEMDAS traces, supports natural‑language and voice input, and is packaged for Windows and Linux.

Problem

Most calculators evaluate expressions without explaining the steps. I wanted a calculator that shows the ordered PEMDAS trace and a plain‑English explanation for each step.

Outcome

Fralculator delivers an offline‑first calculator that explains each evaluation step, supports natural‑language input via rule‑based autocorrect, includes voice input with Whisper‑tiny, and ships as signed installers for Windows and Linux.

Workflow

  • 1. Tokenize the input string into numbers, operators, parentheses, and unary minus.
  • 2. Parse the tokens into an AST using recursive‑descent with precedence climbing.
  • 3. Evaluate the AST while recording a step trace at precedence boundaries.
  • 4. Render the trace with KaTeX and display plain‑English explanations.
  • 5. Apply word‑shorthand autocorrect rules to typed and voice input.
  • 6. For voice, use Whisper‑tiny WASM in a worker to transcribe audio, then run the same autocorrect pipeline.
  • 7. Package the app with electron‑builder for Windows (NSIS, portable exe) and Linux (AppImage, deb, rpm).

Evidence

Most calculators evaluate. I wanted one that explains the evaluation: given 3 × (4 + 5), show the ordered PEMDAS trace — 4 + 5 = 9, then 3 × 9 = 27 — rendered as real math notation, with a plain-English sentence underneath.

Source

Offline by default. The only allowed network calls: an optional currency rate fetch and a one-time ~40 MB model download for voice.

Source

The engine is deliberately classic. A tokenizer turns the string into tokens (numbers, operators, parens, unary minus), a recursive‑descent parser builds an AST with the usual precedence climbing, and the evaluator walks it.

Source

Natural‑language input in a calculator is either a tiny rule engine or an LLM. Offline means rule engine.

Source

  • Record date: 2026-10-01T03:23:00.183Z