refactor(backend): Clean Architecture layering#7
Conversation
Replaces the flat database/server monolith with explicit domain, usecase, repository, and handler layers that strictly enforce the dependency rule (inner circles never import outer circles). Key changes: - internal/domain/ — HealthStats typed struct (was map[string]string) - internal/usecase/ — HealthReader interface + HealthUseCase with message thresholds - internal/repository/postgres/ — raw DB adapter; business logic moved out - internal/handler/ — Handler struct wired on use case interfaces; HealthHandler exported - internal/server/server.go — composition root only, NewServer() returns error - Deleted internal/database/ and internal/server/routes.go - Updated all backend docs and CLAUDE.md to reflect new layout
|
Warning Review limit reached
More reviews will be available in 9 minutes and 20 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (24)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
internal/database+internal/servermonolith with explicit Clean Architecture layers:domain→usecase→repository/postgres+handler→serverHealthStatspromoted frommap[string]stringto a typed struct with JSON tagsHealthHandlerexported for naming consistency withHelloWorldHandlerNewServer()now returns(*http.Server, error)instead of panicking on DB failureTest plan
go vet ./...passes (no output)make testpasses unit tests (handler httptest)make itestpasses integration tests against Testcontainers Postgres (requires Docker)GET /returns{"message":"Hello World"}with 200GET /healthreturns typed JSON stats with 200 when DB is up; 503 when DB is down