Skip to content

Package Overview

ModularityJS is organized as a monorepo with packages grouped by role.

Core

PackageDescription
@modularityjs/diAbstract DI contract — decorators and container interface
@modularityjs/di-inversifyInversifyJS implementation of the DI contract
@modularityjs/di-awilixAwilix implementation of the DI contract
@modularityjs/modularityModule system — loader, lifecycle, pools, validators
@modularityjs/pluginsPlugin system with before/after/around interception
@modularityjs/viewComponent registry and recursive view validator

Contracts and Drivers

Each service follows the contract/driver pattern: an abstract contract package and one or more concrete driver packages. See Architecture for details on the two variants (service contracts and module-level contracts).

Service Contracts

ServiceContractDrivers
Cache@modularityjs/cachecache-memory, cache-redis. Extensions: cache-metrics, cache-telemetry
Lock@modularityjs/locklock-memory, lock-redis. Extensions: lock-plugins (@WithLock), lock-cli, lock-telemetry
Queue@modularityjs/queuequeue-memory, queue-redis, queue-rabbitmq. Extensions: queue-jobs (typed background jobs), queue-metrics, queue-telemetry
Session@modularityjs/sessionsession-memory, session-redis, session-database-typeorm, session-database-prisma
Auth@modularityjs/authauth-jwt, auth-api-key, auth-local, auth-oidc, auth-oidc-introspection
Authz@modularityjs/authzauthz-rbac, authz-policy
Storage@modularityjs/storagestorage-memory, storage-local, storage-s3
Search@modularityjs/searchsearch-memory, search-elasticsearch, search-postgres
Metrics@modularityjs/metricsmetrics-memory, metrics-otel, metrics-prometheus. Extensions: http-metrics, http-metrics-prometheus (scrape endpoint), cache-metrics, database-metrics, queue-metrics
Mail@modularityjs/mailmail-memory, mail-nodemailer, mail-queue. Extensions: mail-template, mail-memory-ui
SMS@modularityjs/smssms-memory, sms-twilio, sms-queue
Push@modularityjs/pushpush-memory, push-webpush
Notification@modularityjs/notificationChannels: notification-mail, notification-sms, notification-push
Audit@modularityjs/auditaudit-memory. Stores: audit-database-typeorm, audit-database-prisma
Telemetry@modularityjs/telemetrytelemetry-otel plus the per-contract *-telemetry instrumentation extensions
Encryption@modularityjs/encryptionencryption-aes
I18n@modularityjs/i18ni18n-json
Rate Limit@modularityjs/rate-limitrate-limit-memory, rate-limit-redis. Extensions: rate-limit-plugins (@RateLimited), http-rate-limit, rate-limit-cli, rate-limit-telemetry
Webhook@modularityjs/webhookwebhook-memory, webhook-direct, webhook-queue
Image Processing@modularityjs/media-imagemedia-image-sharp
Video Processing@modularityjs/media-videomedia-video-ffmpeg
Audio Processing@modularityjs/media-audiomedia-audio-ffmpeg
Media (shared)@modularityjs/mediamedia-ffmpeg (FFmpeg utilities), media-storage-stream (storage pipeline extension)
Template@modularityjs/templatetemplate-handlebars, template-ejs
Assets@modularityjs/assetsDrivers: assets-local (filesystem). Bridges: http-assets (serves /static/*), template-assets ( helper). CLI: assets-cli (assets:collect)
Validation@modularityjs/validationvalidation-zod, validation-ajv
Outbox@modularityjs/outboxStores: outbox-memory, outbox-typeorm, outbox-prisma (Postgres). Publisher: outbox-events (→ EventBus). Bridges: outbox-scheduler (cron dispatch + retention), outbox-cli (outbox:dispatch/list/stats/retry), outbox-telemetry (OTel)
Secrets@modularityjs/secretsDrivers: secrets-memory, secrets-vault (HashiCorp Vault), secrets-aws (AWS Secrets Manager), secrets-gcp (GCP Secret Manager). Bridge: secrets-config plugs SecretsService into ConfigSource so secrets flow through ConfigService.resolve()
Feature Flags@modularityjs/feature-flagsDrivers: feature-flags-static (forRoot config), feature-flags-growthbook (GrowthBook SDK). Bridge: http-feature-flags provides @Variant(key) / @Flag(key) parameter decorators backed by getFeatureContext(request)
MFA@modularityjs/mfaPool-based factor model. Drivers: mfa-totp (RFC 6238), mfa-sms / mfa-email (one-time codes via SmsService/MailService), mfa-backup-codes (single-use recovery), mfa-webauthn (passkeys via @simplewebauthn/server). Bridge: http-mfa provides @RequireMfa() guard. App implements MfaSecretStore.

Transport-Pool Contracts

ServiceContractDriversDescription
Logger@modularityjs/loggerlogger-console, logger-fileTransport-pool dispatch with channel routing and level filtering

Module-Level Contracts

ServiceContractDriverDescription
HTTP@modularityjs/httphttp-fastifyPool-based controller discovery with framework-owned decorators
CLI@modularityjs/clicli-commanderPool-based command discovery with Commander.js
Database@modularityjs/databasedatabase-typeorm, database-prisma. Extensions: database-metrics, database-telemetryAbstract DatabaseConnection, MigrationRunner, MigrationGenerator; driver-specific entity/schema registration
Scheduler@modularityjs/schedulerscheduler-croner, scheduler-memory (deterministic manual tick)Cron-based job scheduler with distributed locking
Events@modularityjs/eventsevents-memory, events-redisTyped event bus with pool-based listener discovery and per-handler once deduplication
WebSocket@modularityjs/wsws-fastify, ws-redis (multi-instance fan-out)Gateway-based WebSocket routing with @WsGateway and @OnMessage, rooms, presence

Infrastructure

PackageDescription
@modularityjs/exceptionStructured exception hierarchy with HTTP mapping. Allowed everywhere — no module wiring required.
@modularityjs/retryRetry-policy primitive — computeDelay(policy, attempt) with fixed/exponential strategies, optional jitter and cap. Zero deps, no DI, no Module. Used by queue, webhook-direct, future delivery drivers.
@modularityjs/validation-schemaSchema typing primitive — Schema<T> interface, ValidationResult, and the native-schema side-channel registry (recordNativeSchema / getNativeSchema) used by validation drivers and OpenAPI tooling. Zero deps, no DI, no Module.
@modularityjs/redisShared ioredis client for all Redis drivers
@modularityjs/configScoped configuration with pluggable sources
@modularityjs/config-envEnvironment variable config source

HTTP Extensions

PackageDescription
@modularityjs/http-sessionSession middleware for HTTP — cookie-based session persistence via HttpServer hooks
@modularityjs/http-authAuth middleware for HTTP — token extraction and identity injection via extractor pool
@modularityjs/http-auth-jwtJWT Bearer adapter — registers an HttpAuthenticator that reads Authorization: Bearer and resolves identity via JwtAuthService
@modularityjs/http-auth-api-keyAPI key extractor adapter — registers X-API-Key header extractor
@modularityjs/http-auth-localLocal auth adapter — HTTP Basic authentication
@modularityjs/http-auth-oidcOIDC Bearer token adapter
@modularityjs/http-auth-sessionSession-based auth adapter — resolves identity from session data
@modularityjs/http-authzAuthorization enforcement — @RequirePermission() checked in the HTTP adapter pipeline (before guards) via AuthzService.can()
@modularityjs/http-uploadAbstract upload contract — HttpUploadConfig (max size, MIME allowlist) + sanitizeFilename; driver-agnostic
@modularityjs/http-fastify-uploadFastify driver — registers @fastify/multipart and binds @UploadedFile()/@UploadedFiles() resolvers
@modularityjs/http-fastify-formbodyFastify-driver extension — registers @fastify/formbody for application/x-www-form-urlencoded bodies
@modularityjs/http-storageUpload-to-storage integration — HttpStorageService with store() and download()
@modularityjs/http-i18nLocale extraction middleware
@modularityjs/http-rate-limitRate limiting middleware
@modularityjs/http-validationValidation parameter decorators — @ValidatedBody/Query/Params/Headers(schema) returning 422 on failure
@modularityjs/http-fastify-corsFastify-driver extension — registers @fastify/cors with framework-managed config
@modularityjs/http-fastify-compressionFastify-driver extension — registers @fastify/compress (br/gzip/deflate)
@modularityjs/http-fastify-security-headersFastify-driver extension — registers @fastify/helmet (CSP, HSTS, X-Frame-Options, …)
@modularityjs/http-csrfCSRF protection — session-stored or HMAC double-submit; @CsrfProtect() decorator
@modularityjs/http-htmxHTMX decorator — request helpers and partial-response conventions
@modularityjs/http-mfaMFA decorator — @RequireMfa() guard backed by MfaService via session attrs
@modularityjs/http-feature-flagsFeature-flags adapter — @Variant(key) / @Flag(key) parameter decorators
@modularityjs/http-openapiServes /openapi.json plus a /docs UI via the OpenApiUiRenderer contract
@modularityjs/http-openapi-swaggerSwagger UI driver — binds OpenApiUiRenderer + ships swagger-ui-dist through the assets pipeline
@modularityjs/http-openapi-redocRedoc driver — binds OpenApiUiRenderer + ships redoc.standalone through the assets pipeline
@modularityjs/http-openapi-rapidocRapiDoc driver — binds OpenApiUiRenderer + ships rapidoc-min through the assets pipeline
@modularityjs/http-openapi-scalarScalar API Reference driver — binds OpenApiUiRenderer + ships the standalone bundle through the assets pipeline
@modularityjs/http-telemetryOpenTelemetry HTTP spans for requests and routes
@modularityjs/http-assetsServes hashed static assets at /static/* from the assets pipeline
@modularityjs/http-webhookWebhook endpoint adapter
@modularityjs/http-health/health, /health/live, /health/ready endpoints with probe-filtered aggregation
@modularityjs/http-idempotency@Idempotent — replay-safe mutating routes over cache + lock
@modularityjs/http-metricsRequest counter, duration histogram, in-flight gauge off the abstract request lifecycle
@modularityjs/http-request-idX-Request-Id propagation + @RequestId() parameter resolver
@modularityjs/http-request-id-loggerBridges the ambient request id into every log entry via LogContextProvidersPool
@modularityjs/http-cache@CacheResponse — GET responses cached in CacheService with weak ETag / 304s
@modularityjs/http-pagination@Page() resolver and the paginate() envelope
@modularityjs/http-serializationOutbound response shaping — Resource classes and @SerializeWith
@modularityjs/http-tenancyPer-request tenant resolution entering the tenant scope

Extensions

PackageDescription
@modularityjs/healthHealth indicators with liveness/readiness probe classification. Built-ins: redis-health, database-health, search-elasticsearch-health
@modularityjs/scopeScope chain resolver for multi-tenant contexts
@modularityjs/exceptionStructured exception hierarchy
@modularityjs/auth-oidc-clientOAuth2/OIDC Authorization Code flow helpers (OidcClientService, OidcFlowService with PKCE)
@modularityjs/auth-local-email-verificationHashed single-use email-verification tokens with memory / TypeORM / Prisma stores
@modularityjs/testingcreateTestHarness(), createHttpTestClient(), and the cross-driver conformance suites
@modularityjs/mcp-serverMCP server contract — expose the app's operations as Model Context Protocol tools (McpToolsPool)
@modularityjs/http-fastify-mcp-serverFastify driver for mcp-server — streamable-HTTP MCP endpoint at /mcp, optional Bearer apiKey
@modularityjs/http-dev-console/dev console — modules, pools, preferences, routes; extensible via DevConsolePanelsPool
@modularityjs/config-cliconfig:print — effective value + winning source per declared path, secrets redacted
@modularityjs/config-env-cliconfig:env:example — generate .env.example from the declared config schema
@modularityjs/runnerThe modularity bin — dev/start/cli, verify, add, doctor, generators