This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Mosaic Media Template — a monorepo for media management services built on the Axinom Mosaic platform. Contains 5 backend services (media, catalog, entitlement, channel, vod-to-live), shared libraries, and React micro-frontend workflows.
# Install dependencies
yarn
# Create local .env files from templates
yarn apply-templates
# Start Docker infrastructure (PostgreSQL, RabbitMQ, pgAdmin)
yarn infra:up
yarn infra:down
# Database setup
yarn db:reset # Create/reset databases
yarn setup # Initialize all services
# Development
yarn dev:libs # Watch-compile libs/media-messages
yarn dev:services # Watch-compile all services
yarn dev:workflows # Start workflow dev server on port 10053
# Testing
yarn test:reset:dbs # Initialize test databases (run once before tests)
yarn test # Run all tests
yarn test:ci # CI mode with JUnit coverage reports
# Building
yarn build # Build all services (excludes vod-to-live and channel by default)
yarn lint # ESLint with auto-fix
# Database migrations
yarn db:commit # Commit schema to migration history
yarn db:update-schema # Update schema dumpTo run a single test file:
yarn jest path/to/file.spec.tsservices/*/service/— Node.js backend servicesservices/*/workflows/— React micro-frontend UI for management UI (not present for all services)libs/media-messages/— Shared message type definitions (commands, events, payloads) shared across services
Each service follows the same structure under src/:
index.ts— Bootstrap: Express, PostGraphile, auth middleware, message bus, DB poolsdomains/— Business logic grouped by domain (e.g., movies, tvshows, collections)graphql/— PostGraphile setup and custom GraphQL pluginsmessaging/— RabbitMQ message handlers and registrationingest/— Data ingestion logicpublishing/— Publishing/snapshot logicgenerated/— Auto-generated DB types (Zapatos) and GraphQL types; do not edit manuallytests/— Integration/DB tests (.db.spec.tssuffix)
Key technologies per service:
- Database: PostgreSQL + Zapatos (type-safe query builder with generated types)
- GraphQL API: PostGraphile — auto-generates GraphQL from DB schema
- Auth:
@axinom/mosaic-id-guardmiddleware (Axinom ID service) - Messaging: RabbitMQ via
@axinom/mosaic-message-buswith transactional inbox/outbox pattern (@axinom/mosaic-transactional-inbox-outbox) - Migrations:
graphile-migrate
Bootstrap sequence (index.ts): load config → check ID service → run migrations → create DB pools → sync permissions → register message bus → setup PostGraphile → start HTTP server.
Located in services/*/workflows/src/:
index.tsx— Entry pointStations/— Feature areas (e.g., Movies, TV Shows)apolloClient/— GraphQL client setuppiletConfig.ts— Piral configuration
Dev server runs on port 10053 and connects to a host Mosaic application.
After modifying GraphQL queries or mutations in a workflow, regenerate TypeScript types by running yarn codegen from the workflow package directory (e.g., services/media/workflows/). This runs graphql-codegen against the configured schema and outputs typed hooks and operations into the generated/ folder. Requires the corresponding backend service to be running.
libs/media-messages/ contains shared event/command schemas. Types are code-generated via @axinom/mosaic-cli msg-codegen. After changing schemas, regenerate types before using them in services.
- TypeScript 4.9, Node 22 (see
.nvmrc) target across all packages - Functional style — avoid classes where possible, prefer functions and plain objects
- ESLint enforces: no
any, explicit return types on module boundaries, noconsole.log(except in tests), top-leveldescribeblocks in tests - Prettier: single quotes, trailing commas, arrow parens always
- Test files:
*.spec.ts(unit) and*.db.spec.ts(integration with DB) - DB integration tests use
createTestContext()to get a pooled connection; clean up inafterEach