Describe the backend in Go.
Controllers, request structs, providers, route marker types, and policies live where your team already reviews code.
Anvil turns typed Go declarations into routing, dependency wiring, validation, OpenAPI, manifests, and deterministic testbeds. Review the handwritten API. Commit the generated glue.
anvil generate anvil.yaml cmd/api, internal/... 38 routes 9 middleware chains 27 resolved 0 dependency cycles anvil_autogenerated.go openapi.json testbeds generated Anvil reads the controllers, policies, providers, and validation tags in your repo, resolves the graph, then writes the Go, specs, manifests, and testbeds that should not be maintained by hand.
The controller stays small. The generated wiring is not a hidden runtime registry, it is Go your team can inspect, diff, and debug.
type Projects struct {
sdk.Controller `path:"/projects"`
Store project.Store
Routes struct {
Create sdk.POSTWith[WritePolicy] `path:"/"`
Get sdk.GET `path:"/:projectId"`
}
} return transport.RegisterHTTP(sdk.HTTPRoute{
Method: "GET",
Path: "/projects/:projectId",
Controller: "Projects",
Endpoint: "Get",
Handler: func(ctx sdk.Ctx) (any, error) {
req, err := bindGetProject(ctx)
if err != nil { return nil, err }
return c.projects.Get(ctx, req)
},
}) Run Anvil during development, in CI, or as a pre-commit check. The same pass catches mistakes and emits the artifacts your docs, tests, and transports need.
Controllers, request structs, providers, route marker types, and policies live where your team already reviews code.
The compiler walks tags, bindings, middleware, validation, providers, custom rules, and transport adapters with type information.
Readable Go, API specs, manifests, diagnostics, and testbed fixtures stay tied to the application model that produced them.
anvil.yaml cmd/api, internal/... 38 routes 9 middleware chains 27 resolved 0 dependency cycles anvil_autogenerated.go openapi.json testbeds generated route and provider graph
generated operation data
deterministic fixtures
repository-owned checks
Generate OpenAPI, deterministic test scenarios, manifest data, and custom diagnostics from the same declarations that register your app.
Every compiler run can produce deterministic JSON that describes routes, bindings, validations, middleware, source locations, and protocol metadata.
Manifest reference{
"schema": "anvil.manifest.v1",
"http": {
"routes": [
{
"method": "GET",
"path": "/projects/:projectId",
"controller": "Projects",
"endpoint": "Get",
"operationId": "Projects.Get",
"request": {"package": "example.com/portal/project", "name": "GetProjectRequest"},
"bindings": [{"field": "ProjectID", "source": "param", "key": "projectId"}],
"source": {"file": "api/projects.go", "line": 19}
}
]
}
}Anvil does not ask you to hide your service graph behind magic. It takes the boring repeat work out of the repository and leaves the architecture visible.
Use CQRS, layered services, hexagonal boundaries, or a small package layout. Anvil reads the contracts and builds around them.
Bad params, missing providers, invalid tags, policy gaps, and custom rule violations show up during generation with source locations.
Routes, policies, OpenAPI, manifests, test data, and generated Go come from the same declarations instead of drifting across files.
HTTP, gRPC, GraphQL, Redis, NATS, SQS, OpenTelemetry, and S3 can attach to the same declarations. Swap the edge. Keep the center.
Generate the wiring, inspect the diff, and keep the pieces that make the repository easier to maintain.