Skip to content

Group Program.cs DI/service registration into extension methods #291

Closed

Description

@mforce

Problem

src/Cluckwork.Api/Program.cs is ~1026 lines. Endpoint mapping is already modular (each feature has its own Map<Feature>Endpoints extension), and the run-then-exit CLI commands are being extracted separately (#288). The remaining bulk is the long inline service-registration block — dozens of builder.Services.Add… calls for persistence/EF, identity/JWT, telemetry/OTel, rate limiting, feature handlers/validators/repositories, health checks, etc.

Proposal

Group the registrations into AddCluckwork*(this IServiceCollection, IConfiguration) extension methods by concern, e.g.:

  • AddCluckworkPersistence (AppDbContext, interceptors, repositories)
  • AddCluckworkIdentity (Identity, JWT, AdminRecoveryService)
  • AddCluckworkTelemetry (OpenTelemetry traces/metrics, Serilog wiring)
  • AddCluckworkRateLimiting
  • AddCluckworkFeatures (handlers + FluentValidation validators + feature repos)
  • AddCluckworkHealthChecks

So the ConfigureServices section of Program.cs reads as a handful of builder.Services.AddCluckwork*() calls, keeping the wiring discoverable and the bootstrapper small.

Constraints

Tech-debt / maintainability. Relates to the CLI-extraction work on #288.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions