DDD todo-list API in Go. Schema-first with oapi-codegen + kin-openapi, GORM + SQLite, JWT auth.
api/
openapi.yaml # root spec — paths, security, inline schemas (Author, Board, TokenResponse)
domain/
author/ # Author aggregate, events, repository interface
board/ # Board aggregate, Note entity, events, repository interface
eventbus/ # In-memory event bus
application/ # AuthorService, BoardService
infrastructure/
persistence/ # GORM + SQLite repositories
middleware/
jwt.go # JWT auth (skips /auth/*)
validation.go # kin-openapi request validation
handler/ # StrictServerInterface implementation
gen/ # Generated — do not edit by hand
models.gen.go
server.gen.go
cmd/main.go # Entrypoint
generate.go # go:generate directives (run from project root)
static/index.html # Frontend (HTML + Tailwind + vanilla JS)
After editing anything under api/:
go generate .go run ./cmd/main.goEnvironment variables (all optional):
| Variable | Default |
|---|---|
ADDR |
:8080 |
DB_DSN |
todo.db |
JWT_SECRET |
change-me-in-production |
Frontend available at http://localhost:8080.
Handled automatically by middleware/validation.go using kin-openapi before requests reach handlers.
Validation errors return HTTP 400:
{
"errors": [
{ "field": "content", "validator": "minLength", "message": "minimum string length is 10" }
]
}Schemas that need to be named Go types must be defined inline in openapi.yaml (not as external $ref), because oapi-codegen only generates a named struct for schemas directly referenced in paths. Leaf schemas with no cross-references can live in api/schemas/.