Flow
ServicesTemplate Service

Template Service

The reference Go service — copy this directory to start a new service.

The template service is a real, compiled, tested service. Its domains (domain1, domain2) are throwaway samples, but the wiring is what you copy: Postgres, idempotent Command: An HTTP POST that changes state, recorded with an Idempotency-Key so retries do not double-apply; not CQRS or a command bus. handling via command.Execute, per-domain Transactional outbox: Each domain inserts events into its own <domain>_events table in the same transaction as the state change; a publisher drains unpublished rows to RabbitMQ. tables, and a Response envelope: The template service wraps every JSON response in {header, payload}; accounting still returns bare bodies and RFC 9457 errors until the divergence is resolved. on every JSON response.

Domain
Services
Kind
Go HTTP service
Lifecycle
Active
flowctl project
None
Stacks
Runs on its own

What it owns

  • Sample CRUD for domain1 and domain2 (POST / GET /v1/domain1, /v1/domain2)
  • Per-domain outbox tables and a RabbitMQ publisher in the API binary
  • Shared platform types in 0001_platform.sql (event_visibility enum)
  • Vendored Swagger UI and served OpenAPI spec
  • A second binary (flowstate) demonstrating multi-process deployment from one image

What it does not own

Production business logic or authorization. Replace the example domains and migrations when copying; keep internal/command/, internal/publisher/, and the handler patterns. Wire Cedar auth when copying into a real service — see services/accounting for the current pattern.

New services follow docs/decisions/0015-domain-scoped-outbox-and-table-prefixes.md: 0001_platform.sql holds shared types; each domain adds its prefixed tables and outbox in 0002_<domain>.sql.

Canonical service README: services/template/README.md.

On this page