Skip to main content

Backend Service

wspace-headshotmarketing-svc is the GraphQL microservice that powers HeadshotMarketing. It runs on the Burdenoff Workspaces platform, exposes a federated GraphQL schema via the workspace public gateway, and persists data in Postgres 18 + AGE via Prisma 7.x.

Stack

LayerTechnology
RuntimeBun 1.3.10+
LanguageTypeScript 5.9+
FrameworkElysiaJS + GraphQL Yoga
FederationApollo Federation v2
ORMPrisma 7.x
DatabasePostgres 18 + AGE (graph extension)
Cache / EventsAzure Managed Redis (Redis Streams via @burdenoff/be-sdk)
ObservabilityOpenTelemetry + Prometheus
Schema registryGraphQL Hive Cloud

Repositories

RepoPathWhat
Service~/products/wspace/headshotmarketing/wspace-headshotmarketing-svcGraphQL Yoga server, resolvers, modules
State / DB~/products/wspace/headshotmarketing/wspace-headshotmarketing-stateDocker Compose for local Postgres + Redis

Development

cd ~/products/wspace/headshotmarketing/wspace-headshotmarketing-svc

# Start the state layer (Postgres + Redis)
bun run switch:local

# Install, generate, and run
bun install
bun run gendb
bun run codegen
bun run dev

The service starts on the port configured in its environment (default: host mode, or the ACA-assigned port in containers).

Key scripts

ScriptWhat
bun run devWatch mode with codegen + migrate + gendb
bun run buildCompile to dist/ with Bun target
bun run codegenGenerate GraphQL types from schema
bun run gendbGenerate Prisma client
bun run migrate:deployDeploy Prisma migrations
bun run testVitest unit tests
bun run test:coverageCoverage report (target ≥80%)
bun run sanityformat:check + codegen + gendb + migrate:deploy + lint + type-check + build + coverage + knip
bun run hive:publishPublish subgraph schema to Hive Cloud (development)
bun run hive:publish:stagingPublish to Hive Cloud staging
bun run hive:publish:productionPublish to Hive Cloud production

Architecture

The service follows the Burdenoff microservice pattern:

  • GraphQL Modules — schema and resolvers are organized into domain modules (campaigns, contacts, deals, pipelines, social, ads, etc.).
  • RBAC at the gateway — the workspace public gateway enforces @rbac directives; the service receives identity via x-actor-id, x-actor-type, and x-workspace-id headers.
  • Event-driven — emits and consumes events via Redis Streams through @burdenoff/be-sdk.
  • Multi-tenant — every row is scoped to a workspace; queries are automatically filtered by workspaceId.

Environment

Local development uses .env and .env.local files generated from the dev Key Vault. The service reads:

VariablePurpose
DATABASE_URLPostgres connection (PgBouncer :6432 in alpha/prod)
REDIS_URLAzure Managed Redis (TLS:10000)
HIVE_TOKENGraphQL Hive Cloud publish token
HIVE_REGISTRYHive Cloud registry endpoint

Integration

Other services and tools integrate with HeadshotMarketing through the workspace public gateway, not directly to the service:

  • App shell (headshotmarketing-app) — via Apollo Client 4 to the workspace gateway.
  • CLI (headshotmarketing-cli) — via graphql-request to the workspace + global gateways.
  • SDKs (headshotmarketing-sdk-node, headshotmarketing-sdk-python) — via graphql-request / httpx to the same gateways.
  • Browser extension — via a custom GraphQL client with dual-token headers.
  • VS Code extension — via graphql-request with workspace-scoped tokens.
  • MCP server — via graphql-request in @burdenoff/mcp-libs.

Testing

  • Unit tests — Vitest in the service repo (target ≥80% coverage).
  • Backend E2Eheadshotmarketing-doctor exercises the GraphQL API end-to-end through the gateway.