Skip to content
/ Project Structure

Documentation

Project Structure

What gostrata generates and where things live.

A newly generated project looks like this:

my-saas
my-saas/
├── cmd/
│   ├── api/
│   └── migrate/
├── config/
├── internal/
│   ├── domain/
│   │   ├── entity/
│   │   ├── errors/
│   │   └── repository/
│   ├── usecase/
│   │   ├── interface/
│   │   └── implementation/
│   ├── delivery/http/
│   │   ├── handlers/
│   │   ├── middleware/
│   │   ├── response/
│   │   └── routes.go
│   ├── infrastructure/
│   │   ├── container/
│   │   ├── database/
│   │   ├── persistence/
│   │   └── server/
│   └── types/
├── migrations/
├── pkg/logger/
├── .air.toml
├── .env
├── .gostrata.json
├── .dockerignore
├── Dockerfile
├── docker-compose.yml
├── Makefile
└── go.mod

Directories

  • cmd/api — the API entry point. Loads config and starts the server.
  • cmd/migrate — runs database migrations up or down. Used by make migrate.
  • internal/domain — entity, errors and repository interfaces.
  • internal/usecase — interface declarations and their implementation.
  • internal/delivery/http — handlers, middleware (CORS, request ID, logging, recovery), the JSON response helpers and routes.go.
  • internal/infrastructure — the container that wires dependencies, plus database, GORM persistence repositories and the server.
  • internal/types — request, input and response DTOs.
  • migrations — numbered .up.sql and .down.sql files.
  • config — Viper configuration.
  • pkg/logger — the Zerolog logger.

Starter feature

Every new project already includes a working User feature, a /health endpoint and an initial users migration, so you can run the server straight away.

Root files

  • .env and .env.example — environment settings.
  • .air.toml — hot reload settings.
  • .gostrata.json — records your router, database and ORM so generators match your stack.
  • Dockerfile and .dockerignore — a multi-stage build for the API.
  • docker-compose.yml — the database service, for PostgreSQL and MySQL projects.
  • Makefile — run, dev, build, migrate, migrate-down, test, tidy and clean.