Skip to content

refactor(backend): restructure into infrastructure/transport layers, add ENV-driven logger#10

Merged
GRACENOBLE merged 1 commit into
mainfrom
backend.environments-and-logger
Jun 14, 2026
Merged

refactor(backend): restructure into infrastructure/transport layers, add ENV-driven logger#10
GRACENOBLE merged 1 commit into
mainfrom
backend.environments-and-logger

Conversation

@GRACENOBLE

@GRACENOBLE GRACENOBLE commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • New pkg/loggerNew(env string) returns a JSON slog handler for staging/production and text for everything else; ENV env var controls the format
  • Bootstrap wires the loggerslog.SetDefault is called immediately so all slog.* calls across the process share the configured handler; Gin runs in release mode for staging/production suppressing [GIN-debug] output
  • internal/handler/internal/transport/handlers/ and new internal/transport/middleware/ with a structured slog Gin access logger replacing Gin's built-in unstructured logger
  • internal/repository/postgres/internal/infrastructure/database/postgres/ — DB implementations live under infrastructure
  • backend/migrations/internal/infrastructure/database/migrations/ — migrations are internal to the project, cmd/migrate migrationsDir constant updated accordingly
  • CLAUDE.md and all backend/docs/ updated to reflect new paths and conventions

Test plan

  • ENV=staging make watch — all logs including Gin access logs are JSON, no [GIN-debug] lines
  • ENV=local make watch — logs are human-readable text, [GIN-debug] route list visible
  • make migrate-status — goose finds migrations at new path
  • make migrate-create name=test_slug — new file created under internal/infrastructure/database/migrations/
  • go build ./... and go vet ./... pass
  • make test passes (unit tests; integration requires Docker)

…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
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@GRACENOBLE, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e77f6e57-2fc6-4d85-882b-6c1b3fdf04ae

📥 Commits

Reviewing files that changed from the base of the PR and between 9e7bfe7 and 0f42ff8.

📒 Files selected for processing (26)
  • CLAUDE.md
  • backend/Makefile
  • backend/cmd/api/main.go
  • backend/cmd/migrate/main.go
  • backend/docs/_index.md
  • backend/docs/bootstrap.md
  • backend/docs/database.md
  • backend/docs/environment.md
  • backend/docs/error-handling.md
  • backend/docs/migrations.md
  • backend/docs/routing.md
  • backend/docs/testing.md
  • backend/internal/bootstrap/bootstrap.go
  • backend/internal/infrastructure/database/migrations/.gitkeep
  • backend/internal/infrastructure/database/migrations/20260614201325_init.sql
  • backend/internal/infrastructure/database/postgres/db.go
  • backend/internal/infrastructure/database/postgres/health_repository.go
  • backend/internal/infrastructure/database/postgres/health_repository_test.go
  • backend/internal/server/server.go
  • backend/internal/transport/handlers/handler.go
  • backend/internal/transport/handlers/health_handler.go
  • backend/internal/transport/handlers/hello_handler.go
  • backend/internal/transport/handlers/hello_handler_test.go
  • backend/internal/transport/handlers/routes.go
  • backend/internal/transport/middleware/logger.go
  • backend/pkg/logger/logger.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch backend.environments-and-logger

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the area: backend Go REST API label Jun 14, 2026
@GRACENOBLE GRACENOBLE merged commit 99935cb into main Jun 14, 2026
2 checks passed
@GRACENOBLE GRACENOBLE deleted the backend.environments-and-logger branch June 14, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: backend Go REST API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant