ddd-microservices
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
- Map bounded contexts to identify natural service boundaries
- Define aggregates within each service for data consistency
- Design communication: synchronous for queries and strong consistency; asynchronous (domain events) for decoupling
- 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
- Building Microservices by Sam Newman
- Domain-Driven Design by Eric Evans
- https://microservices.io/
Keywords
ddd microservices, bounded context, aggregate, domain events, service boundary, Saga pattern, CQRS, database per service, eventual consistency, API gateway
More from partme-ai/full-stack-skills
vite
Guidance for Vite using the official Guide, Config Reference, and Plugins pages. Use when the user needs Vite setup, configuration, or plugin selection details.
68element-plus-vue3
Provides comprehensive guidance for Element Plus Vue 3 component library including installation, components, themes, internationalization, and API reference. Use when the user asks about Element Plus for Vue 3, needs to build Vue 3 applications with Element Plus, or customize component styles.
63vue3
Guidance for Vue 3 using the official guide and API reference. Use when the user needs Vue 3 concepts, patterns, or API details to build components, apps, and tooling.
54electron
Build cross-platform desktop applications with Electron, covering main/renderer process architecture, IPC communication, BrowserWindow management, menus, tray icons, packaging, and security best practices. Use when the user asks about Electron, needs to create desktop applications, implement Electron features, or build cross-platform desktop apps.
51uniapp-project
Provides per-component and per-API examples with cross-platform compatibility details for uni-app, covering built-in components, uni-ui components, and APIs (network, storage, device, UI, navigation, media). Use when the user needs official uni-app components or APIs, wants per-component examples with doc links, or needs platform compatibility checks.
40ascii-cli-logo-banner
Entry point for ASCII CLI banners that routes to the Python built-in font skill or figlet.js/FIGfont skill. Use when the user wants a startup banner, ASCII logo, terminal welcome screen, or CLI branding for a service.
38