
Applying Strategic DDD to Design Microservices for AWS
A practical look at how I used Strategic Domain-Driven Design to model microservices for a university project that will be deployed on AWS, from identifying bounded contexts to planning the next architectural steps.
Information Systems student learning cloud computing and DevOps.
When designing a cloud application, it is tempting to start by choosing AWS services and deciding how many microservices the system should have. However, I wanted to take a different approach in a university project: understand the domain first and define the architecture before mapping it to the cloud.
For this project, I decided to use Domain-Driven Design (DDD). This article presents the initial stage of the project, focused on Strategic DDD, and explains how it helped define the boundaries and responsibilities of the microservices.
The architecture is still evolving.
The Application Domain
The application is a crowdfunding platform where users can create campaigns and other users can contribute financially to them.
Some of the main domain activities include:
- Creating and managing campaigns
- Making contributions
- Holding funds until a campaign is completed
- Calculating participation and distributing returns
- Managing user accounts
- Verifying user identities
- Sending notifications
Instead of immediately turning each activity into a microservice, I first analyzed the domain using Strategic DDD.
Why Strategic DDD?
Strategic DDD helps organize a complex domain by identifying its main business areas and defining clear boundaries between them.
Three concepts were particularly important in this stage:
- Subdomains — areas of the business with different levels of importance.
- Bounded Contexts — boundaries within which a domain model and its terminology have a consistent meaning.
- Context Map — relationships and dependencies between bounded contexts.
This approach helped me focus on the business domain before thinking about infrastructure.
Identifying the Subdomains
The first step was to divide the application into subdomains and classify them as Core, Supporting, or Generic.
Subdomain | Classification | Responsibility |
|---|---|---|
Campaign Management | Core | Create, manage, moderate, and publish campaigns |
Contributions | Core | Register and process investor contributions |
Custody (Escrow) | Core | Hold, release, or return funds |
Participation and Returns | Supporting | Calculate participation and distribute returns |
Accounts and Users | Supporting | Registration, authentication, and profiles |
Identity Verification (KYC) | Generic | Validate user identity |
Notification | Generic | Notify users about relevant events |
The Core subdomains represent the most important parts of the business domain. Supporting subdomains provide necessary functionality, while Generic subdomains can potentially rely on solutions already available in the market.
Defining the Bounded Contexts
After identifying the subdomains, I defined seven bounded contexts.
Each context received a specific responsibility and its own domain concepts.
For example, Campaign Management is responsible for the
Campaign aggregate, while Contributions is responsible for the Contribution aggregate.The contexts defined were:
- Campaign Management
- Contributions
- Custody
- Participation and Returns
- Accounts and Users
- Identity Verification (KYC)
- Notification
This separation prevents unrelated responsibilities from being mixed into the same domain model.
Creating the Context Map
The next step was to understand how these contexts communicate and depend on each other.
Some of the relationships identified were:
- Accounts and Users → Campaign Management: Open Host Service + Published Language
- Accounts and Users → KYC: Open Host Service + Published Language
- Campaign Management → Contributions: Customer/Supplier
- KYC → Contributions: Anti-Corruption Layer
- Contributions → Custody: Customer/Supplier
- Custody → Participation and Returns: Customer/Supplier
- Custody → Campaign Management: Customer/Supplier
- All contexts → Notification: Conformist
For example, when a contribution is validated, the Contributions context can communicate an
ContributionConfirmed event to the Custody context.This mapping makes the dependencies between parts of the system explicit instead of leaving them implicit in the implementation.
From Bounded Contexts to Microservices
An important lesson from this stage was that a Bounded Context is not necessarily the same thing as a deployable microservice.
Strategic DDD identified seven bounded contexts, but for the scope of the university project, I decided to group some of them.
The resulting deployment architecture contains five microservices:
- Campaign Management
- Contributions
- Custody and Returns
- Identity
- Notification
The Custody and Returns service groups the Custody and Participation and Returns contexts, while the Identity service groups Accounts and Users with KYC.
Even when contexts are deployed together, they remain logically separated internally. This preserves the boundaries defined during the strategic analysis and makes it possible to extract them into independent services later if necessary.
What Comes Next?
The Strategic DDD stage is only the beginning of the architecture process.
The next steps are focused on turning the domain model into a more concrete technical architecture.
1. Define Communication Contracts
Once the service boundaries and architecture are established, the next stage will be to define the communication contracts between microservices.
These contracts will specify aspects such as:
- Direction of communication
- Payload
- Guarantees
- Expected behavior
- Failure handling
This will make the interactions between services explicit before implementation.
2. Apply Tactical DDD
After the strategic boundaries are established, I will move to Tactical DDD.
This stage will focus on modeling the internal structure of each bounded context, including concepts such as:
- Entities
- Value Objects
- Aggregates
- Repositories
- Domain Services
- Domain Events
This creates a connection between the strategic model and the actual implementation of each service.
3. Select Design Patterns
The next stage is to select appropriate architectural and design patterns for communication, consistency, and resilience.
The goal is not to apply patterns simply because they are popular, but to choose them according to the relationships and requirements identified in the domain model.
4. Create the C4 Model
After defining the main architectural decisions, I will create the C4 Model, focusing initially on the Context and Container levels.
This will provide a clearer visual representation of the system, its users, microservices, and their relationships.
5. Map the Architecture to AWS
Only after defining the logical architecture will the components be mapped to AWS services.
This means deciding which AWS services can support each container, considering requirements such as scalability, availability, security, and operational needs.
The objective is to avoid letting the cloud provider dictate the domain architecture.
6. Define the Cloud Infrastructure
The architecture will then be materialized as a cloud infrastructure design.
This stage will describe how the AWS resources are organized and how the different application components are deployed.
However, the process does not end with the infrastructure diagram.
7. Implement and Deploy
Finally, the project will move from modeling to implementation.
The microservices, communication mechanisms, databases, and AWS infrastructure will be implemented based on the decisions made in the previous stages.
The final architecture will therefore be the result of an iterative process:
Strategic DDD → Design Patterns → C4 Model → AWS Mapping → Cloud Infrastructure → Communication Contracts → Tactical DDD → Implementation and Deployment
Conclusion
Using Strategic DDD before choosing cloud services helped me understand the application from the perspective of its business domain rather than its infrastructure.
The process resulted in seven bounded contexts and, considering the project's implementation scope, five deployable microservices.
More importantly, this stage established the boundaries and relationships that will guide the next steps. The architecture is not considered finished after defining the microservices or creating the AWS infrastructure diagram. Communication contracts, Tactical DDD, implementation, and deployment are still part of the process.
For me, this approach provides a clearer path from understanding the domain to building a cloud-native application on AWS.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article