mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-14 17:54:42 +00:00
Move Infrastructure.FileUpload into Features.PhotoUpload (#290)
This commit is contained in:
@@ -91,7 +91,6 @@ flowchart TB
|
||||
I1["Database.Connection"]
|
||||
I3["Infrastructure.PasswordHashing"]
|
||||
I4["Email.Templates"]
|
||||
I5["Infrastructure.FileUpload"]
|
||||
end
|
||||
|
||||
DB[("Database (SQL Server)")]
|
||||
@@ -166,8 +165,7 @@ brewery photo upload command) rather than bound to an HTTP route directly.
|
||||
- `Domain.Entities`, `Domain.Exceptions`
|
||||
- `Database.Connection` (generic ADO.NET connection/command plumbing) plus
|
||||
whichever infrastructure project the slice needs (`Infrastructure.PasswordHashing`
|
||||
for Users, `Infrastructure.Email.Templates` for
|
||||
Emails, `Infrastructure.FileUpload` for PhotoUpload)
|
||||
for Users, `Infrastructure.Email.Templates` for Emails)
|
||||
- `Shared.Contracts`, `Shared.Application`
|
||||
- No other `Features.*` project, with two exceptions: `Features.Users`
|
||||
references `Features.PhotoUpload` directly for avatar uploads, and
|
||||
@@ -209,7 +207,6 @@ whichever slices need them
|
||||
| `Database.Connection` | Generic ADO.NET connection/command plumbing (`DefaultSqlConnectionFactory`, the abstract `DapperRepository` base class), not domain-specific; each slice's own `Repository/` folder builds on this. |
|
||||
| `Infrastructure.PasswordHashing` | Argon2id password hashing. |
|
||||
| `Infrastructure.Email.Templates` | Email template rendering (Razor components). |
|
||||
| `Infrastructure.FileUpload` | `IFileStorageProvider` abstraction over S3-compatible object storage, implemented by `S3FileStorageProvider` (targets the SeaweedFS container in dev; any S3-compatible endpoint in other environments) using the AWS SDK's `AmazonS3Client` with `ForcePathStyle = true`. |
|
||||
|
||||
**Dependencies**:
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ see the notes for what else each of those foundation projects pulls in.
|
||||
- `Domain.Exceptions` (referenced by nearly every project directly, including
|
||||
all of `Shared.Contracts` and each feature slice)
|
||||
- `Infrastructure.Configuration` (the shared options-binding project
|
||||
referenced by `Database.Connection`, `Infrastructure.FileUpload`,
|
||||
referenced by `Database.Connection`, `Features.PhotoUpload`,
|
||||
and `Features.Emails` directly)
|
||||
- both are plumbing-level dependencies of nearly everything above, and drawing
|
||||
them would just add a second copy of the same fan-in
|
||||
|
||||
@@ -24,7 +24,6 @@ end
|
||||
subgraph INFRA["Slice-specific Infrastructure"]
|
||||
direction LR
|
||||
PwdHash["Infrastructure.PasswordHashing"]
|
||||
FileUpload["Infrastructure.FileUpload"]
|
||||
EmailTemplates["Infrastructure.Email.Templates"]
|
||||
end
|
||||
|
||||
@@ -33,7 +32,7 @@ EmailsSlice == project ref, handles UserRegisteredNotification & ConfirmationEma
|
||||
BrewerySlice --> FOUNDATION
|
||||
LocationsSlice --> FOUNDATION
|
||||
BeersSlice --> FOUNDATION
|
||||
PhotoSlice --> FOUNDATION & FileUpload
|
||||
PhotoSlice --> FOUNDATION
|
||||
UsersSlice --> FOUNDATION & PwdHash
|
||||
EmailsSlice --> EmailTemplates
|
||||
DBConn -- Dapper SQL, no ORM --> Tables[("SQL Server<br>Tables")]
|
||||
|
||||
@@ -255,8 +255,8 @@ SMTP_FROM_NAME=The Biergarten App # Optional, defaults to "The Biergarten
|
||||
|
||||
### File storage configuration (backend)
|
||||
|
||||
Read by `Infrastructure.FileUpload/S3FileStorageProvider.cs` for uploading and
|
||||
retrieving photos via an S3-compatible object store.
|
||||
Read by `Features.PhotoUpload/Services/S3FileStorageProvider.cs` for uploading
|
||||
and retrieving photos via an S3-compatible object store.
|
||||
|
||||
```bash
|
||||
SEAWEEDFS_SERVICE_URL=http://seaweedfs:8333 # Required, no default
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
<ProjectReference Include="..\..\Domain\Domain.Exceptions\Domain.Exceptions.csproj" />
|
||||
<ProjectReference Include="..\..\Database\Database.Connection\Database.Connection.csproj" />
|
||||
<ProjectReference Include="..\..\Infrastructure\Infrastructure.Configuration\Infrastructure.Configuration.csproj" />
|
||||
<ProjectReference Include="..\..\Infrastructure\Infrastructure.FileUpload\Infrastructure.FileUpload.csproj" />
|
||||
<ProjectReference Include="..\..\Features\Features.Breweries\Features.Breweries.csproj" />
|
||||
<ProjectReference Include="..\..\Features\Features.Users\Features.Users.csproj" />
|
||||
<ProjectReference Include="..\..\Features\Features.Emails\Features.Emails.csproj" />
|
||||
|
||||
@@ -34,7 +34,6 @@ COPY ["Features/Features.PhotoUpload.Tests/Features.PhotoUpload.Tests.csproj", "
|
||||
COPY ["Features/Features.Users/Features.Users.csproj", "Features/Features.Users/"]
|
||||
COPY ["Features/Features.Users.Tests/Features.Users.Tests.csproj", "Features/Features.Users.Tests/"]
|
||||
COPY ["Infrastructure/Infrastructure.Configuration/Infrastructure.Configuration.csproj", "Infrastructure/Infrastructure.Configuration/"]
|
||||
COPY ["Infrastructure/Infrastructure.FileUpload/Infrastructure.FileUpload.csproj", "Infrastructure/Infrastructure.FileUpload/"]
|
||||
COPY ["Shared/Shared.Application/Shared.Application.csproj", "Shared/Shared.Application/"]
|
||||
COPY ["Shared/Shared.Contracts/Shared.Contracts.csproj", "Shared/Shared.Contracts/"]
|
||||
RUN dotnet restore "Biergarten.API.slnx"
|
||||
|
||||
@@ -12,7 +12,6 @@ using Features.Users.Controllers;
|
||||
using Features.Users.DependencyInjection;
|
||||
using FluentValidation;
|
||||
using FluentValidation.AspNetCore;
|
||||
using Infrastructure.FileUpload;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Shared.Application.Behaviors;
|
||||
|
||||
@@ -103,9 +102,7 @@ internal static class ServiceCollectionExtensions
|
||||
.AddFeaturesLocations();
|
||||
|
||||
public IServiceCollection AddCoreInfrastructure() =>
|
||||
services
|
||||
.AddSingleton<IFileStorageProvider, S3FileStorageProvider>()
|
||||
.AddScoped<GlobalExceptionFilter>();
|
||||
services.AddScoped<GlobalExceptionFilter>();
|
||||
|
||||
public IServiceCollection AddJwtAuthentication()
|
||||
{
|
||||
|
||||
@@ -24,7 +24,6 @@ COPY ["Features/Features.PhotoUpload.Tests/Features.PhotoUpload.Tests.csproj", "
|
||||
COPY ["Features/Features.Users/Features.Users.csproj", "Features/Features.Users/"]
|
||||
COPY ["Features/Features.Users.Tests/Features.Users.Tests.csproj", "Features/Features.Users.Tests/"]
|
||||
COPY ["Infrastructure/Infrastructure.Configuration/Infrastructure.Configuration.csproj", "Infrastructure/Infrastructure.Configuration/"]
|
||||
COPY ["Infrastructure/Infrastructure.FileUpload/Infrastructure.FileUpload.csproj", "Infrastructure/Infrastructure.FileUpload/"]
|
||||
COPY ["Shared/Shared.Application/Shared.Application.csproj", "Shared/Shared.Application/"]
|
||||
COPY ["Shared/Shared.Contracts/Shared.Contracts.csproj", "Shared/Shared.Contracts/"]
|
||||
RUN dotnet restore "Biergarten.API.slnx"
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
</Folder>
|
||||
<Folder Name="/Infrastructure/">
|
||||
<Project Path="Infrastructure/Infrastructure.Configuration/Infrastructure.Configuration.csproj" />
|
||||
<Project Path="Infrastructure/Infrastructure.FileUpload/Infrastructure.FileUpload.csproj" />
|
||||
</Folder>
|
||||
<Folder Name="/Features/" />
|
||||
<Folder Name="/Features/Users/">
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
<ProjectReference Include="..\..\Features\Features.Users\Features.Users.csproj" />
|
||||
<ProjectReference Include="..\..\Features\Features.Locations\Features.Locations.csproj" />
|
||||
<ProjectReference Include="..\..\Features\Features.PhotoUpload\Features.PhotoUpload.csproj" />
|
||||
<ProjectReference Include="..\..\Infrastructure\Infrastructure.FileUpload\Infrastructure.FileUpload.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None
|
||||
|
||||
@@ -10,7 +10,6 @@ using Features.Locations.Queries.GetCountry;
|
||||
using Features.Users.Commands.Profile.UploadAvatar;
|
||||
using Features.Users.DependencyInjection;
|
||||
using Features.Users.Services;
|
||||
using Infrastructure.FileUpload;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -31,7 +30,6 @@ internal class Program
|
||||
.AddFeaturesLocations()
|
||||
.AddFeaturesUsers()
|
||||
.AddFeaturesPhotoUpload()
|
||||
.AddSingleton<IFileStorageProvider, S3FileStorageProvider>()
|
||||
.AddScoped<ITokenService, NoOpTokenService>()
|
||||
.AddMediatR(cfg =>
|
||||
cfg.RegisterServicesFromAssemblyContaining<CreateBreweryCommand>()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Domain.Entities;
|
||||
using Features.ImageUploads.Commands.UploadPhoto;
|
||||
using Features.ImageUploads.Repository;
|
||||
using Features.ImageUploads.Services;
|
||||
using FluentAssertions;
|
||||
using Infrastructure.FileUpload;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Moq;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Domain.Entities;
|
||||
using Features.ImageUploads.Repository;
|
||||
using Infrastructure.FileUpload;
|
||||
using Features.ImageUploads.Services;
|
||||
using MediatR;
|
||||
|
||||
namespace Features.ImageUploads.Commands.UploadPhoto;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Features.ImageUploads.Repository;
|
||||
using Features.ImageUploads.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Features.ImageUploads.DependencyInjection;
|
||||
@@ -6,11 +7,16 @@ namespace Features.ImageUploads.DependencyInjection;
|
||||
/// <summary>Registers the services required by the PhotoUpload feature.</summary>
|
||||
public static class FeaturesPhotoUploadServiceCollectionExtensions
|
||||
{
|
||||
/// <summary>Registers <see cref="IPhotoUploadRepository" /> and its implementation.</summary>
|
||||
/// <summary>
|
||||
/// Registers <see cref="IPhotoUploadRepository" /> and <see cref="IFileStorageProvider" /> and their
|
||||
/// implementations.
|
||||
/// </summary>
|
||||
/// <returns><paramref name="services" />, for chaining.</returns>
|
||||
public static IServiceCollection AddFeaturesPhotoUpload(this IServiceCollection services)
|
||||
{
|
||||
services.AddScoped<IPhotoUploadRepository, PhotoUploadRepository>();
|
||||
services
|
||||
.AddScoped<IPhotoUploadRepository, PhotoUploadRepository>()
|
||||
.AddSingleton<IFileStorageProvider, S3FileStorageProvider>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,19 @@
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AWSSDK.S3" Version="4.0.102.4" />
|
||||
<PackageReference
|
||||
Include="Microsoft.Extensions.Configuration.Abstractions"
|
||||
Version="10.0.1"
|
||||
/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Domain\Domain.Entities\Domain.Entities.csproj" />
|
||||
<ProjectReference Include="..\..\Domain\Domain.Exceptions\Domain.Exceptions.csproj" />
|
||||
<ProjectReference Include="..\..\Database\Database.Connection\Database.Connection.csproj" />
|
||||
<ProjectReference Include="..\..\Infrastructure\Infrastructure.FileUpload\Infrastructure.FileUpload.csproj" />
|
||||
<ProjectReference Include="..\..\Infrastructure\Infrastructure.Configuration\Infrastructure.Configuration.csproj" />
|
||||
<ProjectReference Include="..\..\Shared\Shared.Contracts\Shared.Contracts.csproj" />
|
||||
<ProjectReference Include="..\..\Shared\Shared.Application\Shared.Application.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Infrastructure.FileUpload;
|
||||
namespace Features.ImageUploads.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Service for storing and retrieving uploaded files in S3-compatible object storage.
|
||||
@@ -3,7 +3,7 @@ using Amazon.S3.Model;
|
||||
using Infrastructure.Configuration;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace Infrastructure.FileUpload;
|
||||
namespace Features.ImageUploads.Services;
|
||||
|
||||
/// <summary>
|
||||
/// File storage service backed by an S3-compatible object store (e.g. SeaweedFS, AWS S3).
|
||||
@@ -1,20 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>Infrastructure.FileUpload</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AWSSDK.S3" Version="4.0.102.4" />
|
||||
<PackageReference
|
||||
Include="Microsoft.Extensions.Configuration.Abstractions"
|
||||
Version="10.0.1"
|
||||
/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Infrastructure.Configuration\Infrastructure.Configuration.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user