Add a service
A new service earns its place when it owns data nobody else should write, or has a different reason to change. If it would share a database with an existing service, or call it on every request, it is probably a package inside that service instead.
-
Copy the layout of
internal/:user/ domain/if it is event-sourced,app/,store/with itsstoretestcontract suite and thememory,mysqlandmongodbbackends,httpapi/,rpc/if others call it, and anAGENTS.mdthat says what is true only there. Start state-stored like auth unless the history is worth keeping; event sourcing is a choice per service. -
Extend the boundary test in
internal/, so the new service imports no other service and none imports it.archtest/ archtest_test.go -
Add the binary, copied from
cmd/:user/ main.go, the composition root, kept under 150 lines,config.go,healthcheck.go, and onestore_<backend>.goper backend. Only those store files carry build tags. Keep themigrate,envandhealthchecksubcommands. -
Describe its API in
api/, with the OpenAPI and authorization-matrix tests copied from<service>.openapi.yaml internal/. Its RPCs, if any, go inuser/ httpapi proto/, followed by<service>/ v1/ make gen: see Add an RPC. -
Give it scopes. A scope users may grant to OAuth apps goes in the
grantablelist ininternal/. A scope that only another service holds stays out of it, like the one auth uses to redeem login codes.auth/ app/ scopes.go -
Register it in compose: a service in
compose.yamlbuilt withSERVICE=<service>, with the health check/(it asks the service’s ownservice healthcheck /), its store settings inreadyz compose.mysql.yamlandcompose.mongodb.yaml, and a database and user indeploy/. Add it to thecompose/ mysql-init.sql logstarget in theMakefile. -
Route it through the gateway, if it has public routes: a
/location inapi/ <service>/ web/, with its upstream as an environment variable next tonginx.conf AUTH_UPSTREAMandUSER_UPSTREAMinweb/.Dockerfile -
Add it to the Helm chart: a template in
deploy/, its values, the list of services inhelm/ go-api-boilerplate/ templates/ templates/, and themigrate.yaml ci/files.*-values.yaml -
Release and document it: add it to the
servicematrix in.github/and to theworkflows/ release.yml for svc in auth userloop inscripts/, so its variables reach Environment variables. Update the map and scope router in the rootenv-reference.sh AGENTS.md, so an agent working in the new folder finds its rules, and this site’s architecture and project layout pages. -
Run everything, with each store:
Terminal window make checkmake up && make e2emake up STORE=mysql && make e2emake up STORE=mongodb && make e2e
CI needs no change for Go: it builds and tests ./ for each store tag, and runs the container tests of every mysql and mongodb package, so the new packages are covered as soon as they exist.