# tartanllama/expected architecture

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

- Interactive diagram: https://gitdiagram.com/tartanllama/expected
- Repository: https://github.com/tartanllama/expected

## Overview

##### Main Components

a) Core Component:
- The single header file `expected.hpp` which contains the entire implementation
- This as the central component of the system

b) External Dependencies:
- Standard C++ Library components
- Assert mechanism (configurable through TL_ASSERT macro)

c) Testing Framework:
- The comprehensive test suite in the `tests` directory
- Build system (CMake)

- ┌─────────────────────────────────────┐
- tl::expected<T,E>         │

- ┌─────────────┐    ┌─────────────┐ │
- Value     │    │    Error    │ │
- Type (T)  │    │  Type (E)   │ │
- ┘    └─────────────┘ │
- ┘

##### Specific details

**┌─────────────────────────────────────────────────┐**
- Build & Package System             │
- ┌─────────┐  ┌─────────┐       ┌──────────┐   │
- CMake  │  │ Vcpkg   │       │  Conan   │   │
- ┘  └─────────┘       └──────────┘   │
- ┘

**┌─────────────────────────────────────────────────┐**
- tl::expected<T,E>                  │

- ┌─────────────┐         ┌──────────────────┐  │
- Value State │         │   Error State    │  │
- ┘         └──────────────────┘  │

- ┌─────────────────────────────────────────┐   │
- Functional Extensions           │   │
- ● map()        ● and_then()           │   │
- ● map_error()  ● or_else()            │   │
- ┘   │
- ┘

**┌─────────────────────────────────────────────────┐**
- Test Suite                      │
- ┌────────────┐  ┌────────────┐  ┌──────────┐  │
- Unit Tests │  │  Constexpr │  │ NoExcept │  │
- ┘  └────────────┘  └──────────┘  │
- ┘

##### Important Notes

- Keep the focus on the template implementation and its functional extensions
- Single-header nature of the library
- Relationship between the core implementation and the test suite
- Build system integration points
- Demonstrate the error handling flow through the functional extensions

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core["Core Implementation"]
        Expected["tl::expected<T,E>"]:::core
        ValueType["Value Type (T)"]:::core
        ErrorType["Error Type (E)"]:::core
        Expected --> ValueType
        Expected --> ErrorType

        subgraph Extensions["Functional Extensions"]
            Map["map()"]:::func
            MapError["map_error()"]:::func
            AndThen["and_then()"]:::func
            OrElse["or_else()"]:::func
        end

        Expected --> Map
        Expected --> MapError
        Expected --> AndThen
        Expected --> OrElse
    end

    subgraph Testing["Testing Framework"]
        Constexpr["Constexpr Tests"]:::test
        NoExcept["NoExcept Tests"]:::test
        FuncTests["Functional Tests"]:::test
        ConstructorTests["Constructor Tests"]:::test
        AssignmentTests["Assignment Tests"]:::test
        ObserverTests["Observer Tests"]:::test
        SwapTests["Swap Operations"]:::test
        RelOpTests["Relational Operations"]:::test
    end

    subgraph Build["Build & Package System"]
        CMake["CMake Configuration"]:::build
        VcPkg["Vcpkg Support"]:::build
        Conan["Conan Support"]:::build
    end

    subgraph CI["CI/CD Integration"]
        GHActions["GitHub Actions"]:::ci
        AppVeyor["AppVeyor"]:::ci
        Travis["Travis CI"]:::ci
    end

    Expected --> Testing
    Build --> Testing
    CI --> Build

    %% Click events for component mapping
    click Expected "https://github.com/TartanLlama/expected/blob/master/include/tl/expected.hpp"
    click Constexpr "https://github.com/TartanLlama/expected/blob/master/tests/constexpr.cpp"
    click NoExcept "https://github.com/TartanLlama/expected/blob/master/tests/noexcept.cpp"
    click FuncTests "https://github.com/TartanLlama/expected/blob/master/tests/extensions.cpp"
    click ConstructorTests "https://github.com/TartanLlama/expected/blob/master/tests/constructors.cpp"
    click AssignmentTests "https://github.com/TartanLlama/expected/blob/master/tests/assignment.cpp"
    click ObserverTests "https://github.com/TartanLlama/expected/blob/master/tests/observers.cpp"
    click SwapTests "https://github.com/TartanLlama/expected/blob/master/tests/swap.cpp"
    click RelOpTests "https://github.com/TartanLlama/expected/blob/master/tests/relops.cpp"
    click CMake "https://github.com/TartanLlama/expected/blob/master/CMakeLists.txt"
    click GHActions "https://github.com/TartanLlama/expected/blob/master/.github/workflows/cmake.yml"
    click AppVeyor "https://github.com/TartanLlama/expected/blob/master/.appveyor.yml"
    click Travis "https://github.com/TartanLlama/expected/blob/master/.travis.yml"

    %% Styling
    classDef core fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef func fill:#90EE90,stroke:#333
    classDef test fill:#DDA0DD,stroke:#333
    classDef build fill:#FFA500,stroke:#333
    classDef ci fill:#D3D3D3,stroke:#333

    %% Legend
    subgraph Legend
        CoreLegend["Core Components"]:::core
        FuncLegend["Functional Components"]:::func
        TestLegend["Test Components"]:::test
        BuildLegend["Build Components"]:::build
        CILegend["CI/CD Components"]:::ci
    end
```
