# theleveragedguess/unsure architecture

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

- Interactive diagram: https://gitdiagram.com/theleveragedguess/unsure
- Repository: https://github.com/theleveragedguess/unsure

## Overview

Unsure Calculator evaluates uncertain formulas using sampled ranges and presents summaries and histograms. Users can enter formulas through the command-line tool or the example web calculator; the package also supports custom Dart callbacks. The README documents the public calculation and range usage, but no source excerpts were supplied, so internal call relationships and web-component interactions are not asserted.

Main entry points: [`lib/src/calculation.dart`](https://github.com/theleveragedguess/unsure/blob/master/lib/src/calculation.dart) (Monte Carlo calculation), [`lib/src/result.dart`](https://github.com/theleveragedguess/unsure/blob/master/lib/src/result.dart) (Calculation result), [`bin/unsure.dart`](https://github.com/theleveragedguess/unsure/blob/master/bin/unsure.dart) (CLI entry), [`example/web/main.dart`](https://github.com/theleveragedguess/unsure/blob/master/example/web/main.dart) (Web entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_cli["CLI entry<br/>[unsure.dart]"]
  node_web_entry["Web entry<br/>[main.dart]"]
  node_web_app["Web application<br/>[app_component.dart]"]
  node_dorker["Formula dorker<br/>[unsure_dorker.dart]"]
  node_result_message["Result message"]
  node_worker["Web worker<br/>[worker.dart]"]
end

subgraph group_engine["Calculation Engine"]
  node_parser["Formula parser<br/>[parser.dart]"]
  node_ast["Formula AST<br/>[ast.dart]"]
  node_range["Uncertain range<br/>[range.dart]"]
  node_calculation["Monte Carlo calculation<br/>[calculation.dart]"]
end

subgraph group_statistics["Statistical Results"]
  node_result["Calculation result<br/>[result.dart]"]
  node_histogram["Histogram<br/>[histogram.dart]"]
  node_normal["Normal distribution"]
  node_formatter["Result formatter<br/>[formatter.dart]"]
end

node_user(("Calculator user"))

node_user -->|"runs formula"| node_cli
node_user -->|"uses calculator"| node_web_entry
node_cli -.->|"runs calculations"| node_calculation
node_web_entry -.->|"opens calculator"| node_web_app
node_user -->|"defines callback"| node_calculation
node_calculation -->|"samples ranges"| node_range
node_calculation -->|"produces result"| node_result
node_result -->|"exposes histogram"| node_histogram
node_result -.->|"exposes summary"| node_formatter
node_parser -.->|"parses formulas"| node_ast

click node_cli "https://github.com/theleveragedguess/unsure/blob/master/bin/unsure.dart"
click node_web_entry "https://github.com/theleveragedguess/unsure/blob/master/example/web/main.dart"
click node_web_app "https://github.com/theleveragedguess/unsure/blob/master/example/lib/app_component.dart"
click node_dorker "https://github.com/theleveragedguess/unsure/blob/master/example/lib/unsure_dorker.dart"
click node_result_message "https://github.com/theleveragedguess/unsure/blob/master/example/lib/unsure_result_message.dart"
click node_worker "https://github.com/theleveragedguess/unsure/blob/master/example/web/worker.dart"
click node_parser "https://github.com/theleveragedguess/unsure/blob/master/lib/src/parser.dart"
click node_ast "https://github.com/theleveragedguess/unsure/blob/master/lib/src/ast.dart"
click node_range "https://github.com/theleveragedguess/unsure/blob/master/lib/src/range.dart"
click node_calculation "https://github.com/theleveragedguess/unsure/blob/master/lib/src/calculation.dart"
click node_result "https://github.com/theleveragedguess/unsure/blob/master/lib/src/result.dart"
click node_histogram "https://github.com/theleveragedguess/unsure/blob/master/lib/src/histogram.dart"
click node_normal "https://github.com/theleveragedguess/unsure/blob/master/lib/src/normal_distribution.dart"
click node_formatter "https://github.com/theleveragedguess/unsure/blob/master/lib/src/formatter.dart"

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_cli,node_web_entry,node_web_app,node_dorker,node_result_message,node_worker,node_user toneBlue
class node_parser,node_ast,node_range,node_calculation toneAmber
class node_result,node_histogram,node_normal,node_formatter toneMint
```

## Components

### User Interfaces

- [CLI entry](https://github.com/theleveragedguess/unsure/blob/master/bin/unsure.dart): `bin/unsure.dart`
- [Web entry](https://github.com/theleveragedguess/unsure/blob/master/example/web/main.dart): `example/web/main.dart`
- [Web application](https://github.com/theleveragedguess/unsure/blob/master/example/lib/app_component.dart): `example/lib/app_component.dart`
- [Formula dorker](https://github.com/theleveragedguess/unsure/blob/master/example/lib/unsure_dorker.dart): `example/lib/unsure_dorker.dart`
- [Result message](https://github.com/theleveragedguess/unsure/blob/master/example/lib/unsure_result_message.dart): `example/lib/unsure_result_message.dart`
- [Web worker](https://github.com/theleveragedguess/unsure/blob/master/example/web/worker.dart): `example/web/worker.dart`

### Calculation Engine

- [Formula parser](https://github.com/theleveragedguess/unsure/blob/master/lib/src/parser.dart): `lib/src/parser.dart`
- [Formula AST](https://github.com/theleveragedguess/unsure/blob/master/lib/src/ast.dart): `lib/src/ast.dart`
- [Uncertain range](https://github.com/theleveragedguess/unsure/blob/master/lib/src/range.dart): `lib/src/range.dart`
- [Monte Carlo calculation](https://github.com/theleveragedguess/unsure/blob/master/lib/src/calculation.dart): `lib/src/calculation.dart`

### Statistical Results

- [Calculation result](https://github.com/theleveragedguess/unsure/blob/master/lib/src/result.dart): `lib/src/result.dart`
- [Histogram](https://github.com/theleveragedguess/unsure/blob/master/lib/src/histogram.dart): `lib/src/histogram.dart`
- [Normal distribution](https://github.com/theleveragedguess/unsure/blob/master/lib/src/normal_distribution.dart): `lib/src/normal_distribution.dart`
- [Result formatter](https://github.com/theleveragedguess/unsure/blob/master/lib/src/formatter.dart): `lib/src/formatter.dart`

### Other components

- **Calculator user**

## Connections

- Calculator user → CLI entry: runs formula (evidence: `README.md`)
- Calculator user → Web entry: uses calculator (evidence: `README.md`)
- CLI entry → Monte Carlo calculation: runs calculations
- Web entry → Web application: opens calculator
- Calculator user → Monte Carlo calculation: defines callback (evidence: `README.md`)
- Monte Carlo calculation → Uncertain range: samples ranges (evidence: `README.md`)
- Monte Carlo calculation → Calculation result: produces result (evidence: `README.md`)
- Calculation result → Histogram: exposes histogram (evidence: `README.md`)
- Calculation result → Result formatter: exposes summary
- Formula parser → Formula AST: parses formulas
