# mpusz/mp-units architecture

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

- Interactive diagram: https://gitdiagram.com/mpusz/mp-units
- Repository: https://github.com/mpusz/mp-units

## Overview

##### Project type and purpose
- This is an open-source, header-only and compiled Modern C++ library (“mp-units”) that provides compile-time dimensional analysis and unit/quantity manipulation.
- It is intended to be used as a dependency in C++20/C++23 projects via CMake and Conan. It also includes examples, tests, and documentation.

##### File structure
- Top-level components:
- src/ — library implementation, subdivided into core/ (fundamental templates and algorithms) and systems/ (unit definitions for SI, CGS, IEC, etc.).
- example/ — sample applications showing library usage and integration.
- test/ — two test suites: runtime/ (unit tests executed at run-time) and static/ (compile-time tests).
- docs/, mkdocs.yml — documentation source for MkDocs / GitHub Pages.
- cmake/, conanfile.py — build and packaging support modules.
- .github/workflows/ — CI pipelines for build, tests, formatting, static analysis, documentation.
- Configuration files: CMakeLists.txt at root and in subfolders, Conan profile in .gitpod, pre-commit, formatting rules.

##### README for additional insights
- Confirms the library’s core focus on zero-overhead, type-safe unit arithmetic.
- Mentions integration points (Compiler Explorer, Gitpod), packaging (ConanCenter), and CI statuses.
- Points to API reference, user guide, and blog posts—indicative of heavy documentation.

##### Final recommendations
- Every major module and its dependencies without over-splitting trivial files.
- Flows: development flow (edit → commit → CI → publish) and consumer flow (Conan install → include → compile).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Repository and CI
    Repo["Repository (mp-units)"]:::external
    CI["GitHub Actions"]:::external
    Repo -->|push triggers| CI

    subgraph "Source Code" 
        direction TB
        Core["Core Module"]:::library
        CoreHdr["Core Headers"]:::library
        CoreImpl["Core Implementation"]:::library
        Sys["Systems Module"]:::library
        SysHdr["Systems Headers"]:::library
        SysImpl["Systems Implementation"]:::library

        Core --> CoreHdr
        Core --> CoreImpl
        Sys --> SysHdr
        Sys --> SysImpl
    end

    subgraph "Build & Packaging"
        direction TB
        CMakeRoot[(CMakeLists.txt)]:::build
        CMakeMod[(cmake/)]:::build
        ConanFile[(conanfile.py)]:::build
        ConanProf[(.gitpod/conan/profiles/)]:::build
    end

    Repo -->|defines build| CMakeRoot
    Repo --> CMakeMod
    Repo -->|defines package| ConanFile
    Repo --> ConanProf

    CI --> CMakeRoot
    CI --> ConanFile

    Core -->|headers to CMake| CMakeRoot
    Sys -->|headers to CMake| CMakeRoot

    subgraph "Artifacts" 
        direction TB
        CoreArt["mp-units-core"]:::artifact
        SysArt["mp-units-systems"]:::artifact
    end

    CMakeRoot -->|build| CoreArt
    CMakeRoot -->|build| SysArt
    ConanFile -->|package| CoreArt
    ConanFile -->|package| SysArt

    subgraph Tests
        direction TB
        RT["Runtime Tests"]:::library
        ST["Static Tests"]:::library
    end

    CoreArt -->|link| RT
    SysArt -->|link| RT
    CoreArt -->|compile-time validate| ST
    SysArt -->|compile-time validate| ST

    Examples["Examples"]:::library
    CoreArt -->|link| Examples
    SysArt -->|link| Examples

    subgraph "Documentation"
        direction TB
        MkCfg["mkdocs.yml"]:::build
        DocsSrc["docs/"]:::build
        DocGen["MkDocs Generator"]:::build
        GHPages["GitHub Pages"]:::external
    end

    Repo --> MkCfg
    Repo --> DocsSrc
    MkCfg --> DocGen
    DocsSrc --> DocGen
    DocGen --> GHPages

    subgraph "External Services"
        direction TB
        ConanCenter["ConanCenter"]:::external
        GitpodSvc["Gitpod"]:::external
    end

    CoreArt --> ConanCenter
    SysArt --> ConanCenter
    Repo --> GitpodSvc

    subgraph "Consumers"
        direction TB
        Consumer["C++ Projects"]:::external
    end

    Consumer -->|conan install & include| CoreArt
    Consumer -->|conan install & include| SysArt

    %% Click events
    click Core "https://github.com/mpusz/mp-units/tree/master/src/core/"
    click CoreHdr "https://github.com/mpusz/mp-units/tree/master/src/core/include/mp-units/"
    click CoreImpl "https://github.com/mpusz/mp-units/blob/master/src/core/mp-units-core.cpp"
    click Sys "https://github.com/mpusz/mp-units/tree/master/src/systems/"
    click SysHdr "https://github.com/mpusz/mp-units/tree/master/src/systems/include/mp-units/systems/"
    click SysImpl "https://github.com/mpusz/mp-units/blob/master/src/systems/mp-units-systems.cpp"
    click CMakeRoot "https://github.com/mpusz/mp-units/blob/master/CMakeLists.txt"
    click CMakeMod "https://github.com/mpusz/mp-units/tree/master/cmake/"
    click ConanFile "https://github.com/mpusz/mp-units/blob/master/conanfile.py"
    click ConanProf "https://github.com/mpusz/mp-units/tree/master/.gitpod/conan/profiles/"
    click RT "https://github.com/mpusz/mp-units/tree/master/test/runtime/"
    click ST "https://github.com/mpusz/mp-units/tree/master/test/static/"
    click Examples "https://github.com/mpusz/mp-units/tree/master/example/"
    click MkCfg "https://github.com/mpusz/mp-units/blob/master/mkdocs.yml"
    click DocsSrc "https://github.com/mpusz/mp-units/tree/master/docs/"
    click CI "https://github.com/mpusz/mp-units/tree/master/.github/workflows/"
    click GitpodSvc "https://github.com/mpusz/mp-units/tree/master/.gitpod/"

    %% Styles
    classDef library fill:#D0E7FF,stroke:#0366D6,color:#0366D6
    classDef build fill:#F0F0F0,stroke:#888888,color:#333333
    classDef artifact fill:#DFFFE0,stroke:#228B22,color:#228B22
    classDef external fill:#FFF8DC,stroke:#DAA520,color:#DAA520
```
