What I have learned by building .NET Stars -part 3- Aspire

I have that same idea to build a project : is what is called today a Modular Monolith – and it is very old in .NET world as can be implemented as a .sln solution.
For those unfamiliar, a Modular Monolith allows you to break down your application into independent modules (think database access, data flow logic, a sleek UI), yet keep them tightly integrated within a single, cohesive solution.

It’s how all these components can work together seamlessly. This idea resonated with me when I started thinking about my project. So, let me break it down:

Interfaces for Data/Flow These lay the foundation, ensuring that data and operations flow smoothly between different parts of the project.
  
– A database stores all the necessary information, serving as the backbone of my application.

– Then there’s the WebAPI, which acts like a messenger, transferring data between the database and the users’ interfaces.

– And finally, for the User Interface, I’ve chosen Blazor. It brings together code, design, and interactivity i

Aspire is a game-changer in the .NET world, offering a simple yet powerful way to coordinate multiple projects. By starting an app host with all the projects intertwined, it simplifies the process of building complex applications.  More, Aspire let me coordinate another project to save the data on Blazor – but this will be discussed in another blog post later .

I have had just 2 modifications to make it work flawlessly :

1. Blazor

  To know the address of the WebAPI to obtain the data ( once published, Blazor will be near the WebAPI in the wwwroot, but until then it needs the adress )

Blazor can have the configuration stored in a appsettings.json in the wwwroot – but how to write ? I developed an extension for ASPIRE in order to write the data

2. Database

In order to have the database with data , I need to write scripts for create table / insert the data.

This code shows how

var paramPass = builder.AddParameter("password", "P@ssw0rd");

var sqlserver = builder.AddSqlServer("sqlserver",paramPass,1433)
    //.WithArgs("pwd","&","ls")
    // Mount the init scripts directory into the container.
    .WithBindMount("./sqlserverconfig", "/usr/config")
    // Mount the SQL scripts directory into the container so that the init scripts run.
    .WithBindMount("../../Scripts/data/sqlserver", "/docker-entrypoint-initdb.d")
    // Run the custom entrypoint script on startup.
    .WithEntrypoint("/usr/config/entrypoint.sh")
    // Configure the container to store data in a volume so that it persists across instances.
    .WithDataVolume() 
    // Keep the container running between app host sessions.
    .WithLifetime(ContainerLifetime.Persistent)

    ;
var db= sqlserver.AddDatabase("DotNetStats");

Also , I have an .gitattributes that contains

* text=auto
*.sh text eol=lf
*.mod text eol=lf
*.sum text eol=lf

in order for the .sh files to maintain linux ending.

You can see at https://ignatandrei.github.io/dotnetstats/ and the source code at http://github.com/ignatandrei/dotnetstats/