Skip to content

Recipes

Working wiring examples with the sharp edges annotated — each recipe is a complete, compiling setup for one capability, plus the mistakes that look right but aren't. The same content is served to coding agents by the MCP server (get_recipe <name>) from @modularityjs/manifest; these pages and the MCP tool share one source, so they never drift apart.

If you're starting from zero, do the Tutorial first — it walks one app from scaffold to verified CRUD API. Recipes are the reference you come back to per capability.

Orientation

  • Minimal App — the smallest complete boot: one controller, one service, createApp.
  • Project Structure — the layered domain blueprint pnpm modularity generate domain scaffolds.
  • Best Practices — the habits that keep an app aligned with the framework's grain.
  • Anti-Patterns — code that compiles but is semantically wrong here (NestJS habits, pool misuse, wrong wrap layer).

Wiring by capability

  • AuditAuditService.record/find, store drivers, PII discipline
  • Auth — resolver chain, HTTP authenticators, @RequireAuth
  • CacheCacheService, TTLs, tag invalidation, atomic operations
  • Database — entities pool, repositories, migrations
  • Transactions@Transactional, propagation, transaction-aware handles
  • Email Verification — hashed single-use tokens, markEmailVerified, enumeration safety
  • Events — typed bus, @OnEvent, runtime subscription
  • File Uploads — multipart limits, @UploadedFile, sanitization
  • GraphQL — SDL pool, resolvers, mercurius mounting
  • Health — liveness vs readiness probes, /health/* endpoints, k8s config
  • Idempotency@Idempotent replay, 409 concurrency, retryable failures
  • Jobs@JobDefinition classes, dispatch-by-class over any queue driver
  • Outbox — reliable event publication with stores and dispatchers
  • Search — index declaration, portable query union
  • SerializationResource classes, @SerializeWith, groups
  • Session — session stores and the HTTP extension
  • Storage — the storage contract and drivers
  • Tenancy — tenant resolution, scope chain, per-tenant config
  • ValidationValidator, @ValidatedBody, schema registry
  • WebSocket — gateways, message handlers, connection lifecycle