Skip to content

feat(backend): add bootstrap package with startup validation and DB probe#9

Merged
GRACENOBLE merged 1 commit into
mainfrom
backend.bootstrap
Jun 14, 2026
Merged

feat(backend): add bootstrap package with startup validation and DB probe#9
GRACENOBLE merged 1 commit into
mainfrom
backend.bootstrap

Conversation

@GRACENOBLE

@GRACENOBLE GRACENOBLE commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds internal/bootstrap package with an App struct that owns all shared, validated dependencies (*sql.DB, Config, *slog.Logger)
  • bootstrap.Run(ctx) validates required BLUEPRINT_DB_* env vars, opens the DB connection, and probes Postgres with up to 5 attempts using full-jitter exponential backoff (500ms base → 16s cap, 15s per-attempt deadline to handle Neon cold starts)
  • Context is signal-aware — Ctrl-C during startup probes cancels immediately
  • server.NewServer updated to accept *bootstrap.App instead of reading env vars itself; startup failures exit with code 1 and a message to stderr
  • main.go follows the signal/bootstrap/serve pattern from the reference implementation

Test plan

  • cd backend && make docker-run && make watch — server starts, bootstrap logs show config valid + postgres ready
  • Remove a required env var (e.g. BLUEPRINT_DB_HOST) — process exits 1 with config error before attempting a connection
  • Stop Postgres mid-probe — retry log lines appear, process exits after 5 attempts
  • go vet ./... and go build ./... pass cleanly

…robe

Introduces internal/bootstrap with an App struct that loads config,
validates required env vars, and probes Postgres with exponential
backoff before the HTTP server starts. main.go and server.go updated
to wire through *bootstrap.App instead of reading env vars independently.
@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 39 minutes and 24 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: da2bcd21-68e9-44d4-95a1-3ce8fa127ca9

📥 Commits

Reviewing files that changed from the base of the PR and between 5a033f6 and daa560b.

📒 Files selected for processing (3)
  • backend/cmd/api/main.go
  • backend/internal/bootstrap/bootstrap.go
  • backend/internal/server/server.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch backend.bootstrap

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 9e7bfe7 into main Jun 14, 2026
2 checks passed
@GRACENOBLE GRACENOBLE deleted the backend.bootstrap 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