Domain Identification and Grouping
This skill groups architectural components into logical domains (business areas) to prepare for creating domain services in a service-based architecture.
How to Use
Quick Start
Request analysis of your codebase:
- "Group components into logical domains"
- "Identify component domains for service-based architecture"
- "Create domain groupings from components"
- "Analyze which components belong to which domains"
Usage Examples
Example 1: Domain Identification
Example 2: Domain Analysis
Example 3: Domain Refactoring
Step-by-Step Process
- Identify Domains: Analyze business capabilities and component relationships
- Group Components: Assign components to appropriate domains
- Validate Groupings: Ensure components fit well in their domains
- Refactor Namespaces: Align component namespaces with domains
- Create Domain Map: Visualize domain structure and component groupings
When to Use
Apply this skill when:
- After identifying, sizing, and analyzing component dependencies
- Before creating domain services (Pattern 6)
- When planning service-based architecture migration
- Analyzing component relationships and business alignment
- Preparing for domain-driven design implementation
- Grouping components for better organization
Core Concepts
Domain Definition
A domain is a logical grouping of components that:
- Represents a distinct business capability or area
- Contains related components that work together
- Has clear boundaries and responsibilities
- Can become a domain service in service-based architecture
Examples:
- Customer Domain: Customer profile, billing, support contracts
- Ticketing Domain: Ticket creation, assignment, routing, completion
- Reporting Domain: Ticket reports, expert reports, financial reports
Component Domain Relationship
One-to-Many: A single domain contains multiple components
Domain Manifestation
Domains are physically manifested through namespace structure:
Before Domain Alignment:
After Domain Alignment:
Notice how all customer-related functionality is grouped under .customer domain.
Analysis Process
Phase 1: Identify Business Domains
Analyze the codebase to identify distinct business domains:
-
Examine Component Responsibilities
- Read component names and descriptions
- Understand what each component does
- Identify business capabilities
-
Look for Business Language
- Group components by business vocabulary
- Example: "billing", "payment", "invoice" → Financial domain
- Example: "customer", "profile", "contract" → Customer domain
-
Identify Domain Boundaries
- Where do business concepts change?
- What are the distinct business areas?
- How do components relate to business capabilities?
-
Collaborate with Business Stakeholders
- Validate domain identification with product owners
- Ensure domains align with business understanding
- Get feedback on domain boundaries
Example Domain Identification:
Phase 2: Group Components into Domains
Assign each component to an appropriate domain:
-
Analyze Component Functionality
- What business capability does it support?
- What domain vocabulary does it use?
- What other components does it relate to?
-
Check Component Relationships
- Which components are frequently used together?
- What are the dependencies between components?
- Do components share data or workflows?
-
Assign to Domain
- Place component in domain that best fits its functionality
- Ensure component aligns with domain's business language
- Verify component relationships support domain grouping
-
Handle Edge Cases
- Components that don't fit clearly: Analyze more deeply
- Components that fit multiple domains: Choose primary domain
- Shared components: May belong to Shared domain
Example Component Grouping:
Phase 3: Validate Domain Groupings
Ensure components fit well in their assigned domains:
-
Check Cohesion
- Do components in domain share business language?
- Are components frequently used together?
- Do components have direct relationships?
-
Verify Boundaries
- Are domain boundaries clear?
- Do components belong to only one domain?
- Are there components that don't fit anywhere?
-
Assess Completeness
- Are all components assigned to a domain?
- Are domains cohesive and well-formed?
- Do domains represent distinct business capabilities?
-
Get Stakeholder Validation
- Review domain groupings with product owners
- Ensure domains align with business understanding
- Get feedback on domain boundaries
Validation Checklist:
- All components assigned to a domain
- Domains have clear boundaries
- Components fit well in their domains
- Domains represent distinct business capabilities
- Stakeholders validate domain groupings
Phase 4: Refactor Namespaces for Domain Alignment
Align component namespaces with identified domains:
-
Compare Current vs Target Namespaces
- Current:
services/billing/payment - Target:
services/customer/billing/payment - Change: Add
.customerdomain node
- Current:
-
Identify Refactoring Needed
- Which components need namespace changes?
- What domain nodes need to be added?
- Are there components already aligned?
-
Create Refactoring Plan
- List components needing namespace changes
- Specify target namespace for each
- Prioritize refactoring work
-
Execute Refactoring
- Update component namespaces
- Update imports/references
- Verify all references updated
Example Namespace Refactoring:
Phase 5: Create Domain Map
Visualize domain structure and component groupings:
-
Create Domain Diagram
- Show domains as boxes
- Show components within each domain
- Show relationships between domains
-
Document Domain Structure
- List domains and their components
- Describe domain responsibilities
- Note domain boundaries
-
Create Domain Inventory
- Table of domains and components
- Component counts per domain
- Size metrics per domain
Example Domain Map:
┌─────────────────────────────────────┐ │ Ticketing Domain (ss.ticket) │ ├─────────────────────────────────────┤ │ • Ticket Shared │ │ • Ticket Maintenance │ │ • Ticket Completion │ │ • Ticket Assign │ │ • Ticket Route │ │ • KB Maintenance │ │ • KB Search │ │ • Survey │ └─────────────────────────────────────┘ │ │ uses ▼ ┌─────────────────────────────────────┐ │ Customer Domain (ss.customer) │ ├─────────────────────────────────────┤ │ • Customer Profile │ │ • Billing Payment │ │ • Billing History │ │ • Support Contract │ └─────────────────────────────────────┘
Component Domain Assignment Table
Namespace Refactoring Plan
Domain Map Visualization
Customer Domain (ss.customer) ├── Customer Profile ├── Billing Payment ├── Billing History └── Support Contract
Ticketing Domain (ss.ticket) ├── Ticket Shared ├── Ticket Maintenance ├── Ticket Completion ├── Ticket Assign ├── Ticket Route ├── KB Maintenance ├── KB Search └── Survey
Reporting Domain (ss.reporting) ├── Reporting Shared ├── Ticket Reports ├── Expert Reports └── Financial Reports
Admin Domain (ss.admin) ├── User Maintenance └── Expert Profile
Shared Domain (ss.shared) ├── Login └── Notification
Ticketing Domain │ uses ├─→ Shared Domain (Login, Notification) └─→ Customer Domain (Customer Profile)
Customer Domain │ uses └─→ Shared Domain (Login, Notification)
Reporting Domain │ uses ├─→ Ticketing Domain (Ticket data) ├─→ Customer Domain (Customer data) └─→ Shared Domain (Login)
Analysis Checklist
Domain Identification:
- Analyzed component responsibilities
- Identified business capabilities
- Identified distinct business domains
- Validated domains with stakeholders
Component Grouping:
- Assigned each component to a domain
- Analyzed component relationships
- Ensured components fit domain vocabulary
- Handled edge cases (shared components, unclear assignments)
Domain Validation:
- Checked cohesion within domains
- Verified domain boundaries are clear
- Ensured all components assigned
- Validated with stakeholders
Namespace Refactoring:
- Compared current vs target namespaces
- Identified components needing refactoring
- Created refactoring plan
- Prioritized refactoring work
Domain Mapping:
- Created domain diagram
- Documented domain structure
- Created domain inventory table
- Documented domain relationships
Implementation Notes
For Node.js/Express Applications
Domains typically organized in services/ directory:
For Java Applications
Domains identified by package structure:
Domain Identification Strategies
Strategy 1: Business Capability Analysis
- Identify what business capabilities the system provides
- Group components by capability
- Example: "Customer Management" capability → Customer Domain
Strategy 2: Vocabulary Analysis
- Identify business vocabulary used by components
- Group components sharing same vocabulary
- Example: Components using "billing", "payment", "invoice" → Financial Domain
Strategy 3: Relationship Analysis
- Identify components frequently used together
- Group components with strong relationships
- Example: Components that share data/workflows → Same Domain
Strategy 4: Stakeholder Collaboration
- Work with product owners/business analysts
- Use their understanding of business areas
- Validate domain boundaries with them
Fitness Functions
After creating domains, create automated checks:
Domain Namespace Governance
Domain Boundary Enforcement
Best Practices
Do's ✅
- Collaborate with business stakeholders to identify domains
- Group components by business capability, not technical layers
- Ensure domains represent distinct business areas
- Validate domain boundaries with stakeholders
- Refactor namespaces to align with domains
- Create clear domain documentation
- Use business language in domain names
Don'ts ❌
- Don't create domains based on technical layers (services, controllers, models)
- Don't force components into domains where they don't fit
- Don't skip stakeholder validation
- Don't create too many small domains (aim for 3-7 domains)
- Don't create domains that are too large (monolithic domains)
- Don't ignore components that don't fit (analyze why)
- Don't skip namespace refactoring (critical for clarity)
Common Domain Patterns
Typical Domains in Business Applications
- Customer Domain: Customer management, profiles, relationships
- Product Domain: Product catalog, inventory, pricing
- Order Domain: Order processing, fulfillment, shipping
- Billing Domain: Invoicing, payments, financial transactions
- Reporting Domain: Reports, analytics, dashboards
- Admin Domain: User management, system configuration
- Shared Domain: Common functionality (login, notification, utilities)
Domain Size Guidelines
- Small Domain: 2-4 components
- Medium Domain: 5-8 components
- Large Domain: 9-15 components
- Too Large: >15 components (consider splitting)
Next Steps
After creating component domains:
- Apply Create Domain Services Pattern - Extract domains to separate services
- Plan Service Extraction - Create migration plan for domain services
- Implement Domain Services - Move domains to separately deployed services
- Monitor Domain Boundaries - Use fitness functions to enforce boundaries
Notes
- Domains should represent business capabilities, not technical layers
- Domain identification requires collaboration with business stakeholders
- Namespace refactoring is critical for domain clarity
- Domains prepare the codebase for service-based architecture
- Well-formed domains make service extraction easier
- Domain boundaries should be clear and well-documented


