# filiph/unsure architecture

> Architecture diagram of the GitHub repository filiph/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/filiph/unsure
- Repository: https://github.com/filiph/unsure

## Overview

Unsure Calculator is a Dart uncertainty-calculation package with a command-line tool and a browser calculator. The documented workflow is to submit a formula to the CLI, or construct a Calculation with a callback and ranges, run it, and inspect the result. The README also documents parser-supported formulas and result summaries, but no source excerpts were provided, so internal calls and the web app’s implementation details are not inferred.

Main entry points: [`lib/src/calculation.dart`](https://github.com/filiph/unsure/blob/master/lib/src/calculation.dart) (Monte Carlo calculation), [`lib/src/result.dart`](https://github.com/filiph/unsure/blob/master/lib/src/result.dart) (Calculation result), [`lib/unsure.dart`](https://github.com/filiph/unsure/blob/master/lib/unsure.dart) (Package API), [`bin/unsure.dart`](https://github.com/filiph/unsure/blob/master/bin/unsure.dart) (Command-line tool)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entrypoints["User entrypoints"]
  node_cli["Command-line tool<br/>[unsure.dart]"]
  node_web["Browser calculator"]
  node_api["Package API<br/>[unsure.dart]"]
end

subgraph group_calculation["Calculation engine"]
  node_range["Uncertain range<br/>[range.dart]"]
  node_parser["Formula parser<br/>[parser.dart]"]
  node_ast["Formula AST<br/>[ast.dart]"]
  node_calculation_run["Monte Carlo calculation<br/>[calculation.dart]"]
  node_normal["Normal distribution"]
end

subgraph group_statistics["Results and statistics"]
  node_result["Calculation result<br/>[result.dart]"]
  node_histogram["Result histogram<br/>[histogram.dart]"]
  node_formatter["Result formatter<br/>[formatter.dart]"]
end

node_user(("Calculator user"))

node_user -->|"runs formula"| node_cli
node_user -->|"uses calculator"| node_web
node_user -->|"uses package"| node_api
node_api -->|"runs calculation"| node_calculation_run
node_calculation_run -->|"samples ranges"| node_range
node_calculation_run -->|"returns result"| node_result
node_result -->|"exposes histogram"| node_histogram
node_result -->|"exposes summary"| node_formatter

click node_cli "https://github.com/filiph/unsure/blob/master/bin/unsure.dart"
click node_web "https://github.com/filiph/unsure/tree/master/example"
click node_api "https://github.com/filiph/unsure/blob/master/lib/unsure.dart"
click node_range "https://github.com/filiph/unsure/blob/master/lib/src/range.dart"
click node_parser "https://github.com/filiph/unsure/blob/master/lib/src/parser.dart"
click node_ast "https://github.com/filiph/unsure/blob/master/lib/src/ast.dart"
click node_calculation_run "https://github.com/filiph/unsure/blob/master/lib/src/calculation.dart"
click node_normal "https://github.com/filiph/unsure/blob/master/lib/src/normal_distribution.dart"
click node_result "https://github.com/filiph/unsure/blob/master/lib/src/result.dart"
click node_histogram "https://github.com/filiph/unsure/blob/master/lib/src/histogram.dart"
click node_formatter "https://github.com/filiph/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,node_api,node_user toneBlue
class node_range,node_parser,node_ast,node_calculation_run,node_normal toneAmber
class node_result,node_histogram,node_formatter toneMint
```

## Components

### User entrypoints

- [Command-line tool](https://github.com/filiph/unsure/blob/master/bin/unsure.dart): `bin/unsure.dart`
- [Browser calculator](https://github.com/filiph/unsure/tree/master/example): `example`
- [Package API](https://github.com/filiph/unsure/blob/master/lib/unsure.dart): `lib/unsure.dart`

### Calculation engine

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

### Results and statistics

- [Calculation result](https://github.com/filiph/unsure/blob/master/lib/src/result.dart): `lib/src/result.dart`
- [Result histogram](https://github.com/filiph/unsure/blob/master/lib/src/histogram.dart): `lib/src/histogram.dart`
- [Result formatter](https://github.com/filiph/unsure/blob/master/lib/src/formatter.dart): `lib/src/formatter.dart`

### Other components

- **Calculator user**

## Connections

- Calculator user → Command-line tool: runs formula (evidence: `README.md`)
- Calculator user → Browser calculator: uses calculator (evidence: `README.md`)
- Calculator user → Package API: uses package (evidence: `README.md`)
- Package API → Monte Carlo calculation: runs calculation (evidence: `README.md`)
- Monte Carlo calculation → Uncertain range: samples ranges (evidence: `README.md`)
- Monte Carlo calculation → Calculation result: returns result (evidence: `README.md`)
- Calculation result → Result histogram: exposes histogram (evidence: `README.md`)
- Calculation result → Result formatter: exposes summary (evidence: `README.md`)
