Problem
internal/api/ is the home for the HTTP layer and has grown to encompass: handlers (ingest, query, structured query, SSE, WS, schema, DLQ, policy, pipes), the router, middleware, the Hub, and health endpoints. As more endpoints get added (e.g. K8s-naming /healthz, future admin routes, /version per #44), this single package becomes the place where every PR collides on shared filenames and the Dependencies struct.
Proposed Solution
Split into focused subpackages under internal/api/. Sketch:
internal/api/router/ — Chi router, middleware, Hub registration
internal/api/ingest/ — ingest handlers
internal/api/query/ — raw + structured query handlers, the singleflight cache wiring
internal/api/stream/ — SSE + WebSocket
internal/api/admin/ — schema, DLQ, policy, pipes admin endpoints
internal/api/health/ — health + readiness
Keep the Dependencies struct + the constructor pattern; each subpackage exposes a Register(r chi.Router, deps Dependencies) function called from the top-level wiring.
Additional Context
Adjacent to #140 (refactor(cmd): extract app.App) but addresses a different layer — #140 extracts the wiring out of cmd/wavehouse/main.go::run(); this issue addresses the HTTP package itself. Could be sequenced before or after #140; not blocking either direction.
This is a pure refactor — no functional change, no API surface change.
Problem
internal/api/is the home for the HTTP layer and has grown to encompass: handlers (ingest, query, structured query, SSE, WS, schema, DLQ, policy, pipes), the router, middleware, the Hub, and health endpoints. As more endpoints get added (e.g. K8s-naming/healthz, future admin routes,/versionper #44), this single package becomes the place where every PR collides on shared filenames and theDependenciesstruct.Proposed Solution
Split into focused subpackages under
internal/api/. Sketch:internal/api/router/— Chi router, middleware, Hub registrationinternal/api/ingest/— ingest handlersinternal/api/query/— raw + structured query handlers, the singleflight cache wiringinternal/api/stream/— SSE + WebSocketinternal/api/admin/— schema, DLQ, policy, pipes admin endpointsinternal/api/health/— health + readinessKeep the
Dependenciesstruct + the constructor pattern; each subpackage exposes aRegister(r chi.Router, deps Dependencies)function called from the top-level wiring.Additional Context
Adjacent to #140 (
refactor(cmd): extract app.App) but addresses a different layer — #140 extracts the wiring out ofcmd/wavehouse/main.go::run(); this issue addresses the HTTP package itself. Could be sequenced before or after #140; not blocking either direction.This is a pure refactor — no functional change, no API surface change.