# co-it/csharpfunctionalextensions.httpresults architecture

> Architecture diagram of the GitHub repository co-it/csharpfunctionalextensions.httpresults, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/co-it/csharpfunctionalextensions.httpresults
- Repository: https://github.com/co-it/csharpfunctionalextensions.httpresults

## Overview

##### Main Components Identification
The system consists of three primary components:
- Core Library
- Source Generator
- Example/Test Projects

##### Specific Elements

a) Core Library Section:
**[Result Extensions]**

- ToStatusCodeHttpResult
- ToJsonHttpResult
- ToOkHttpResult
- Other HTTP Result Types

b) Generator Section:
**[Source Generator]**

- Templates
- Result<T,E>
- UnitResult<E>

- Rules
- DuplicateMapperRule
- EmptyMapGetterRule

c) Error Handling Flow:
**[Custom Error] ──► [Error Mapper] ──► [HTTP Result]**

##### Additional Details

- The relationship between custom errors and their mappers
- The source generation process
- How the Result types map to HTTP results

##### Notes for Implementation

- Keep the abstraction level high enough to show the architecture but detailed enough to understand the flow
- Version information and supported .NET versions
- Notes about the RFC compliance for ProblemDetails

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Core["Core Library"]
        RE["Result Extensions"]
        IRM["IResultErrorMapper Interface"]
        PDM["ProblemDetailsMap"]
        RE --> IRM
        RE --> PDM
    end

    subgraph Generator["Source Generator"]
        REG["ResultExtensionsGenerator"]
        BLD["Builders"]
        RUL["Rules"]
        TMP["Extension Templates"]
        REG --> BLD
        REG --> RUL
        REG --> TMP
    end

    subgraph Consumer["Consumer Layer"]
        EX["Example API"]
        subgraph Examples["Example Features"]
            CE["Custom Error Example"]
            BE["Books API Example"]
        end
        TEST["Test Projects"]
        subgraph Tests["Test Suites"]
            CLT["Core Library Tests"]
            GT["Generator Tests"]
        end
        EX --> Examples
        TEST --> Tests
    end

    CSharpFE["CSharpFunctionalExtensions"]:::external

    Generator -.->|Generates| Core
    Core --> CSharpFE
    Consumer --> Core
    Consumer -.-> Generator

    %% Click events for component mapping
    click RE "https://github.com/co-IT/CSharpFunctionalExtensions.HttpResults/tree/main/CSharpFunctionalExtensions.HttpResults/ResultExtensions/"
    click IRM "https://github.com/co-IT/CSharpFunctionalExtensions.HttpResults/blob/main/CSharpFunctionalExtensions.HttpResults/IResultErrorMapper.cs"
    click PDM "https://github.com/co-IT/CSharpFunctionalExtensions.HttpResults/blob/main/CSharpFunctionalExtensions.HttpResults/ProblemDetailsMap.cs"
    click REG "https://github.com/co-IT/CSharpFunctionalExtensions.HttpResults/blob/main/CSharpFunctionalExtensions.HttpResults.Generators/ResultExtensionsGenerator.cs"
    click BLD "https://github.com/co-IT/CSharpFunctionalExtensions.HttpResults/tree/main/CSharpFunctionalExtensions.HttpResults.Generators/Builders/"
    click RUL "https://github.com/co-IT/CSharpFunctionalExtensions.HttpResults/tree/main/CSharpFunctionalExtensions.HttpResults.Generators/Rules/"
    click TMP "https://github.com/co-IT/CSharpFunctionalExtensions.HttpResults/tree/main/CSharpFunctionalExtensions.HttpResults.Generators/ResultExtensions/"
    click EX "https://github.com/co-IT/CSharpFunctionalExtensions.HttpResults/tree/main/CSharpFunctionalExtensions.HttpResults.Examples/"
    click CE "https://github.com/co-IT/CSharpFunctionalExtensions.HttpResults/tree/main/CSharpFunctionalExtensions.HttpResults.Examples/Features/CustomError/"
    click BE "https://github.com/co-IT/CSharpFunctionalExtensions.HttpResults/tree/main/CSharpFunctionalExtensions.HttpResults.Examples/Features/Books/"
    click CLT "https://github.com/co-IT/CSharpFunctionalExtensions.HttpResults/tree/main/CSharpFunctionalExtensions.HttpResults.Tests/"
    click GT "https://github.com/co-IT/CSharpFunctionalExtensions.HttpResults/tree/main/CSharpFunctionalExtensions.HttpResults.Generators.Tests/"

    %% Styling
    classDef core fill:#a8d1f0,stroke:#333
    classDef generator fill:#90EE90,stroke:#333
    classDef consumer fill:#f5f5f5,stroke:#333
    classDef external fill:#FFB366,stroke:#333

    class RE,IRM,PDM core
    class REG,BLD,RUL,TMP generator
    class EX,CE,BE,TEST,CLT,GT consumer
    class CSharpFE external

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Generator Components]:::generator
        L3[Consumer Components]:::consumer
        L4[External Dependencies]:::external
        L5["---> Direct Dependency"]
        L6["--> Generation Flow"]
    end
```
