# skysaksham/math-expression-evaluator architecture

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

- Interactive diagram: https://gitdiagram.com/skysaksham/math-expression-evaluator
- Repository: https://github.com/skysaksham/math-expression-evaluator

## Overview

This is a small, single-file Python expression evaluator, usable from a terminal or imported through `evaluate()`. Its workflow normalizes input, validates it, tokenizes it, evaluates nested brackets, then applies unary handling and arithmetic operators. The README documents the supported operators and error cases; the sampled source shows the call structure. All repository components belong to `evaluator.py`, so no subsystem groups are needed.

Main entry points: [`evaluator.py`](https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py) (Expression Evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_user(("Expression User"))
node_evaluate["Evaluate Entry<br/>[evaluator.py]"]
node_normalize["Input Normalize<br/>[evaluator.py]"]
node_validate["Syntax Validate<br/>[evaluator.py]"]
node_tokenize["Tokenize Expression<br/>[evaluator.py]"]
node_brackets["Bracket Evaluation<br/>[evaluator.py]"]
node_expression["Expression Evaluation<br/>[evaluator.py]"]
node_unary["Unary Operators<br/>[evaluator.py]"]
node_exponent["Exponentiation<br/>[evaluator.py]"]
node_division["Division<br/>[evaluator.py]"]
node_multiplication["Multiplication<br/>[evaluator.py]"]
node_addition["Addition Subtraction<br/>[evaluator.py]"]

node_user -->|"enters expression"| node_normalize
node_evaluate -->|"calls"| node_normalize
node_evaluate -->|"validates input"| node_validate
node_evaluate -->|"tokenizes input"| node_tokenize
node_evaluate -->|"evaluates tokens"| node_brackets
node_brackets -->|"evaluates contents"| node_expression
node_expression -->|"handles unary"| node_unary
node_expression -->|"evaluates powers"| node_exponent
node_expression -->|"evaluates division"| node_division
node_expression -->|"evaluates products"| node_multiplication
node_expression -->|"evaluates sums"| node_addition
node_evaluate -->|"returns result"| node_user

click node_evaluate "https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py"
click node_normalize "https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py"
click node_validate "https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py"
click node_tokenize "https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py"
click node_brackets "https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py"
click node_expression "https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py"
click node_unary "https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py"
click node_exponent "https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py"
click node_division "https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py"
click node_multiplication "https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py"
click node_addition "https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.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_user toneBlue
class node_evaluate,node_normalize,node_validate,node_tokenize,node_brackets,node_expression,node_unary,node_exponent,node_division,node_multiplication,node_addition toneTeal
```

## Components

### Other components

- **Expression User**
- [Evaluate Entry](https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py): `evaluator.py`
- [Input Normalize](https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py): `evaluator.py`
- [Syntax Validate](https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py): `evaluator.py`
- [Tokenize Expression](https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py): `evaluator.py`
- [Bracket Evaluation](https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py): `evaluator.py`
- [Expression Evaluation](https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py): `evaluator.py`
- [Unary Operators](https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py): `evaluator.py`
- [Exponentiation](https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py): `evaluator.py`
- [Division](https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py): `evaluator.py`
- [Multiplication](https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py): `evaluator.py`
- [Addition Subtraction](https://github.com/skysaksham/math-expression-evaluator/blob/main/evaluator.py): `evaluator.py`

## Connections

- Expression User → Input Normalize: enters expression
- Evaluate Entry → Input Normalize: calls
- Evaluate Entry → Syntax Validate: validates input
- Evaluate Entry → Tokenize Expression: tokenizes input
- Evaluate Entry → Bracket Evaluation: evaluates tokens
- Bracket Evaluation → Expression Evaluation: evaluates contents
- Expression Evaluation → Unary Operators: handles unary
- Expression Evaluation → Exponentiation: evaluates powers
- Expression Evaluation → Division: evaluates division
- Expression Evaluation → Multiplication: evaluates products
- Expression Evaluation → Addition Subtraction: evaluates sums
- Evaluate Entry → Expression User: returns result
