- Java Microservices Tutorial
- Java Microservices - Home
- Microservices - Introduction
- Microservices vs Monolith vs SOA
- Java Microservices - Environment Setup
- Java Microservices - Advantages of Spring Boot
- Java Microservices - Design Patterns
- Java Microservices - Domain Driven Design
- Java Microservices - Decomposition by Business Capability
- Java Microservices - Decomposition by Subdomain
- Java Microservices - Backend for Frontend
- Java Microservices - The Strangler Pattern
- Java Microservices - Synchronous Communication
- Java Microservices - Asynchronous Communication
- Java Microservices - Saga Pattern
- Java Microservices - Centralized Logging (ELK Stack)
- Java Microservices - Event Sourcing
- Java Microservices - CQRS Pattern
- Java Microservices - Sidecar Pattern
- Java Microservices - Service Mesh Pattern
- Java Microservices - Circuit Breaker Pattern
- Java Microservices - Distributed Tracing
- Java Microservices - Control Loop Pattern
- Java Microservices - Database Per Service
- Java Microservices - Bulkhead Pattern
- Java Microservices - Health Check API
- Java Microservices - Retry Pattern
- Java Microservices - Fallback Pattern
- Java Microservices Useful Resources
- Java Microservices Quick Guide
- Java Microservices Useful Resources
- Java Microservices Discussion
Java Microservices - Decomposition by Business Capability
Introduction
Microservices architecture enables the development of complex systems as a suite of independently deployable, modular services. One of the most critical aspects of microservices design is how to decompose a large application into smaller, manageable services. This article focuses on a key decomposition strategy: Decomposition by Business Capability.
This pattern emphasizes splitting services based on business domains rather than technical layers, promoting better alignment with organizational structures, product thinking, and scalability.
What Is Decomposition in Microservices?
In a microservices system, decomposition refers to the act of breaking down a monolithic application into independently deployable units (microservices). Each unit should have −
A well-defined boundary
Autonomy over its data and logic
A clear business purpose
Poor decomposition can lead to tightly coupled services, redundancy, and operational inefficiencies.
Understanding Business Capability
A business capability is something that the business does or needs to do to achieve its objectives. It is −
Stable over time
Independent from organizational changes
Often modeled using Domain-Driven Design (DDD)
Examples of Business Capabilities
| Sr.No. | Business Domain | Business Capabilities |
|---|---|---|
| 1 | E-commerce | Order Management, Payments, Customer Service |
| 2 | Banking | Account Management, Loans, Risk Analysis |
| 3 | Healthcare | Patient Records, Appointments, Billing |
Pattern − Decomposition by Business Capability
Definition
Decomposition by business capability is a microservices design pattern that organizes services around what the business does, not how the software is technically layered.
Core Principle
Each microservice corresponds to a single business capability, becoming the owner of all data and logic related to that capability.
Benefits of Decomposition by Business Capability
| Sr.No. | Benefit | Description |
|---|---|---|
| 1 | High cohesion | Services are focused and internally consistent. |
| 2 | Loose coupling | Independent deployment and scalability. |
| 3 | Clear ownership | Easier to assign to teams (Team-Service alignment). |
| 4 | Faster development | Services evolve independently without breaking other components. |
| 5 | Better DDD alignment | Ties naturally with DDD's Bounded Contexts. |
Applying the Pattern: A Case Study
Scenario: Building an Online Retail Platform
Monolith Capabilities
User management
Product catalog
Order management
Payment processing
Decomposed Microservices
| Sr.No. | Microservice | Business Capability |
|---|---|---|
| 1 | user-service | User registration, profiles |
| 2 | product-service | Product listings, categories |
| 3 | order-service | Cart, checkout, orders |
| 4 | payment-service | Payment processing |
Step-by-Step Implementation (Spring Boot)
We'll use Spring Boot to demonstrate decomposition by business capability.
Create Individual Services.
user-service − User Capability
UserController.java
@RestController
@RequestMapping("/users")
public class UserController {
@GetMapping("/{id}")
public String getUser(@PathVariable String id) {
return "User profile for ID: " + id;
}
}
product-service − Product Capability
ProductController.java
@RestController
@RequestMapping("/products")
public class ProductController {
@GetMapping("/{id}")
public String getProduct(@PathVariable String id) {
return "Product details for ID: " + id;
}
}
order-service − Order Capability
OrderController.java
@RestController
@RequestMapping("/orders")
public class OrderController {
@PostMapping("/")
public String placeOrder(@RequestBody String orderData) {
return "Order placed successfully";
}
}
payment-service − Payment Capability
PaymentController.java
@RestController
@RequestMapping("/payments")
public class PaymentController {
@PostMapping("/")
public String makePayment(@RequestBody String paymentData) {
return "Payment successful";
}
}
Each service is an isolated Spring Boot application, deployed independently, with its own database.
Communication Between Business Capabilities
Inter-service communication is done via REST or asynchronous messaging.
REST Example from Order to Payment
@Autowired
private RestTemplate restTemplate;
public String callPaymentService() {
return restTemplate.postForObject("http://payment-service/payments", new Payment(), String.class);
}
Integration with Domain-Driven Design (DDD)
Decomposition by business capability is closely aligned with DDD's Bounded Context.
Bounded Context Example
ProductContext → product-service
CustomerContext → user-service
OrderContext → order-service
Each service is a self-contained model and is responsible for its own aggregates, entities, and repositories.
Database Design per Capability
Each microservice manages its own database. This ensures −
Loose coupling
Independent schema evolution
Avoidance of shared database anti-pattern
Example
| Sr.No. | Service | Table |
|---|---|---|
| 1 | user-service | Users |
| 2 | product-service | products, categories |
| 3 | order-service | orders, order_items |
Challenges in This Pattern
| Sr.No. | Challenge | Description |
|---|---|---|
| 1 | Data consistency | No distributed transactions; must use eventual consistency |
| 2 | Cross-cutting concerns | Logging, auth, monitoring must be centralized |
| 3 | Service granularity confusion | Too fine-grained = overhead; too coarse = mini-monolith |
| 4 | Initial complexity | More moving parts to manage compared to monolith |
Real-World Examples
| Sr.No. | Company | Business Capability-based Microservices |
|---|---|---|
| 1 | Amazon | Order, Inventory, Delivery, Payment |
| 2 | Netflix | Playback, Recommendations, Membership |
| 3 | Uber | Ride Booking, Payments, Driver Management |
These companies structure services around business functions, not technical tiers.
Conclusion
Decomposition by Business Capability is one of the most effective strategies for structuring microservices. It helps design systems that are −
Modular and scalable
Aligned with business goals
Easy to manage and evolve
This pattern provides a strong foundation for team autonomy, agile development, and cloud-native deployment.