Skip to content

Commit 061de42

Browse files
authored
Aspire 9 - minimal first version (#43)
Allow people to use Aspire App host to play with the app and maybe contribute * Aspire 9 first version
1 parent 80d63a4 commit 061de42

File tree

24 files changed

+463
-133
lines changed

24 files changed

+463
-133
lines changed

README.md

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
LAST BIG PR implemented:
1+
# News
22

3-
- double-entry preparation
4-
- 2 new backend apis (tx and sales-or-vat-tax)
5-
- Blazor better token management
3+
LAST PR implemented:
64

7-
Next steps between:
5+
- Aspire 9.0 (very minimal implementation without service discovery or test project)
6+
- Now, you can run the apphost project and have fun
87

9-
- vat-sales tax module implementation
8+
Next steps or in progress:
9+
10+
- Vat-sales tax module implementation
1011
- .Net 9 (Blazor adaptations)
1112
- SingalR hub to trace tx status
1213
- Blazor double-entry ui
13-
- Aspire (re-test the thing)
14+
- Aspire, enhance service defaults and see for discovery and maybe tests project
1415
- will see...
1516

1617
# Ubik - Accounting
@@ -21,7 +22,7 @@ A .net8 project to manage double entry accounting. (it's the very beginning of a
2122

2223
Microservices arch and supports multi-tenants.
2324

24-
But for now, it's an experimental project that references a lot of things about .net 8 - Backend and Frontend sides of things -.
25+
But for now, it's an experimental project that references a lot of things about .net 8 (9 soon) - Backend and Frontend sides of things -.
2526

2627
## Not ready for production
2728

@@ -30,11 +31,23 @@ At this stage, **DO NOT USE THIS SYSTEM ON A PRODUCTION** environnement.
3031
- **Don't forget to change all the "secrets" exposed here, and in the configuration files.**
3132
- **Never re-use the Keycloak realm configuration file.**
3233

33-
## For the Kubernetes/Minikube guys
34+
# Run - Debug
35+
36+
Choose between section 1), 2) or 3)
37+
38+
## 1) For the Aspire guys
39+
40+
You can run all the stuff with the host project:
41+
42+
`dotnet run --project .\src\Ubik.AppHost\Ubik.AppHost.csproj`
3443

35-
For detailed instructions on deploying locally with Minikube (full experience), please refer to the [local deployment guide](./deploy/deploy-local-readme.md).
44+
Or, in Visual Studio, you can set the Aspire Host project as project startup and you will be able to play/debug with all the dependencies.
3645

37-
## Build and Run
46+
## 2) For the Kubernetes/Minikube guys
47+
48+
For detailed instructions on deploying locally with Minikube, please refer to the [local deployment guide](./deploy/deploy-local-readme.md).
49+
50+
## 3) For the Docker guys
3851

3952
**At the root of the repository**, "Mount" the dependencies with Docker by running this command in your terminal:
4053

@@ -49,9 +62,7 @@ For detailed instructions on deploying locally with Minikube (full experience),
4962
> - Pgadmin: to admin your dbs if needed
5063
> - Apis: backend apis (security/accounting) for integration testing
5164
52-
### Ready to play and debug
53-
54-
#### Run backend Apis or define a multiple projects startup
65+
#### Run backend Apis or define a multiple projects startup to debug
5566

5667
`dotnet run --launch-profile https --project ./src/Ubik.Accounting.SalesOrVatTax.Api/Ubik.Accounting.SalesOrVatTax.Api.csproj`
5768

@@ -69,9 +80,13 @@ For detailed instructions on deploying locally with Minikube (full experience),
6980

7081
`dotnet run --launch-profile https --project ./src/Ubik.Accounting.WebApp/Ubik.Accounting.WebApp.csproj`
7182

72-
And now (when all the stuff are up and running), you can access the very first version of a the Blazor 8 webapp here <https://localhost:7249>
83+
## For All
84+
85+
After choosing your prefered way 1), 2) 3) you can access the Blazor app here:
7386

74-
### All the things are up
87+
<https://localhost:7249>
88+
89+
# All the things are up
7590

7691
If you try to access the Blazor app, you will be redirected on a Keycloak login page
7792

@@ -89,6 +104,12 @@ Try to log with different access rights and play with the only available "Accoun
89104

90105
Now you can run your preferred code editor and start to deep dive... (see below)
91106

107+
# Integration tests
108+
109+
If you want to contribute, see section "3) For the Docker guys" to be able to mount the dependencies and run the integration tests project. No time to update to Aspire Test and change all the related stuff (github actions etc.).
110+
111+
At the end, simply run `docker compose -f .\docker-compose.yml -f .\docker-integration-tests.yml up -d`, and you will be able to run the tests project.
112+
92113
## External libs
93114

94115
| Package | For what |
@@ -100,6 +121,8 @@ Now you can run your preferred code editor and start to deep dive... (see below)
100121
| [LanguageExt.Core](https://github.com/louthy/language-ext) | use Either<Left, Right> pattern |
101122
| [Masstransit](https://github.com/MassTransit/MassTransit) | message bus abstraction + inbox/outbox pattern |
102123

124+
Send some love on github to this projects...
125+
103126
## Yarp Proxy
104127

105128
-- Ubik.YarpProxy --
@@ -150,15 +173,11 @@ First you can maybe uncomment this lines in Ubik.Accounting.WebApp.csproj, if yo
150173
</Target>
151174
```
152175

153-
I don't know why, but my build fails in Github actions if I let this Tailwind instructions (related to the forms plugin). If someone has an idea...
154-
`EXEC : error : Cannot find module '@tailwindcss/forms'`
155-
156176
**To use Tailwind in DEV**, you need to have node installed, Tailwind and Tailwind forms... I let you go on their site for installation instructions. Maybe, `npm install` command can be sufficient in the WebApp (server) project, cannot be sure because it seems to trigger a weird error in the dotnet build github actions.
157177

158178
| Package | For what |
159179
|----------- | -------- |
160180
| [BalzorPageScript](https://github.com/MackinnonBuck/blazor-page-script) | small tool that allows Tailwind to apply its Dark or Light theme on each page and component |
161-
| [IdentityModel](https://github.com/IdentityModel) | Small extension to refresh token in OpenIdC |
162181

163182
Send some love on github to this projects...
164183

@@ -167,29 +186,19 @@ Send some love on github to this projects...
167186
(server side)
168187

169188
- Static components and pages
170-
- Typed HttpClient to access the backend api
171-
- Tailwind config - Tailwind Flowbite design layout etc
172189
- A very minimal reverse proxy controller that allows components (automode) to call the backend api when they are WASM.
173190
- Some stuff about security (Token cache service)
174191

175-
In program.cs, you can access the config of:
176-
177-
- Redis for token caching
178-
- CascadingAuthenticationState
179-
- Cookie auth with OpenIdC (connection + refresh token in OnValidatePrincipal)
180-
- ...
181-
182192
=> next, implement new .Net 9 Blazor stuff related to authentication and render modes.
183193

184194
### Ubik.Accounting.WebApp.Client
185195

186196
(client-auto side)
187197

188-
- All components are able to run in auto mode (InteractiveServer or InteractiveWasm)
198+
- **All components are able to run in auto mode (InteractiveServer or InteractiveWasm)**
189199
- Authorization components (depending on authorized state)
190200
- Minimal common components (Alerts, Buttons, Form Inputs, Grid *(Microsoft inspired/copied)*, Modal, Spinners)
191201
- Tailwind Flowbite design for components
192-
- The implementation of the facade that call the reverse proxy controller that call the Backend api for automode
193202
- Error components that manage problemdetails returns from backend api (try to add a booking account with an existing code as an example)
194203

195204
### Ubik.Accounting.WebApp.Shared
@@ -203,7 +212,7 @@ In program.cs, you can access the config of:
203212

204213
-- Ubik.Accounting.Api.Tests.Integration --
205214

206-
- In integration tests => test all proxy endpoints
215+
- In integration tests => test all proxy endpoints
207216

208217
## Others
209218

src/Ubik.Accounting.SalesOrVatTax.Api/Program.cs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
var builder = WebApplication.CreateBuilder(args);
2121

22+
builder.AddServiceDefaults();
23+
2224
//Options
2325
var authOptions = new AuthServerOptions();
2426
builder.Configuration.GetSection(AuthServerOptions.Position).Bind(authOptions);
@@ -27,14 +29,15 @@
2729
var swaggerUIOptions = new SwaggerUIOptions();
2830
builder.Configuration.GetSection(SwaggerUIOptions.Position).Bind(swaggerUIOptions);
2931

30-
//Default httpclient
31-
builder.Services.ConfigureHttpClientDefaults(http =>
32-
{
33-
http.AddStandardResilienceHandler();
34-
});
32+
//Default httpclient - Aspire now
33+
//builder.Services.ConfigureHttpClientDefaults(http =>
34+
//{
35+
// http.AddStandardResilienceHandler();
36+
//});
3537

3638
builder.Services.AddDbContextFactory<AccountingSalesTaxDbContext>(
3739
options => options.UseNpgsql(builder.Configuration.GetConnectionString("AccountingSalesTaxDbContext")), ServiceLifetime.Scoped);
40+
builder.EnrichNpgsqlDbContext<AccountingSalesTaxDbContext>();
3841

3942
Dapper.DefaultTypeMap.MatchNamesWithUnderscores = true;
4043

@@ -79,14 +82,14 @@
7982
//TODO: Cors
8083
builder.Services.AddCustomCors();
8184

82-
//Tracing and metrics
83-
builder.Logging.AddOpenTelemetry(logging =>
84-
{
85-
logging.IncludeFormattedMessage = true;
86-
logging.IncludeScopes = true;
87-
});
85+
//Tracing and metrics
86+
//builder.Logging.AddOpenTelemetry(logging =>
87+
//{
88+
// logging.IncludeFormattedMessage = true;
89+
// logging.IncludeScopes = true;
90+
//});
8891

89-
builder.Services.AddTracingAndMetrics();
92+
//builder.Services.AddTracingAndMetrics();
9093

9194
//Swagger config
9295
var xmlPath = Path.Combine(AppContext.BaseDirectory,
@@ -113,7 +116,6 @@
113116
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()));
114117

115118
builder.Services.AddHttpContextAccessor();
116-
builder.Services.AddEndpointsApiExplorer();
117119

118120
//Route config
119121
builder.Services.Configure<RouteOptions>(options =>
@@ -128,6 +130,8 @@
128130

129131
var app = builder.Build();
130132

133+
app.MapDefaultEndpoints();
134+
131135
app.UseExceptionHandler(app.Logger, app.Environment);
132136

133137
// Configure the HTTP request pipeline.

src/Ubik.Accounting.SalesOrVatTax.Api/Ubik.Accounting.SalesOrVatTax.Api.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
<ItemGroup>
1717
<PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0" />
1818
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
19+
<PackageReference Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.2.2" />
1920
<PackageReference Include="Dapper" Version="2.1.35" />
2021
<PackageReference Include="EFCore.NamingConventions" Version="8.0.3" />
2122
<PackageReference Include="LanguageExt.Core" Version="4.4.9" />
22-
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.10.0" />
2323
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
2424
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.10" />
2525
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.0.0" />
@@ -33,6 +33,7 @@
3333
<ProjectReference Include="..\Ubik.Accounting.Transaction.Contracts\Ubik.Accounting.Transaction.Contracts.csproj" />
3434
<ProjectReference Include="..\Ubik.ApiService.Common\Ubik.ApiService.Common.csproj" />
3535
<ProjectReference Include="..\Ubik.Db.Common\Ubik.DB.Common\Ubik.DB.Common.csproj" />
36+
<ProjectReference Include="..\Ubik.ServiceDefaults\Ubik.ServiceDefaults.csproj" />
3637
</ItemGroup>
3738

3839
<ItemGroup>

src/Ubik.Accounting.Structure.Api/Program.cs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class Program
2626
public static async Task Main(string[] args)
2727
{
2828
var builder = WebApplication.CreateBuilder(args);
29+
builder.AddServiceDefaults();
2930

3031
//Log
3132
//TODO: Begin to log usefull things
@@ -42,11 +43,11 @@ public static async Task Main(string[] args)
4243
//Auth server and JWT (no need, no auth)
4344
//builder.Services.AddAuthServerAndJwt(authOptions);
4445

45-
//Default httpclient
46-
builder.Services.ConfigureHttpClientDefaults(http =>
47-
{
48-
http.AddStandardResilienceHandler();
49-
});
46+
////Default httpclient - Aspire now
47+
//builder.Services.ConfigureHttpClientDefaults(http =>
48+
//{
49+
// http.AddStandardResilienceHandler();
50+
//});
5051

5152
//DB
5253
builder.Services.AddDbContextFactory<AccountingDbContext>(
@@ -102,14 +103,14 @@ public static async Task Main(string[] args)
102103
//TODO: Cors
103104
builder.Services.AddCustomCors();
104105

105-
//Tracing and metrics
106-
builder.Logging.AddOpenTelemetry(logging =>
107-
{
108-
logging.IncludeFormattedMessage = true;
109-
logging.IncludeScopes = true;
110-
});
106+
////Tracing and metrics - Aspire now
107+
//builder.Logging.AddOpenTelemetry(logging =>
108+
//{
109+
// logging.IncludeFormattedMessage = true;
110+
// logging.IncludeScopes = true;
111+
//});
111112

112-
builder.Services.AddTracingAndMetrics();
113+
//builder.Services.AddTracingAndMetrics();
113114

114115
//Swagger config
115116
var xmlPath = Path.Combine(AppContext.BaseDirectory,
@@ -149,7 +150,10 @@ public static async Task Main(string[] args)
149150
//Build the app
150151
var app = builder.Build();
151152

152-
app.MapPrometheusScrapingEndpoint();
153+
//Build the app
154+
app.MapDefaultEndpoints();
155+
156+
//app.MapPrometheusScrapingEndpoint();
153157
//app.UseSerilogRequestLogging();
154158
app.UseExceptionHandler(app.Logger, app.Environment);
155159

src/Ubik.Accounting.Structure.Api/Ubik.Accounting.Structure.Api.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
<PrivateAssets>all</PrivateAssets>
3737
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3838
</PackageReference>
39-
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.10.0" />
4039
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
4140
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.10" />
4241
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
@@ -46,6 +45,7 @@
4645
<ItemGroup>
4746
<ProjectReference Include="..\Ubik.Accounting.Structure.Contracts\Ubik.Accounting.Structure.Contracts.csproj" />
4847
<ProjectReference Include="..\Ubik.Db.Common\Ubik.DB.Common\Ubik.DB.Common.csproj" />
48+
<ProjectReference Include="..\Ubik.ServiceDefaults\Ubik.ServiceDefaults.csproj" />
4949
</ItemGroup>
5050

5151
<ItemGroup>

0 commit comments

Comments
 (0)