Your first request

docker compose up, run the API, hit /api/health.

4 mineasy

Time to bring the API up. Four commands. By the end you'll have a live JSON response in your terminal.

1. Start Postgres + friends

Terminal
$cd bench-api
$docker compose up -d

Brings up Postgres, Redis, MinIO, and Mailhog in the background. The -d means "detached"; check status with docker compose ps.

2. Run the API from the project root

Important: run from project root, not from inside apps/api/cmd/server/. The config loader looks for ./.env relative to your working directory, and .env lives at project root.

Terminal
# from bench-api/
$cd apps/api && go run ./cmd/server

Wait — that's also a non-root cwd. The trick: run from apps/api/ (because that's where go.mod lives), and the loader will find the project-root .env via the ../../.env path it tries.

Don't cd apps/api/cmd/server first — from there, the loader can't find .env and the API exits with DATABASE_URL is required. This is the gotcha most new users hit. Always run from apps/api/.

3. Watch the startup log

2026/06/01 09:00:00 Database connected successfully
2026/06/01 09:00:00 Redis cache connected
2026/06/01 09:00:00 File storage connected
2026/06/01 09:00:00 Job queue connected
2026/06/01 09:00:00 [sentinel] Mounted at /sentinel
2026/06/01 09:00:00 Pulse observability mounted at /pulse
2026/06/01 09:00:00 [GIN-debug] Listening and serving HTTP on :8080

Every battery wired in five lines. If any of these say "failed", scroll up — the error message tells you exactly what's missing (usually a env value or Docker service that didn't come up).

4. Hit /api/health

Terminal
$curl http://localhost:8080/api/health

You should see:

{ "status": "ok", "version": "0.1.0" }

That's success. The API connected to every service it needs and is ready to handle requests.

The other URLs you can poke

  • http://localhost:8080/docs — auto-generated OpenAPI documentation
  • http://localhost:8080/studio — GORM Studio (DB browser)
  • http://localhost:8080/sentinel/ui — Sentinel WAF dashboard
  • http://localhost:8080/pulse/ui — Pulse observability
  • http://localhost:8025 — Mailhog (captures all dev email)

Quick check

You see `DATABASE_URL is required` on startup. What's the most likely cause?

Try it

Get the API running end-to-end. From your scaffolded project:

  1. docker compose up -d
  2. cd apps/api && go run ./cmd/server
  3. In another terminal: curl http://localhost:8080/api/health

Paste the curl response in notes.md. That completes chapter 1's assignment — the criteria are in the sidebar.

What's next

Chapter 2 — Modeling with GORM. You'll define your first model, see how AutoMigrate handles tables, and learn the GORM tags Grit assumes.

Spot a typo? Have an idea?

Help us improve this lesson. One click opens a GitHub issue with the lesson URL pre-filled — suggest clearer wording, report a bug, or request more depth. The course keeps improving thanks to learners like you.

Suggest an improvement on GitHub