/mcp), an MCP SDK, an AI agent, and two cloud infrastructure planes. This page covers the whole-platform topology, the generated-client contract, the integration map, and the data-flow patterns. For api-events internals see api-events.
Platform topology
Clients authenticate with Clerk and call api-events (Encore.ts), the system of record on PostgreSQL. The service writes domain events transactionally, serves the public HTTP API and/mcp, and fans out notification delivery over GCP Pub/Sub. @soundcheck/mcp (mcp-ts/) is the catalog library; CheckAI drives the platform through those tools.
Two infrastructure planes
Both planes share one PostgreSQL database: api-events owns schema and migrations (
api-events/src/db/schema.prisma, api-events/src/db/migrations/).
Environments
The generated-client contract
The web app never hand-writes API types. The chain is:- api-events route contracts — Encore
api()/api.raw()handlers and typed operation graphs inapi-events/src/. npm run openapi:emit(inapi-events/) renders OpenAPI 3.x from those contracts viascripts/openapi/emitOpenApi.ts. Path templates use Encore param names ({userId},{organizationId},{eventId}).swagger-typescript-apistill derives method names such asv1UsersDetail; the path-param objects follow the Encore names ({ userId }not{ id }). Query, header, body, and response shapes come from siblingopenapiRoute()annotations. Encore’s typedapi()cannot describe custom envelope shapes, which is why most handlers areapi.raw. Named$refschemas come from siblingopenapiSchema()registrations.- On PRs,
api-events-deploy.ymlopenapi-parityemits and asserts path templates against Encore extract. Onapi-events/pushes todev/qa/main,docs-cisync-openapi-specre-emits and asserts path templates and$ref’d schema-catalog keys before auto-committingdocs/openapi/soundcheck.json. web/scripts/generate-api-client.mjsreadsdocs/openapi/soundcheck.jsonand emits a typed TypeScript client viaswagger-typescript-api. It runs automatically on the web app’spredevandprebuildscripts (skipping codegen when the output is newer than the spec).
e2e/ suite additionally enforces endpoint coverage — new API routes are expected to be exercised — so an unregistered or untested endpoint surfaces in CI rather than silently drifting.
npm run openapi:parity in api-events/ compares the committed spec against live TS endpoint declarations extracted via AST (a self-check that emit and handlers have not drifted). Encore’s native OpenAPI export is not used — it cannot describe api.raw handlers.
Integration map
The API is the single boundary for third-party integration. External services either push in via signed webhooks or the API calls out through a dedicated service. Per project convention, third-party calls that would otherwise be made inline (HubSpot, Flex) are brokered through n8n, which posts results back to the API as webhooks.Inbound webhooks
All webhook handlers live inapi-events/src/webhooks/ and verify a provider signature or shared secret before doing any work.
Outbound integrations
Data-flow patterns
Direct Pub/Sub today; durable outbox as the target
The API currently mixes direct provider calls with direct Pub/Sub publication; it has no shared transactional outbox. Availability notification processors demonstrate independent channel/device fan-out with terminal inbox and notification audit records, while other consumers have different failure policies. An inbox alone does not make external effects exactly once. See api-events for the component map. The durable workflow contract selects among synchronous transactions, outbox delivery, database queues, reconciliation and resumable workflows. The feature assessment identifies current gaps and a sequenced end-state for durability and scalability.UEF import & ingestion
The Universal Event Format (UEF) is the interchange shape for bringing external event data into the platform — file uploads and third-party imports are normalized to UEF, then reconciled against existing records. In-repo the import pipeline lives underapi-events/src/systems/imports/; ingestion batches under api-events/src/systems/event-ingestions/. See api-events for the ingestion subsystem.
CI/CD
Workflows live in
.github/workflows/ (e.g. api-events-deploy.yml, web-ci-cd.yml, docs-ci.yml, gcp-terraform-validate.yml).
Security model
- Authentication — Clerk-issued JWTs from every client. Basic Auth is removed. See the API’s auth middleware.
- Authorization — organization-scoped, role-based checks enforced in middleware and handlers; resource-level ownership checks in services.
- Secrets — held in Azure Key Vault and surfaced to App Services as Key Vault references (not raw env vars).
- Webhooks — every inbound webhook verifies a provider signature or HMAC shared secret before acting.
- Fail-closed config — the API defaults
ENVIRONMENTtoproduction, so production validation applies unless development is explicitly opted into.