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
| Module | Package | Description |
|---|---|---|
| Command Module | @mbc-cqrs-serverless/core | CQRS command handling, data synchronization, event sourcing |
| Sequence Module | @mbc-cqrs-serverless/sequence | Thread-safe sequential ID generation |
| Tenant Module | @mbc-cqrs-serverless/tenant | Multi-tenant data isolation and management |
Feature Modules
| Module | Package | Description |
|---|---|---|
| Task Module | @mbc-cqrs-serverless/task | Async task execution with Step Functions |
| Master Module | @mbc-cqrs-serverless/master | Master data and settings management |
| Import Module | @mbc-cqrs-serverless/import | Large-scale CSV import with Distributed Map |
Support Modules
| Module | Package | Description |
|---|---|---|
| Notification Module | @mbc-cqrs-serverless/core | Email notifications via Amazon SES |
| Setting Module | @mbc-cqrs-serverless/ui-setting | User 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:
🗃️ Command Module
3 items
📄️ Sequence
Sequence setup and usage.
📄️ Task
Learn how to create and process long-running task
📄️ Tenant
Learn how to use TenantModule for multi-tenant management in MBC CQRS Serverless.
📄️ Master
Learn about the Master Service for managing master data and settings in a multi-tenant environment.
📄️ Directory
Directory management functionality with S3 integration for the MBC CQRS Serverless framework.
🗃️ Notification Module
1 item
📄️ UI Setting
Learn how to manage UI settings and data configurations with the UI Setting module.