Conversation
… packages
- handler/{auth,calls,bookmarks,share,setup,health}/... for listener + auth routes
- handler/admin/{imports,radioreference,transcriptions}/... for the admin REST surface
(11 WS-only admin features remain in internal/admin + internal/ws, already extracted in Phase 2)
- handler/shared/ for swagger DTOs and common helpers
- handler/routes/ owns route registration, including /ws and /api/ws
- internal/api/ removed
- Swag invocation in Makefile + 3 workflows updated to scan internal/handler
- Swagger regenerated
- No route, method, body, header, or middleware changes
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.
Phase 3 of the directory restructure
Plan reference:
docs/plans/directory-restructure-plan.md§ Phase 3.Breaks the monolithic
backend/internal/api/package into per-feature subpackages underbackend/internal/handler/. Pure refactor — zero changes to route paths, HTTP methods, middleware ordering, response shapes, status codes, error strings, headers, or query parameters.What moved
handler/routes/api/routes.go(+ all integration tests)handler/shared/api/swagger_models.go→dto.go,api/content_disposition*.go, plus genuinely shared helpers (call_search.go,grants.go,resolve.go,settings.go)handler/auth/api/admin.go(mis-named — held auth/login/refresh/me/password/tg-selection) + auth/refresh testshandler/calls/api/calls.go+ limiterhandler/bookmarks/api/bookmarks.gohandler/share/api/share.go+ share-limiter testhandler/setup/api/setup.gohandler/health/api/health.gohandler/admin/imports/api/import.gohandler/admin/radioreference/api/radioreference.gohandler/admin/transcriptions/api/crud.go(GetTranscriptionStatus)backend/internal/api/is gone — not stubbed.Scope adjustment vs. the original plan
The plan was written before Phase 2 landed and assumed
api/admin.go+api/crud.godefined ~14 admin REST handlers. After Phase 2, those 11 admin features (users/systems/talkgroups/tags/groups/units/api_keys/dirmonitors/downstreams/webhooks/logs) are WS-only and already live ininternal/admin/+internal/ws/. Only 3 admin REST handlers actually existed ininternal/api/(imports, radioreference, transcriptions status), so only those 3 admin subpackages were created. No empty placeholder packages.Other changes
cmd/server/main.goimportsinternal/handler/routesinstead ofinternal/api.swag initinvocations updated inbackend/Makefile,.github/workflows/ci.yml,.github/workflows/codeql.yml,.github/workflows/release.ymlto scaninternal/handlerinstead ofinternal/api.backend/.golangci.ymlswagger-stubs path-include updated.type Handler struct,func New(...) *Handler,func (h *Handler) Register(r gin.IRouter).handler/routes/routes.gowires them all with the same middleware ordering as before.Verification
cd backend && go build ./...✅cd backend && go vet ./...✅cd backend && go test ./...✅ (50 test functions, exact parity with the old api/ tests)cd frontend && npx tsc --noEmit✅rg -n internal/api backend/ Makefile .github/workflows/returns zero hits.Audit results
Completeness audit confirmed:
internal/handler/orinternal/middleware/handler/shared/has ≥2 consumers across distinct packagesStats
37 files changed, +695 / -580 — mostly renames; net deletions because thin handlers + the shared dedup add less than the old monolith spent on its in-package machinery.
Soak
Per the plan, this is a pause-and-review point before Phases 4-5 (frontend reorg). Recommend merging to
devand exercising the Admin UI / Scanner UI before continuing.Changelog
Entry added under
### Changed.Rollback
git revertthe squash commit. Routes, methods, bodies preserved → clients can't observe the move.