Backend Development
Backend services follow Clean Architecture with Web, Application, Domain, and Infra layers.
Handler Pattern
Controllers inject handlers with [FromServices], and handlers extend HandlerBase<TRequest, TResponse>.
[HttpPost("foo")]
public async Task<IServiceResponse<FooResponse>> FooAsync(
[FromServices] FooHandler handler,
[FromBody] FooRequest request) => await handler.ProcessAsync(request);
public class FooHandler : HandlerBase<FooRequest, FooResponse>
{
protected override Task ValidateAsync()
{
if (string.IsNullOrWhiteSpace(Input.Name))
Response.AddError("Name is required.");
return Task.CompletedTask;
}
protected override async Task HandleAsync()
{
Response.Data = await service.DoAsync(Input);
}
}
Feature Checklist
- Add domain entity and repository interface.
- Add EF mapping,
DbSet<T>, repository implementation, and infrastructure registration. - Add application service, handler request, handler response, and handler.
- Add a Web controller action using
[FromServices]handler injection. - Add an EF migration targeting the Infra project with the Web startup project.