Scaffolding the API
grit new my-api --api walkthrough.
Welcome to Building a Go API. Goal of this chapter: scaffold an API-only project, identify every file, get it serving requests. This first lesson is the scaffold itself โ 5 minutes, one command, you're ready.
This course assumes you can read Go syntax (structs, methods, error handling) and run a Docker container locally. If either is shaky, skim the primers first โ they take 15 minutes each.
The command
$grit new bench-api --api
Pick the project name (anything kebab-case works). The --api flag tells Grit you want the headless Go backend kit โ no apps/web, no apps/admin, just the Go API.
What you get
You'll see the standard checklist run:
โ Created bench-api/โ Wrote 42 filesโ Initialized go moduleโ Generated random secrets (JWT_SECRET, SENTINEL_*, PULSE_*)Next steps:cd bench-apidocker compose up -dcd apps/api && go run cmd/server/main.go
apps/api/, not the project root. This is so you can later add a frontend by dropping it next to apps/api/ without moving files.The kit's shape at a glance
bench-api/โโโ apps/โ โโโ api/ The Go API lives hereโ โโโ cmd/server/main.go Entry pointโ โโโ internal/ All Go codeโ โโโ .air.toml Hot-reload configโ โโโ go.modโ โโโ Dockerfileโโโ docker-compose.yml Postgres + Redis + MinIO + Mailhogโโโ docker-compose.prod.ymlโโโ .env Generated with random secretsโโโ .env.exampleโโโ grit.jsonโโโ README.md
What didn't get scaffolded
- No
apps/web/โ no public Next.js site - No
apps/admin/โ no Filament-style admin panel - No
packages/shared/โ no Zod schemas + TS types - No
turbo.json,pnpm-workspace.yamlโ Go-only deps
Everything else from the Concepts course โ random JWT secret, Sentinel + Pulse pre-configured, SQLite support out of the box โ still ships.
Quick check
Try it
Scaffold bench-api with the API-only kit. Then run ls -la bench-api (Mac/Linux) or dir bench-api (Windows) and paste the output in notes.md.
Note: do not use cd apps/api yet โ we'll tour the structure in the next lesson before running anything.
What's next
Files are on disk. Next lesson โ the tour. We open apps/api/internal/ and walk every folder, naming the responsibility of each.
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