# lk-code/fluent-data-builder architecture

> Architecture diagram of the GitHub repository lk-code/fluent-data-builder, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lk-code/fluent-data-builder
- Repository: https://github.com/lk-code/fluent-data-builder

## Overview

##### Project type and purpose
- This is a .NET class‑library ecosystem (“FluentDataBuilder”) that provides a fluent API for constructing hierarchical data objects (JSON, XML, YAML, IConfiguration).
- It consists of a core module (DataBuilder), multiple extension modules (Json, NewtonsoftJson, Xml, Yaml, Microsoft.Extensions.Configuration), test suites, and a documentation site built with static assets.

##### File structure
- Top‑level “source” directory:
- Core library: FluentDataBuilder (IDataBuilder, DataBuilder.cs, DictionaryExtensions helper)
- Extension libraries: FluentDataBuilder.Json, FluentDataBuilder.NewtonsoftJson, FluentDataBuilder.Xml, FluentDataBuilder.Yaml, FluentDataBuilder.Microsoft.Extensions.Configuration
- Test projects: FluentDataBuilder.Tests and module‑specific tests under FluentDataBuilder.ExtensionTests & Microsoft.Extensions.Configuration.Tests
- Solution file (.sln) organizes all projects
- “docs” folder: a static site with HTML, CSS, JS, assets, built and deployed via GitHub workflows
- CI: GitHub Actions workflows for .NET builds, testing, NuGet packaging, and docs publishing

##### README for additional insights
- Describes purpose: fluent builders for different output targets
- Lists NuGet packages, usage examples, calling patterns (builder.Add(...))

a. Main components
1. Core DataBuilder module (IDataBuilder interface, DataBuilder implementation)
2. Extension modules (Json, NewtonsoftJson, Xml, Yaml, Configuration)
3. Consumer code (user applications or libraries that reference FluentDataBuilder packages)
4. Test suites (unit tests for core and extensions)
5. Documentation site generator (static assets + build pipeline)
6. CI/CD pipelines (GitHub Actions) and NuGet feed / GitHub Pages

b. Relationships and interactions
- Consumer code → references Core and one or more Extension modules → calls IDataBuilder.Add() → Build() or ToConfiguration()
- Extension modules → depend on Core module
- Test projects → depend on Core and respective Extension modules
- CI pipeline → checks out code → builds all projects → runs all tests → packages NuGet artifacts → publishes packages → builds docs → deploys to GitHub Pages

c. Architectural patterns and design principles
- Modular plugin‑style design: Core defines the IDataBuilder contract; each extension implements output serialization
- Single responsibility: Core only manages in‑memory structure; serialization concerns are pushed to extensions
- Convention over configuration: Add‑method chaining in fluent style

d. Key technologies, frameworks, libraries
- .NET 8.0 class libraries and SDK-style projects
- System.Text.Json, Newtonsoft.Json, System.Xml, YamlDotNet, Microsoft.Extensions.Configuration
- xUnit or MSTest for unit tests
- GitHub Actions for CI/CD
- Static site assets (Bootstrap, FontAwesome) for documentation

##### Detailed component breakdown
- Core Library Node:
- IDataBuilder (interface)
- DataBuilder (implementation)
- DictionaryExtensions (helper)
- Extension Module Nodes (one per package): show their package name and principal class (DataBuilderExtensions)
- Test Suite Nodes: link to the modules they test
- Docs Site Node: static assets → HTML output → GitHub Pages
- CI/CD Pipeline Node: GitHub Actions (dotnet.yml, pull-request.yml, github‑pages.yml)

##### Final advice
- Don’t obscure small modules—capture each extension separately.
- Flow of data: “builder.Build() → JSON / XML / YAML / IConfiguration”
- Publishing steps: “dotnet pack → NuGet.org” and “docs build → GitHub Pages.”
- Keep the layout logical: Core in center, Extensions around it, Consumer at top, Tests below, CI/CD at side.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Consumer
    Consumer["Consumer Application"]:::consumer

    %% Core Library
    subgraph "Core Library"
        direction TB
        idb["IDataBuilder"]:::library
        db["DataBuilder"]:::library
        dictExt["DictionaryExtensions"]:::library
        coreProj["FluentDataBuilder.csproj"]:::library
    end

    %% Extension Modules
    subgraph "Extension: Json"
        direction TB
        jsonExt["DataBuilderExtensions"]:::library
        jsonProj["FluentDataBuilder.Json.csproj"]:::library
    end

    subgraph "Extension: NewtonsoftJson"
        direction TB
        newtonExt["DataBuilderExtensions"]:::library
        newtonProj["FluentDataBuilder.NewtonsoftJson.csproj"]:::library
    end

    subgraph "Extension: Xml"
        direction TB
        xmlExt["DataBuilderExtensions"]:::library
        xmlProj["FluentDataBuilder.Xml.csproj"]:::library
    end

    subgraph "Extension: Yaml"
        direction TB
        yamlExt["DataBuilderExtensions"]:::library
        yamlProj["FluentDataBuilder.Yaml.csproj"]:::library
    end

    subgraph "Extension: Configuration"
        direction TB
        configExt["DataBuilderExtensions"]:::library
        configProj["FluentDataBuilder.Microsoft.Extensions.Configuration.csproj"]:::library
    end

    %% Test Suites
    subgraph "Test Projects"
        direction TB
        coreTests["Core Tests"]:::test
        sharedTests["Shared Tests"]:::test
        extTests["Extension Tests"]:::test
        configTests["Configuration Tests"]:::test
    end

    %% Documentation Site
    Docs["Documentation Site (Static)"]:::docs

    %% CI/CD Pipeline
    CICD["CI/CD: GitHub Actions"]:::cicd
    NuGet["NuGet.org"]:::cicd
    GHPages["GitHub Pages"]:::cicd

    %% Relationships
    Consumer -->|uses| idb
    Consumer -->|uses| jsonExt
    Consumer -->|uses| newtonExt
    Consumer -->|uses| xmlExt
    Consumer -->|uses| yamlExt
    Consumer -->|uses| configExt

    idb -->|implemented by| db
    idb -->|helper| dictExt
    db -->|packaged in| coreProj

    db -->|extension dependency| jsonExt
    db -->|extension dependency| newtonExt
    db -->|extension dependency| xmlExt
    db -->|extension dependency| yamlExt
    db -->|extension dependency| configExt

    jsonExt -->|packaged in| jsonProj
    newtonExt -->|packaged in| newtonProj
    xmlExt -->|packaged in| xmlProj
    yamlExt -->|packaged in| yamlProj
    configExt -->|packaged in| configProj

    coreTests -->|tests| db
    coreTests -->|tests| dictExt
    sharedTests -->|supports| coreTests

    extTests -->|tests| jsonExt
    extTests -->|tests| newtonExt
    extTests -->|tests| xmlExt
    extTests -->|tests| yamlExt

    configTests -->|tests| configExt

    CICD -->|build & test| coreProj
    CICD -->|build & test| jsonProj
    CICD -->|build & test| newtonProj
    CICD -->|build & test| xmlProj
    CICD -->|build & test| yamlProj
    CICD -->|build & test| configProj
    CICD -->|run tests| coreTests
    CICD -->|run tests| extTests
    CICD -->|run tests| configTests
    CICD -->|publish packages| NuGet
    CICD -->|build docs| Docs
    CICD -->|deploy docs| GHPages

    %% Click Events: Core
    click idb "https://github.com/lk-code/fluent-data-builder/blob/main/source/FluentDataBuilder/IDataBuilder.cs"
    click db "https://github.com/lk-code/fluent-data-builder/blob/main/source/FluentDataBuilder/DataBuilder.cs"
    click dictExt "https://github.com/lk-code/fluent-data-builder/blob/main/source/FluentDataBuilder/Helper/DictionaryExtensions.cs"
    click coreProj "https://github.com/lk-code/fluent-data-builder/blob/main/source/FluentDataBuilder/FluentDataBuilder.csproj"

    %% Click Events: Extensions
    click jsonExt "https://github.com/lk-code/fluent-data-builder/blob/main/source/FluentDataBuilder.Json/DataBuilderExtensions.cs"
    click jsonProj "https://github.com/lk-code/fluent-data-builder/blob/main/source/FluentDataBuilder.Json/FluentDataBuilder.Json.csproj"
    click newtonExt "https://github.com/lk-code/fluent-data-builder/blob/main/source/FluentDataBuilder.NewtonsoftJson/DataBuilderExtensions.cs"
    click newtonProj "https://github.com/lk-code/fluent-data-builder/blob/main/source/FluentDataBuilder.NewtonsoftJson/FluentDataBuilder.NewtonsoftJson.csproj"
    click xmlExt "https://github.com/lk-code/fluent-data-builder/blob/main/source/FluentDataBuilder.Xml/DataBuilderExtensions.cs"
    click xmlProj "https://github.com/lk-code/fluent-data-builder/blob/main/source/FluentDataBuilder.Xml/FluentDataBuilder.Xml.csproj"
    click yamlExt "https://github.com/lk-code/fluent-data-builder/blob/main/source/FluentDataBuilder.Yaml/DataBuilderExtensions.cs"
    click yamlProj "https://github.com/lk-code/fluent-data-builder/blob/main/source/FluentDataBuilder.Yaml/FluentDataBuilder.Yaml.csproj"
    click configExt "https://github.com/lk-code/fluent-data-builder/blob/main/source/FluentDataBuilder.Microsoft.Extensions.Configuration/DataBuilderExtensions.cs"
    click configProj "https://github.com/lk-code/fluent-data-builder/blob/main/source/FluentDataBuilder.Microsoft.Extensions.Configuration/FluentDataBuilder.Microsoft.Extensions.Configuration.csproj"

    %% Click Events: Tests
    click coreTests "https://github.com/lk-code/fluent-data-builder/blob/main/source/FluentDataBuilder.Tests/FluentDataBuilder.Tests.csproj"
    click sharedTests "https://github.com/lk-code/fluent-data-builder/blob/main/source/FluentDataBuilder.TestsShared/FluentDataBuilder.TestsShared.csproj"
    click extTests "https://github.com/lk-code/fluent-data-builder/blob/main/source/FluentDataBuilder.ExtensionTests/FluentDataBuilder.ExtensionTests.csproj"
    click configTests "https://github.com/lk-code/fluent-data-builder/blob/main/source/FluentDataBuilder.Microsoft.Extensions.Configuration.Tests/FluentDataBuilder.Microsoft.Extensions.Configuration.Tests.csproj"

    %% Click Events: Docs
    click Docs "https://github.com/lk-code/fluent-data-builder/blob/main/docs/src/index.html"

    %% Click Events: CI/CD
    click CICD "https://github.com/lk-code/fluent-data-builder/blob/main/.github/workflows/dotnet.yml"
    click CICD "https://github.com/lk-code/fluent-data-builder/blob/main/.github/workflows/pull-request.yml"
    click CICD "https://github.com/lk-code/fluent-data-builder/blob/main/.github/workflows/github-pages.yml"

    %% Styles
    classDef library fill:#cce5ff,stroke:#004085,color:#004085
    classDef consumer fill:#d4edda,stroke:#155724,color:#155724
    classDef test fill:#fff3cd,stroke:#856404,color:#856404
    classDef docs fill:#e2e3e5,stroke:#383d41,color:#383d41
    classDef cicd fill:#f5e6ff,stroke:#5e1169,color:#5e1169
```
