Code Generation
The backend relies on three code generators. All of their output is committed to the repository, and CI fails if any of it is stale relative to its source.
oapi-codegen (server + types)
Section titled “oapi-codegen (server + types)”The OpenAPI spec drives oapi-codegen,
which generates the chi strict-server bindings and shared types from the bundled
spec (dist/openapi.bundled.yaml). The generators are configured by
backend/oapi-codegen.yaml (server) and backend/oapi-codegen-types.yaml
(types).
make backend-generate-openapi-serverThis target first bundles the spec, then generates the strict-server code and the types package. See API & OpenAPI for the spec-first workflow.
Wire (dependency injection)
Section titled “Wire (dependency injection)”The dependency graph is wired with Wire. The
generated internal/container/wire_gen.go is committed, and Wire is pinned via
the go.mod tool directive so runs are reproducible in CI.
make backend-wire-gen # regenerate internal/container/wire_gen.gomake backend-wire-check # regenerate, then fail if it differs from the committed filebackend-wire-check catches DI drift — a hand-edited wire_gen.go, or a changed
provider signature that was never regenerated. It is idempotent on a clean tree.
mockery (test mocks)
Section titled “mockery (test mocks)”Service interfaces are mocked with mockery so handlers and services can be unit-tested against fakes.
make backend-mock-generate # regenerate all mocks (mockery --all)The generated mock_*.go files are committed. See
Testing for how the mocks are used.
Quick reference
Section titled “Quick reference”| Generator | Command | Output (committed) |
|---|---|---|
| oapi-codegen | make backend-generate-openapi-server | strict-server handlers + internal/server/gen/types |
| Wire | make backend-wire-gen (backend-wire-check to verify) | internal/container/wire_gen.go |
| mockery | make backend-mock-generate | mock_*.go files |