refactor(backend): restructure into infrastructure/transport layers, add ENV-driven logger#10
Conversation
…add ENV-driven logger - Move internal/handler/ → internal/transport/handlers/ and add internal/transport/middleware/ with a slog-based Gin access logger - Move internal/repository/postgres/ → internal/infrastructure/database/postgres/ - Move backend/migrations/ → internal/infrastructure/database/migrations/ - Add pkg/logger with New(env) returning JSON handler for staging/production and text handler otherwise; ENV env var controls the format - Bootstrap uses logger.New and calls slog.SetDefault so all slog calls across the process share the configured handler - Gin runs in release mode for staging/production, suppressing [GIN-debug] output - Update Makefile, cmd/migrate, CLAUDE.md, and all backend/docs/ to reflect new paths
|
Warning Review limit reached
More reviews will be available in 4 minutes and 16 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 (26)
✨ 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
pkg/logger—New(env string)returns a JSON slog handler forstaging/productionand text for everything else;ENVenv var controls the formatslog.SetDefaultis called immediately so allslog.*calls across the process share the configured handler; Gin runs in release mode for staging/production suppressing[GIN-debug]outputinternal/handler/→internal/transport/handlers/and newinternal/transport/middleware/with a structured slog Gin access logger replacing Gin's built-in unstructured loggerinternal/repository/postgres/→internal/infrastructure/database/postgres/— DB implementations live under infrastructurebackend/migrations/→internal/infrastructure/database/migrations/— migrations are internal to the project,cmd/migratemigrationsDirconstant updated accordinglybackend/docs/updated to reflect new paths and conventionsTest plan
ENV=staging make watch— all logs including Gin access logs are JSON, no[GIN-debug]linesENV=local make watch— logs are human-readable text,[GIN-debug]route list visiblemake migrate-status— goose finds migrations at new pathmake migrate-create name=test_slug— new file created underinternal/infrastructure/database/migrations/go build ./...andgo vet ./...passmake testpasses (unit tests; integration requires Docker)