Skip to content

mbc-net/mbc-cqrs-serverless

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,102 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MBC CQRS serverless framework

MBC CQRS Serverless Framework

Build production-ready serverless applications on AWS in minutes, not months.

npm version License: MIT TypeScript NestJS

Documentation | Getting Started | Examples | API Reference


Why MBC CQRS Serverless?

Building enterprise-grade serverless applications on AWS is hard. You need to handle:

  • Event sourcing and CQRS patterns
  • Multi-tenancy and data isolation
  • DynamoDB to RDS synchronization
  • Sequence number generation
  • Async task processing
  • ...and much more

MBC CQRS Serverless provides all of this out of the box, so you can focus on your business logic.

Key Benefits

Feature What You Get
Zero to API in 5 minutes CLI generates complete project structure with best practices
Built-in Multi-tenancy Data isolation, tenant settings, and RBAC out of the box
Event Sourcing Full audit trail with DynamoDB Streams and automatic RDS sync
Local Development Complete offline mode with Docker - no AWS costs during development
Production Ready Battle-tested in enterprise SaaS applications

Quick Start

# Install CLI
npm install -g @mbc-cqrs-serverless/cli

# Create new project
mbc new my-saas-app

# Start development
cd my-saas-app
npm install
npm run build            # Build the project
npm run offline:docker   # Start local AWS services
npm run migrate          # Run database migrations
npm run offline:sls      # Start API server

That's it! Your API is running at http://localhost:4000


See It in Action

Quick Start Demo

Create a CRUD endpoint in 30 lines:

// todo.controller.ts
@Controller('api/todo')
export class TodoController {
  constructor(
    private readonly commandService: CommandService,
    private readonly dataService: DataService,
  ) {}

  @Post()
  async create(@Body() dto: CreateTodoDto, @IInvoke() invokeContext: IInvoke) {
    const command = new TodoCommandDto({
      pk: dto.pk,
      sk: dto.sk,
      tenantCode: invokeContext.tenantCode,
      name: dto.name,
      attributes: { description: dto.description },
    });
    return this.commandService.publishSync(command, { invokeContext });
  }

  @Get(':pk/:sk')
  async findOne(@Param('pk') pk: string, @Param('sk') sk: string) {
    return this.dataService.getItem({ pk, sk });
  }
}

What happens automatically:

  • Command is validated and persisted to DynamoDB
  • Event is emitted via DynamoDB Streams
  • Data is synced to RDS for complex queries
  • Full audit trail is maintained
  • Multi-tenant isolation is enforced

Architecture

┌─────────────────────────────────────────────────────────────────────┐
│                         Your Application                             │
├─────────────────────────────────────────────────────────────────────┤
│                                                                      │
│   Client Request                                                     │
│        │                                                             │
│        ▼                                                             │
│   ┌─────────┐    ┌─────────┐    ┌──────────────┐                    │
│   │   API   │───▶│ Service │───▶│ CommandService│                    │
│   │ Gateway │    │  Layer  │    │   (Write)    │                    │
│   └─────────┘    └─────────┘    └──────────────┘                    │
│                       │                │                             │
│                       │                ▼                             │
│                       │         ┌──────────────┐                    │
│                       │         │  DynamoDB    │──── Stream ───┐    │
│                       │         │  (Commands)  │               │    │
│                       │         └──────────────┘               ▼    │
│                       │                              ┌──────────────┐│
│                       ▼                              │Step Functions││
│                ┌──────────────┐                      └──────────────┘│
│                │ DataService  │                              │       │
│                │   (Read)     │                              ▼       │
│                └──────────────┘                      ┌──────────────┐│
│                       │                              │  DynamoDB    ││
│                       ▼                              │   (Data)     ││
│                ┌──────────────┐                      └──────────────┘│
│                │     RDS      │◀──── Sync ───────────────────┘       │
│                │   (Query)    │                                      │
│                └──────────────┘                                      │
│                                                                      │
└─────────────────────────────────────────────────────────────────────┘

Packages

Package Description Version
@mbc-cqrs-serverless/core Core CQRS framework with AWS integrations npm
@mbc-cqrs-serverless/cli CLI tool for project scaffolding npm
@mbc-cqrs-serverless/tenant Multi-tenancy support npm
@mbc-cqrs-serverless/master Master data and hierarchical settings npm
@mbc-cqrs-serverless/sequence Sequence number generation with rotation npm
@mbc-cqrs-serverless/task Async task processing and queue management npm
@mbc-cqrs-serverless/import Data import with CSV and REST support npm
@mbc-cqrs-serverless/ui-setting UI configuration management npm

Features

Core Framework

  • CQRS Pattern - Clean separation of commands (writes) and queries (reads)
  • Event Sourcing - Complete audit trail with immutable event log
  • Optimistic Locking - Automatic conflict resolution for concurrent updates

AWS Integration

  • Lambda - Serverless compute with automatic scaling
  • DynamoDB - Event store and data persistence
  • RDS/Aurora - Complex queries with Prisma ORM
  • Cognito - Authentication and authorization
  • Step Functions - Workflow orchestration
  • SNS/SQS - Event-driven messaging

Enterprise Features

  • Multi-tenancy - Built-in tenant isolation and settings hierarchy
  • Sequence Generation - Auto-incrementing IDs with date rotation
  • Master Data - Centralized configuration management
  • Async Tasks - Background job processing with retries

Developer Experience

  • Full TypeScript - Type-safe development with excellent IDE support
  • NestJS Foundation - Familiar patterns and dependency injection
  • Local Development - Complete offline mode with Docker
  • CLI Tools - Project scaffolding and code generation

Examples

Check out our sample repository for complete working examples:

Example Description
step-01-setup Environment setup
step-02-create Create operations with CommandService
step-03-rds-sync DynamoDB to RDS synchronization
step-04-read Read operations with DataService
step-05-search Search with Prisma/RDS
step-06-update-delete Update and soft delete
step-07-sequence Sequence number generation
complete/basic Full CRUD implementation

Documentation

Visit our documentation site for:


Installation

Latest Stable Release

npm install -g @mbc-cqrs-serverless/cli

Beta Release (Latest Features)

npm install -g @mbc-cqrs-serverless/cli@beta

Specific Version

npm install -g @mbc-cqrs-serverless/cli@1.0.17

Contributing

We welcome contributions! Please see our Contributing Guide for details.

# Clone the repository
git clone https://github.com/mbc-net/mbc-cqrs-serverless.git

# Install dependencies
npm install

# Build all packages
npm run build

# Run tests
npm test

Development Workflow

  1. Fork the repository
  2. Create a feature branch from develop
  3. Make your changes with tests
  4. Submit a pull request

Community


License

Copyright © 2024-2025, Murakami Business Consulting, Inc.

This project is licensed under the MIT License.


Get Started Now | View Examples | Read the Docs

Made with love for the serverless community

About

serverless applications with CQRS on AWS, NestJS and local development

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Contributors

Languages