Communication
| Channel | Use | Conventions |
|---|---|---|
| REST/JSON via the gateway | Public API (browsers, scripts, devices) | /v1/ URL versioning, one OpenAPI 3.1 spec per service, cursor pagination, RFC 9457 errors |
| ConnectRPC | Internal synchronous queries (permission checks, lookups) | proto/, generated into pkg/gen; gRPC compatible, served over HTTP on the service port |
| Kafka | Internal asynchronous events | Topics <service>.<aggregate>.v1, CloudEvents 1.0 JSON, key = aggregate ID |
Devices and external integrations only use the HTTP API; Kafka is internal.
REST conventions
- Errors:
application/problem+jsonwithtype,title,status, a machine-readablecode, optionaldetail,instanceand per-fieldfieldsfor validation errors (pkg/problem). - Pagination:
limit(default 25, max 200) and an opaquecursor; responses are{"items": [...], "next_cursor": "..."}(pkg/pagination). Lists are ordered by ascending ULID unless stated. - Request ID: a well-formed incoming request ID is reused, otherwise generated (
pkg/httpx), and propagated to audit records and logs. - Health:
/healthz(liveness),/readyz(readiness: dependencies registered withAddCheck). Prometheus metrics are served on a separate private listener (METRICS_ADDR).
Gateway routing
| Prefix | Upstream | Access |
|---|---|---|
/v1/auth/* | gateway itself | see gateway |
/v1/public/settings | authz | anonymous, cached |
/v1/authz/* | authz | authenticated |
/v1/members/* | members | authenticated |
/v1/audit/* | audit | authenticated |
/v1/files, /v1/inventory, /v1/events, /v1/public/events, /v1/public/calendar, /v1/borrowing | phase 2–3 services | planned |
/v1/search | search | authenticated |
/v1/devices | devices | authenticated (device API keys: /v1/devices/agent/* only) |
Upstreams come from GATEWAY_ROUTES (prefix=url,..., longest prefix wins). An unrouted /v1/* path answers
503; paths outside /v1/ answer 404; /v1/public/* is the only anonymous area.
CloudEvents envelope
pkg/cloudevent builds CloudEvents 1.0 structured-mode JSON:
{
"specversion": "1.0",
"id": "01J…",
"source": "members",
"type": "members.member.created",
"subject": "<aggregate ID, also the Kafka key>",
"time": "2026-10-06T10:00:00Z",
"datacontenttype": "application/json",
"data": {},
"traceparent": "00-…",
"atlactorkind": "user",
"atlactorid": "<Keycloak ID>",
"atlsite": "paris",
"atlversion": 3
}
type follows <service>.<aggregate>.<event>. Extensions carry the actor, the site and the aggregate version;
traceparent lets consumers continue the trace.