mcpField
D
ddd-microservices

ddd-microservices

github.com/partme-aiDevelopment71681 installsUpdated 3w ago
Repository

About ddd-microservices

A design skill for developers applying domain-driven design to microservices. It covers service boundaries, aggregates, communication choices, data ownership, and consistency strategies.

Key features

  1. 01Map bounded contexts to services
  2. 02Define aggregates and domain events
  3. 03Choose synchronous or asynchronous communication
  4. 04Set service-level data ownership
  5. 05Plan eventual consistency and Saga patterns

Use cases

  1. 01Identify service boundaries before decomposition
  2. 02Design REST, gRPC, or event-based contracts
  3. 03Plan cross-service consistency
  4. 04Specify database ownership per service

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/partme-ai/full-stack-skills --skill ddd-microservices

After installing, type/ddd-microservicesin Claude Code to confirm it loaded.

Bundled filesLICENSE.txt

Details

From the project README

When to use this skill

Use this skill whenever the user wants to:

  • Use DDD to define microservice boundaries (bounded contexts, aggregates, domain events)
  • Design inter-service contracts and event-driven communication
  • Implement cross-service consistency, querying, and operational strategies
  • Decide between synchronous (REST/gRPC) and asynchronous (events/messaging) communication

How to use this skill

Workflow
  1. Map bounded contexts to identify natural service boundaries
  2. Define aggregates within each service for data consistency
  3. Design communication: synchronous for queries and strong consistency; asynchronous (domain events) for decoupling
  4. Ensure data ownership: each service owns its database; share data via APIs or events
1. Bounded Context to Service Mapping
E-Commerce Domain:
├── Order Service        ← Order bounded context
│   ├── Order aggregate
│   └── OrderPlaced event
├── Inventory Service    ← Inventory bounded context
│   ├── Product aggregate
│   └── StockReserved event
├── Payment Service      ← Payment bounded context
│   ├── Payment aggregate
│   └── PaymentCompleted event
└── Notification Service ← Cross-cutting
    └── Subscribes to all domain events
2. Synchronous Communication (Feign/gRPC)
@FeignClient(name = "inventory-service")
public interface InventoryClient {
    @GetMapping("/api/products/{id}/stock")
    StockInfo getStock(@PathVariable String id);
}
3. Asynchronous Communication (Domain Events)
// Order Service publishes
@Transactional
public void placeOrder(PlaceOrderCommand cmd) {
    Order order = Order.create(cmd);
    orderRepository.save(order);
    eventPublisher.publish(new OrderPlacedEvent(order.getId(), order.getItems()));
}

// Inventory Service subscribes
@EventListener
public void onOrderPlaced(OrderPlacedEvent event) {
    inventoryService.reserveStock(event.getItems());
}
4. Database per Service
Order Service      → order_db (PostgreSQL)
Inventory Service  → inventory_db (PostgreSQL)
Payment Service    → payment_db (PostgreSQL)

Best Practices

  • Define bounded contexts clearly before splitting into services; avoid premature decomposition
  • Use domain events to express cross-aggregate and cross-service facts; ensure idempotency and ordering
  • Define clear SLAs, data ownership, and failure boundaries for each service
  • Prefer eventual consistency with compensating transactions (Saga pattern) over distributed transactions

Resources

Keywords

ddd microservices, bounded context, aggregate, domain events, service boundary, Saga pattern, CQRS, database per service, eventual consistency, API gateway

Comments

Markdown supported