Skip to content

Generated Files

kiln generates two categories of files: auto-generated (regenerated on each run) and write-once (generated once, yours to edit).

Auto-Generated Files

These are regenerated on each kiln generate. Each has an embedded checksum - if you edit one, kiln detects the change and skips it.

File Contents
generated/models/<table>.go Response struct, Create/Update request structs, list response
generated/store/<table>.go Store with Get, List, Create, Update, Delete methods
generated/handlers/<table>.go HTTP handlers for each CRUD operation
generated/router.go Route registration for all tables
docs/openapi.yaml OpenAPI 3.0 specification

Models

Each table gets a models file with:

  • Response struct (User) - all visible columns with JSON tags
  • CreateRequest struct (CreateUserRequest) - writable columns with validation tags
  • UpdateRequest struct (UpdateUserRequest) - all fields as pointers (partial updates)
  • ListResponse struct (ListUsersResponse) - paginated response wrapper
  • LinkRequest struct (LinkTagToPostRequest) - for M2M relationships (one per junction table)

Store

Each table gets a store file with:

  • Get - fetch by primary key
  • List - paginated with filtering and sorting
  • Create - insert with request validation
  • Update - partial update by primary key
  • Delete - hard delete or soft delete (if deleted_at exists)
  • ListByParent - one per foreign key relationship
  • Link/Unlink/ListLinked - for many-to-many relationships via junction tables

Store constructors accept bob.Executor, which both bob.DB and bob.Tx satisfy. This allows wrapping store calls in transactions without modifying generated code.

Handlers

Each table gets a handler file with HTTP handlers that:

  • Parse request bodies and path parameters
  • Call store methods
  • Return JSON responses with correct status codes
  • Handle errors (404, 409 conflict, 422 FK violation, 500)

Router

A single file that registers all routes. Supports stdlib http.ServeMux or chi.

Write-Once Files

Generated once on first run. kiln never overwrites them. Edit freely.

File Purpose
generated/store/mappers/<table>.go Map bob model to response type. Add computed fields, hide sensitive data.
generated/handlers/helpers.go Error formatting, pagination parsing, request validation.
generated/auth/middleware.go Auth middleware skeleton (if auth enabled).
cmd/server/main.go Server entry point - wires stores, handlers, and router.

Internal Files (Bob)

These are generated by bob (kiln's schema reader) and are internal:

Directory Contents
models/ Bob's query builder models
dbinfo/ Raw schema metadata (column types, constraints, indexes)
factory/ Test factories (bob feature)
dberrors/ Database error helpers (bob feature)

You don't need to edit these. kiln reads them during generation.