[AZ-312] [AZ-313] [AZ-314] Split Services into per-component csprojs

Phase B of architecture coupling refactor (epic AZ-309). Replaces
the monolithic SatelliteProvider.Services with three per-component
csprojs to add a compiler-enforced module boundary (resolves F4):

- SatelliteProvider.Services.TileDownloader
- SatelliteProvider.Services.RegionProcessing
- SatelliteProvider.Services.RouteManagement

DI registrations relocated into per-component AddTileDownloader /
AddRegionProcessing / AddRouteManagement extension methods called
from Program.cs. RateLimitException moved to Common/Exceptions/ to
keep the three new csprojs as siblings (no Region->TileDownloader
ProjectReference). Dockerfiles and consumer csprojs (Api, Tests)
rewired to the new project paths. No DI lifetime or hosted-service
order changes.

Build: 0 warn, 0 err. Unit tests: 40/40. Smoke integration: green.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-05-10 07:15:44 +03:00
parent 12b582deac
commit 8b0ddae075
30 changed files with 330 additions and 46 deletions
+3 -1
View File
@@ -8,7 +8,9 @@ WORKDIR /src
COPY ["SatelliteProvider.Api/SatelliteProvider.Api.csproj", "SatelliteProvider.Api/"]
COPY ["SatelliteProvider.Common/SatelliteProvider.Common.csproj", "SatelliteProvider.Common/"]
COPY ["SatelliteProvider.DataAccess/SatelliteProvider.DataAccess.csproj", "SatelliteProvider.DataAccess/"]
COPY ["SatelliteProvider.Services/SatelliteProvider.Services.csproj", "SatelliteProvider.Services/"]
COPY ["SatelliteProvider.Services.TileDownloader/SatelliteProvider.Services.TileDownloader.csproj", "SatelliteProvider.Services.TileDownloader/"]
COPY ["SatelliteProvider.Services.RegionProcessing/SatelliteProvider.Services.RegionProcessing.csproj", "SatelliteProvider.Services.RegionProcessing/"]
COPY ["SatelliteProvider.Services.RouteManagement/SatelliteProvider.Services.RouteManagement.csproj", "SatelliteProvider.Services.RouteManagement/"]
RUN dotnet restore "SatelliteProvider.Api/SatelliteProvider.Api.csproj"
COPY . .
WORKDIR "/src/SatelliteProvider.Api"
+7 -15
View File
@@ -7,7 +7,9 @@ using SatelliteProvider.DataAccess.Repositories;
using SatelliteProvider.Common.Configs;
using SatelliteProvider.Common.DTO;
using SatelliteProvider.Common.Interfaces;
using SatelliteProvider.Services;
using SatelliteProvider.Services.RegionProcessing;
using SatelliteProvider.Services.RouteManagement;
using SatelliteProvider.Services.TileDownloader;
using Serilog;
var builder = WebApplication.CreateBuilder(args);
@@ -27,9 +29,10 @@ builder.Services.AddSingleton<IRegionRepository>(sp => new RegionRepository(conn
builder.Services.AddSingleton<IRouteRepository>(sp => new RouteRepository(connectionString, sp.GetRequiredService<ILogger<RouteRepository>>()));
builder.Services.AddHttpClient();
builder.Services.AddMemoryCache();
builder.Services.AddSingleton<ISatelliteDownloader, GoogleMapsDownloaderV2>();
builder.Services.AddSingleton<ITileService, TileService>();
builder.Services.AddTileDownloader();
builder.Services.AddRegionProcessing();
builder.Services.AddRouteManagement();
var allowedOrigins = builder.Configuration.GetSection("CorsConfig:AllowedOrigins").Get<string[]>() ?? Array.Empty<string>();
builder.Services.AddCors(options =>
@@ -43,17 +46,6 @@ builder.Services.AddCors(options =>
});
});
var processingConfig = builder.Configuration.GetSection("ProcessingConfig").Get<ProcessingConfig>() ?? new ProcessingConfig();
builder.Services.AddSingleton<IRegionRequestQueue>(sp =>
{
var logger = sp.GetRequiredService<ILogger<RegionRequestQueue>>();
return new RegionRequestQueue(processingConfig.QueueCapacity, logger);
});
builder.Services.AddSingleton<IRegionService, RegionService>();
builder.Services.AddHostedService<RegionProcessingService>();
builder.Services.AddSingleton<IRouteService, RouteService>();
builder.Services.AddHostedService<RouteProcessingService>();
builder.Services.ConfigureHttpJsonOptions(options =>
{
options.SerializerOptions.PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase;
@@ -18,7 +18,9 @@
<ItemGroup>
<ProjectReference Include="..\SatelliteProvider.Common\SatelliteProvider.Common.csproj" />
<ProjectReference Include="..\SatelliteProvider.DataAccess\SatelliteProvider.DataAccess.csproj" />
<ProjectReference Include="..\SatelliteProvider.Services\SatelliteProvider.Services.csproj" />
<ProjectReference Include="..\SatelliteProvider.Services.TileDownloader\SatelliteProvider.Services.TileDownloader.csproj" />
<ProjectReference Include="..\SatelliteProvider.Services.RegionProcessing\SatelliteProvider.Services.RegionProcessing.csproj" />
<ProjectReference Include="..\SatelliteProvider.Services.RouteManagement\SatelliteProvider.Services.RouteManagement.csproj" />
</ItemGroup>
</Project>