The TaskHub.Shared.Bootstrapping modules provide the standardized application host templates that enforce the TaskHub Architectural Standard across all microservices. They eliminate “Startup Glue” code by providing pre-configured builders that wire up observability, security, persistence, and messaging in a consistent, predictable way.
The BasicHostBuilder is the root of the hierarchy. It configures the minimal “must-have” infrastructure for any TaskHub service:
System.Text.Json with JsonStringEnumConverter and PropertyNamingPolicy.CamelCase. It ensures that all TaskHub APIs speak the same JSON dialect.DomainException, ResultException, and generic Exception types. It automatically converts them into a Result or ValueResult<T> with standard status codes (400, 403, 404, 500), ensuring the client never receives a raw stack trace.IHttpContextAccessor and basic configuration tools.Inheriting from BasicHostBuilder, the FullHostBuilder orchestrates the entire solution’s project graph:
AddAppSerilog, AddAppOpenTelemetry, and AddAppMetrics.AddAppRedis) and Networking (AddAppNetworkingSettings).DbContext and UnitOfWork.UserStatusMiddleware.CommandsBus and scans assemblies for Handlers and Behaviors.BasicHostBuilder(string[] args)| Method | Description |
| :— | :— |
| void Start() | Initializes the WebApplicationBuilder with basic settings. |
| Task Run() | Builds and starts the WebApplication. |
FullHostBuilder(string[] args)| Method | Description |
| :— | :— |
| void Start<TContext>(Action<WebApplicationBuilder>? config = null) | Full infrastructure initialization including database context TContext. |
| Task Run<TContext>() | Performs migrations and starts the host. |
When FullHostBuilder.Run<TContext>() is called, the following execution sequence occurs:
appsettings.json, appsettings.{Env}.json, and Environment Variables.ServiceInfo (Refactoring)Serilog (Logging)OpenTelemetry (Tracing/Metrics)Redis (Caching)CommandsBus (CQRS)AppAuthorization (Security)AppNetworking (Resilience)TContext is resolved, and db.Database.MigrateAsync() is executed.ForwardedHeadersSerilogRequestLoggingExceptionHandler (Custom)HttpsRedirectionRoutingAuthentication & AuthorizationUserStatusMiddleware (TaskHub Security)Endpoints (Controllers, Metrics, etc.)A service using FullHostBuilder requires the following sections in appsettings.json:
Service: Name and version.Persistence: Connection string and feature flags.Jwt: Key and Issuer.Networking: Defaults and node URLs.Metrics: Port and labels.OpenTelemetry: OTLP endpoint.Action<WebApplicationBuilder> argument in Start() for service-specific registrations to keep Program.cs clean.dotnet ef database update manually in production; let the FullHostBuilder handle it to ensure atomicity between code and schema.FullHostBuilder unless you have a deep understanding of how it affects the UserStatusMiddleware and Result filters.