# martincostello/dotnet-8-samples architecture

> Architecture diagram of the GitHub repository martincostello/dotnet-8-samples, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/martincostello/dotnet-8-samples
- Repository: https://github.com/martincostello/dotnet-8-samples

## Overview

##### Project type and purpose
- This repository is a collection of .NET 8 sample applications and libraries used to demonstrate new language features (C# 12) and platform capabilities (TimeProvider abstraction, ASP.NET Core Weather API).
- There is no single “production” system here; instead, we have three self-contained samples:
- CSharp12 – a console app showcasing C# 12 syntax samples
- TimeProvider – a class library plus its xUnit test project (TimeProvider.Tests)
- WeatherApi – an ASP.NET Core Web API sample illustrating HTTP clients, configuration, and launch profiles

##### File structure
- Top-level security & configuration:
- global.json – pins .NET SDK to version 8
- Directory.Build.* and Directory.Packages.props – centralize MSBuild settings and NuGet versions
- build.ps1 – orchestrates a full solution build via MSBuild/dotnet CLI
- src folder: three sub-projects, each with its own .csproj
- CSharp12 (console)
- TimeProvider (class library)
- WeatherApi (ASP.NET Core web API) with appsettings.json and launchSettings.json for local debugging
- tests folder: TimeProvider.Tests – an xUnit test project referencing TimeProvider
- .github/workflows/build.yml – CI pipeline that restores, builds, tests

##### README for additional insights
- Confirms this is a samples repo for a .NET 8 talk.
- Instructs how to clone & build via build.ps1.
- Mentions no production deployment; the focus is on code samples.

a. Main components
1. Solution build orchestrator (build.ps1 / dotnet CLI / GitHub Actions)
2. CSharp12 console application
3. TimeProvider class library
4. TimeProvider.Tests (xUnit test suite)
5. WeatherApi ASP.NET Core Web API
6. External Weather HTTP endpoint (represented by forecast.http sample)

b. Relationships & interactions
- The solution file (.sln) ties together all three projects.
- build.ps1 (and GitHub Actions) invokes dotnet restore/build/test on the solution.
- TimeProvider.Tests references TimeProvider → run under test runner.
- WeatherApi at runtime reads appsettings.json, uses HttpClient to call external weather API (forecast.http).
- global.json ensures all projects build on .NET 8 SDK.

c. Architectural patterns & principles
- Separation of concerns: console app / library / web API / tests are all isolated projects
- Centralized configuration: Directory.Build.props for MSBuild settings, appsettings.json for runtime config
- Conventional layering: Library (TimeProvider) sits under test harness; Web API is a thin wrapper calling external services

d. Key technologies & frameworks
- .NET 8 SDK & SDK-style csproj
- MSBuild central props/targets
- xUnit for unit tests
- ASP.NET Core Web API
- JSON-based configuration (appsettings.json, httpenv.json)
- GitHub Actions for CI (build.yml)

##### Essential detail callouts
- Appsettings.json & launchSettings.json under WeatherApi.
- That CSharp12 is purely illustrative (no external dependencies).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Build and CI
    subgraph "Build & CI" 
        direction TB
        BS(["build.ps1"]):::script
        CI([".github/workflows/build.yml"]):::script
    end

    %% Solution and Config
    Solution(["dotnet-8-samples.sln"]):::solution

    subgraph "Centralized Configuration" 
        direction TB
        GJSON(["global.json"]):::config
        DBPROPS(["Directory.Build.props"]):::config
        DBTARGS(["Directory.Build.targets"]):::config
        DBPACK(["Directory.Packages.props"]):::config
        NUGET(["NuGet.config"]):::config
        EDITOR([".editorconfig"]):::config
        GITIGNORE([".gitignore"]):::config
        README(["README.md"]):::config
    end

    %% Projects
    subgraph "Projects"
        direction TB
        C1(["CSharp12\n(Console App)"]):::app
        TP(["TimeProvider\n(Class Library)"]):::library
        TT(["TimeProvider.Tests\n(xUnit Test)"]):::test
        WA(["WeatherApi\n(Web API)"]):::app
    end

    %% External Service
    subgraph "External Weather Service"
        direction TB
        ExtSvc(["External Weather HTTP Service"]):::external
        FH(["forecast.http"]):::artifact
        HE(["httpenv.json"]):::artifact
    end

    %% Edges
    BS -->|"invokes build on"| Solution
    CI -->|"CI pipeline runs"| Solution

    GJSON --> Solution
    DBPROPS --> Solution
    DBTARGS --> Solution
    DBPACK --> Solution
    NUGET --> Solution
    EDITOR --> Solution
    GITIGNORE --> Solution
    README --> Solution

    Solution --> C1
    Solution --> TP
    Solution --> TT
    Solution --> WA

    TT -->|"references"| TP
    WA -->|"calls external API"| ExtSvc
    ExtSvc --> FH
    ExtSvc --> HE

    %% Click events
    click BS "https://github.com/martincostello/dotnet-8-samples/blob/main/build.ps1"
    click CI "https://github.com/martincostello/dotnet-8-samples/blob/main/.github/workflows/build.yml"
    click GJSON "https://github.com/martincostello/dotnet-8-samples/blob/main/global.json"
    click DBPROPS "https://github.com/martincostello/dotnet-8-samples/blob/main/Directory.Build.props"
    click DBTARGS "https://github.com/martincostello/dotnet-8-samples/blob/main/Directory.Build.targets"
    click DBPACK "https://github.com/martincostello/dotnet-8-samples/blob/main/Directory.Packages.props"
    click NUGET "https://github.com/martincostello/dotnet-8-samples/blob/main/NuGet.config"
    click EDITOR "https://github.com/martincostello/dotnet-8-samples/blob/main/.editorconfig"
    click GITIGNORE "https://github.com/martincostello/dotnet-8-samples/blob/main/.gitignore"
    click README "https://github.com/martincostello/dotnet-8-samples/blob/main/README.md"
    click C1 "https://github.com/martincostello/dotnet-8-samples/tree/main/src/CSharp12"
    click C1 "https://github.com/martincostello/dotnet-8-samples/blob/main/src/CSharp12/CSharp12.csproj"
    click C1 "https://github.com/martincostello/dotnet-8-samples/blob/main/src/CSharp12/CollectionExpressions.cs"
    click C1 "https://github.com/martincostello/dotnet-8-samples/blob/main/src/CSharp12/PrimaryConstructors.cs"
    click C1 "https://github.com/martincostello/dotnet-8-samples/blob/main/src/CSharp12/Program.cs"
    click TP "https://github.com/martincostello/dotnet-8-samples/tree/main/src/TimeProvider"
    click TP "https://github.com/martincostello/dotnet-8-samples/blob/main/src/TimeProvider/TimeProvider.csproj"
    click TP "https://github.com/martincostello/dotnet-8-samples/blob/main/src/TimeProvider/EggTimer.cs"
    click TP "https://github.com/martincostello/dotnet-8-samples/blob/main/src/TimeProvider/PaydayCalculator.cs"
    click TT "https://github.com/martincostello/dotnet-8-samples/blob/main/tests/TimeProvider.Tests"
    click TT "https://github.com/martincostello/dotnet-8-samples/blob/main/tests/TimeProvider.Tests/TimeProvider.Tests.csproj"
    click TT "https://github.com/martincostello/dotnet-8-samples/blob/main/tests/TimeProvider.Tests/TimeTests.cs"
    click WA "https://github.com/martincostello/dotnet-8-samples/tree/main/src/WeatherApi"
    click WA "https://github.com/martincostello/dotnet-8-samples/blob/main/src/WeatherApi/WeatherApi.csproj"
    click WA "https://github.com/martincostello/dotnet-8-samples/blob/main/src/WeatherApi/Program.cs"
    click WA "https://github.com/martincostello/dotnet-8-samples/blob/main/src/WeatherApi/appsettings.json"
    click WA "https://github.com/martincostello/dotnet-8-samples/blob/main/src/WeatherApi/Properties/launchSettings.json"
    click FH "https://github.com/martincostello/dotnet-8-samples/blob/main/src/WeatherApi/forecast.http"
    click HE "https://github.com/martincostello/dotnet-8-samples/blob/main/src/WeatherApi/httpenv.json"
    click Solution "https://github.com/martincostello/dotnet-8-samples/blob/main/dotnet-8-samples.sln"

    %% Styles
    classDef script fill:#A2D2FF,stroke:#0366D6,color:#000;
    classDef solution fill:#B8FFF9,stroke:#008080,color:#000;
    classDef config fill:#E9FFB8,stroke:#A2A200,color:#000;
    classDef app fill:#B8FFC8,stroke:#006400,color:#000;
    classDef library fill:#FFF3B8,stroke:#A67C00,color:#000;
    classDef test fill:#FFC8A2,stroke:#D2691E,color:#000;
    classDef external fill:#D3D3D3,stroke:#696969,color:#000;
    classDef artifact fill:#E0E0E0,stroke:#A9A9A9,color:#000;
```
