# terraar/medida architecture

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

- Interactive diagram: https://gitdiagram.com/terraar/medida
- Repository: https://github.com/terraar/medida

## Overview

medida is a small C++ library for values paired with measurement error. Users create measurements, apply arithmetic or mathematical functions, optionally derive measurements and errors from arrays or files, then print results. The public header declares the type and API; the implementation contains the calculations and I/O. File-based statistics visibly delegate to stream-based statistics, which in turn use array-based calculations. The excerpts are partial, so the graph groups related implementation responsibilities without claiming unseen call paths.

Main entry points: [`medida.h`](https://github.com/terraar/medida/blob/master/medida.h) (Measurement API), [`medida.cpp`](https://github.com/terraar/medida/blob/master/medida.cpp) (Array statistics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Public interface"]
  node_api["Measurement API<br/>[medida.h]"]
end

subgraph group_operations["Measurement operations"]
  node_arithmetic["Arithmetic operators<br/>[medida.cpp]"]
  node_math["Math functions<br/>[medida.cpp]"]
end

subgraph group_statistics["Statistical input"]
  node_array_stats["Array statistics<br/>[medida.cpp]"]
  node_stream_stats["Stream statistics<br/>[medida.cpp]"]
  node_file_stats["Named-file statistics<br/>[medida.cpp]"]
end

subgraph group_presentation["Output"]
  node_printing["Measurement output<br/>[medida.cpp]"]
end

node_user(("Library user"))

node_user -->|"uses"| node_api
node_arithmetic -->|"implements"| node_api
node_math -->|"implements"| node_api
node_array_stats -->|"returns measurements"| node_api
node_stream_stats -->|"delegates to"| node_array_stats
node_file_stats -->|"delegates to"| node_stream_stats
node_printing -->|"formats measurements"| node_api

click node_api "https://github.com/terraar/medida/blob/master/medida.h"
click node_arithmetic "https://github.com/terraar/medida/blob/master/medida.cpp"
click node_math "https://github.com/terraar/medida/blob/master/medida.cpp"
click node_array_stats "https://github.com/terraar/medida/blob/master/medida.cpp"
click node_stream_stats "https://github.com/terraar/medida/blob/master/medida.cpp"
click node_file_stats "https://github.com/terraar/medida/blob/master/medida.cpp"
click node_printing "https://github.com/terraar/medida/blob/master/medida.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_api,node_user toneBlue
class node_arithmetic,node_math toneAmber
class node_array_stats,node_stream_stats,node_file_stats toneMint
class node_printing toneRose
```

## Components

### Public interface

- [Measurement API](https://github.com/terraar/medida/blob/master/medida.h): `medida.h`

### Measurement operations

- [Arithmetic operators](https://github.com/terraar/medida/blob/master/medida.cpp): `medida.cpp`
- [Math functions](https://github.com/terraar/medida/blob/master/medida.cpp): `medida.cpp`

### Statistical input

- [Array statistics](https://github.com/terraar/medida/blob/master/medida.cpp): `medida.cpp`
- [Stream statistics](https://github.com/terraar/medida/blob/master/medida.cpp): `medida.cpp`
- [Named-file statistics](https://github.com/terraar/medida/blob/master/medida.cpp): `medida.cpp`

### Output

- [Measurement output](https://github.com/terraar/medida/blob/master/medida.cpp): `medida.cpp`

### Other components

- **Library user**

## Connections

- Library user → Measurement API: uses (evidence: `README.md`)
- Arithmetic operators → Measurement API: implements (evidence: `medida.cpp`)
- Math functions → Measurement API: implements (evidence: `medida.cpp`)
- Array statistics → Measurement API: returns measurements (evidence: `medida.cpp`)
- Stream statistics → Array statistics: delegates to (evidence: `medida.cpp`)
- Named-file statistics → Stream statistics: delegates to (evidence: `medida.cpp`)
- Measurement output → Measurement API: formats measurements (evidence: `medida.cpp`)
