Skip to main content

Modules

The MBC CQRS Serverless framework provides a comprehensive set of modules for building enterprise-grade serverless applications. Each module is designed to handle specific concerns while maintaining consistency with the CQRS and Event Sourcing patterns.

Module Overview

Core Modules

ModulePackageDescription
Command Module@mbc-cqrs-serverless/coreCQRS command handling, data synchronization, event sourcing
Sequence Module@mbc-cqrs-serverless/sequenceThread-safe sequential ID generation
Tenant Module@mbc-cqrs-serverless/tenantMulti-tenant data isolation and management

Feature Modules

ModulePackageDescription
Task Module@mbc-cqrs-serverless/taskAsync task execution with Step Functions
Master Module@mbc-cqrs-serverless/masterMaster data and settings management
Import Module@mbc-cqrs-serverless/importLarge-scale CSV import with Distributed Map

Support Modules

ModulePackageDescription
Notification Module@mbc-cqrs-serverless/coreEmail notifications via Amazon SES
Setting Module@mbc-cqrs-serverless/ui-settingUser interface configuration storage

Quick Start

Install the core package:

npm install @mbc-cqrs-serverless/core

Register the CommandModule in your application:

import { CommandModule } from '@mbc-cqrs-serverless/core';

@Module({
imports: [
CommandModule.register({
tableName: 'your-table-name',
}),
],
})
export class YourModule {}

Common Patterns

Service Injection

All services are available for injection in your NestJS providers:

import { CommandService, DataService } from '@mbc-cqrs-serverless/core';

@Injectable()
export class YourService {
constructor(
private readonly commandService: CommandService,
private readonly dataService: DataService,
) {}
}

Multi-Tenant Context

Most operations require tenant context for data isolation:

async createItem(tenantCode: string, data: CreateDto, invokeContext: IInvoke) {
return this.commandService.publishAsync({
pk: `${tenantCode}#ITEM`,
sk: data.id,
tenantCode,
// ... other fields
}, { invokeContext });
}

Module Documentation

Explore each module's detailed documentation: