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