top of page

What is a Subdomain?

In Domain-Driven Design (DDD), a subdomain refers to a distinct, focused part of the overall problem domain. The concept of a subdomain helps to break down complex business systems into manageable pieces, each of which represents a specific aspect of the business. Let’s break down the key elements of subdomains in DDD:


1. Domain

The domain represents the problem space your software system is trying to address. It is the business or area of knowledge that the software is built to serve. For example, if you’re building an e-commerce platform, the domain would be everything related to running an online store—products, orders, customers, payments, etc.


2. Subdomain

A subdomain is a smaller, more focused area of the overall domain. It represents a specific, coherent segment of the problem that can be isolated and understood independently of other parts of the system. Each subdomain addresses a distinct aspect of the business.


For example, in an e-commerce system, you might have subdomains such as:

- Product Catalog (managing products, descriptions, categories)

- Order Management (handling order placement, tracking, etc.)

- Payment Processing (dealing with payments, refunds, etc.)


3. Types of Subdomains

In DDD, subdomains are categorized into three main types, each of which plays a different role in the system:


- Core Subdomain: This is the most important part of the system, where the unique, strategic value of the business lies. For example, in an e-commerce platform, if you’re building a niche product recommendation engine, that might be the core subdomain because it gives the business a competitive advantage.

  

- Supporting Subdomain: These subdomains support the core subdomain but are not as critical or complex. They provide necessary functionality to make the core subdomain work, but they don’t differentiate the business. For example, user authentication might be a supporting subdomain—it’s important, but not unique to the business.


- Generic Subdomain: These are domains that are common across many systems and industries. They don’t provide unique value to the business and are often candidates for off-the-shelf solutions. In an e-commerce platform, an example might be payment processing, which can be handled by a third-party service like PayPal or Stripe.


4. Bounded Context and Subdomains

Subdomains are closely tied to the concept of bounded contexts in DDD. A bounded context is the boundary within which a particular model or concept is valid. While a subdomain represents a real-world problem space, a bounded context is where the solution for that subdomain is implemented. Multiple subdomains can map to their own bounded contexts.


Example:

Consider an online education platform**. The domain is online learning, and you might have these subdomains:

- Course Management: Core subdomain, handling how courses are created, organized, and structured.

- User Accounts: Supporting subdomain, where users register and manage their profiles.

- Payment Gateway: Generic subdomain, facilitating payments via third-party services.


In Summary:

- Subdomains help you understand and segment the overall business problem.

- Core subdomains focus on where the unique business value lies.

- Supporting and Generic subdomains provide auxiliary and non-strategic functionality.

- Each subdomain is generally mapped to its own bounded context, which ensures that the models and logic within that subdomain are cohesive and isolated from others.

bottom of page