refactor(app): collapse feature wiring into per-feature Module builders#143
Merged
Conversation
Each feature now owns one build<Feature>Module that assembles use case -> handler -> Route Module in a single place. Handler and repository once[T] fields are removed from the Container: handlers are built as locals inside the builders, and repositories are built inline inside each use case's init (single consumer, stateless over *sql.DB). Use cases stay as memoized once[T] fields because both the HTTP path and the CLI consume them. The per-route authorizer becomes a shared Authorizer() accessor so every builder fetches it without threading. initHTTPServer drops ~12 dependency fetches down to three plus a four-builder loop. buildAuthModule builds its optional token rate limiter last so the error paths never start its background goroutine. Drops 8 handler + 7 repository fields/accessors/inits; adds 4 builders and one authorizer accessor. Net -232 lines. di_test rewritten to assert at the module seam; the audit-log integration test builds its own repository from the container DB. README dependency graph and "adding components" updated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Deepens the composition root (
internal/app). Each feature now owns onebuild<Feature>Modulethat assembles use case → handler → Route Module in one place, replacing the scattered field + accessor +inittriple that every handler and repository carried.Containerfields — built as locals inside the feature builders.Containerfields — built inline inside each use case'sinit(single consumer, stateless over*sql.DB).once[T]fields (both the HTTP path and the CLI consume them).Authorizer()accessor, so builders fetch it without threading.initHTTPServerdrops from ~12 dependency fetches to three (db, tokenUseCase, metricsProvider) plus a four-builder loop.buildAuthModulebuilds its optional token rate limiter last, so the error paths never start its background goroutine.Net: drops 8 handler + 7 repository fields/accessors/inits; adds 4 builders + 1 authorizer accessor. −232 lines.
Docs: the
internal/app/README.mddependency graph and "adding components" section are updated to the builder pattern (and a staleinitErrors-map example that never matchedonce[T]is corrected).Validation
go build ./...— cleanmake test— 1250 tests pass (41 packages, race enabled)go vet -tags integration ./test/integration/...— cleanmake lint— 0 issues, govulncheck 0 vulnerabilitiesmake docs-lint— 0 errorsNotes
di_test.gonow asserts at the module seam; the audit-log signature integration test builds its own repository from the container DB.di_crypto.go(it wires keyring/KEK, not transit crypto).🤖 Generated with Claude Code