Refactor solution structure and add RabbitMQ config

Reorganized the solution structure to align with a layered architecture:
- Replaced `src` folder with `core`, `infrastructure`, and `presentation`.
- Moved projects to their respective folders.
- Added `DigitalData.MessagingService.Publisher.Abstraction` project.
- Removed `DigitalData.MessagingService.Client` project.

Updated project configurations and nesting in the solution file.

Added `appsettings.Secrets.json` with RabbitMQ and email account settings:
- RabbitMQ configuration includes hostname, port, credentials, and queue/exchange details.
- Email configuration includes SMTP server details and credentials.
This commit is contained in:
2026-07-28 10:26:15 +02:00
parent 2ad2dc6b4d
commit 78c82bf129
40 changed files with 67 additions and 40 deletions

View File

@@ -0,0 +1,87 @@
using DigitalData.MessagingService.API.Middleware;
using DigitalData.MessagingService.Application;
using DigitalData.MessagingService.Application.Common.Dtos;
using DigitalData.MessagingService.Infrastructure;
using Serilog;
// Configure Serilog early
Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.WriteTo.File(
path: "logs/emailprofiler-.log",
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: 30,
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}")
.CreateBootstrapLogger();
try
{
Log.Information("Starting MessagingService API");
var builder = WebApplication.CreateBuilder(args);
// Use Serilog for logging
builder.Host.UseSerilog((context, services, configuration) => configuration
.ReadFrom.Configuration(context.Configuration)
.ReadFrom.Services(services)
.Enrich.FromLogContext()
.WriteTo.Console()
.WriteTo.File(
path: "logs/emailprofiler-.log",
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: 30,
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}"));
// Add appsettings.Secrets.json for sensitive configuration (not committed to git)
builder.Configuration.AddJsonFile("appsettings.Secrets.json", optional: true, reloadOnChange: true);
// Register Application layer (MediatR, AutoMapper, FluentValidation)
builder.Services.AddApplicationServices(builder.Configuration);
// Register Infrastructure layer (RabbitMQ, Repositories, etc.)
builder.Services.AddInfrastructure(builder.Configuration);
// Register EmailAccount configuration (IOptions<EmailAccountDto>)
builder.Services.Configure<EmailAccountDto>(
builder.Configuration.GetSection("EmailAccount"));
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Add global exception handling middleware
app.UseMiddleware<ExceptionHandlingMiddleware>();
// Add Serilog request logging
app.UseSerilogRequestLogging();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
Log.Information("MessagingService API started successfully");
app.Run();
}
catch (Exception ex)
{
Log.Fatal(ex, "MessagingService API failed to start");
throw;
}
finally
{
Log.CloseAndFlush();
}