Flow
ServicesTemplate Service

Architecture

Binaries, directory layout, and platform wiring in the template service.

Binaries

BinaryPathRole
APIcmd/apiHTTP server + outbox publisher; flags -migrate, -openapi
Flowstatecmd/flowstateBackground worker (sample loop; no HTTP)

Layout

services/template/
  domains/                    ← public per-domain contracts
    domain1/events/
    domain2/events/
  internal/
    domains/                  ← business logic (insert row + outbox event)
      domain1/
      domain2/
    handlers/                 ← HTTP: command → domain (auth not wired yet)
    command/                  ← idempotency + transaction
    publisher/                ← drain domain outboxes
  envelope/                   ← RabbitMQ wire format (service-level)
  migrations/
  db/                         ← sqlc generated queries

Request path

Diagram. Text representation: flowchart LR Client --> Chi Chi --> Huma Huma --> Command Command --> Domain Domain --> SQL Command --> Outbox Outbox --> Publisher
Diagram source
flowchart LR
  Client --> Chi
  Chi --> Huma
  Huma --> Command
  Command --> Domain
  Domain --> SQL
  Command --> Outbox
  Outbox --> Publisher
  1. Handlers call command.Domain1 or command.Domain2.
  2. Domain packages (internal/domains/domain1) insert into domain1 and append to domain1_events.
  3. The publisher drains each domain outbox to RabbitMQ.

Domains

DomainTableOutboxRoutes
domain1domain1domain1_eventsPOST/GET /v1/domain1
domain2domain2domain2_eventsPOST/GET /v1/domain2

Event payloads: services/template/domains/domain1/events/ and services/template/domains/domain2/events/.

Business logic: services/template/internal/domains/domain1/create.go.

Tests

go test ./services/template/...

On this page