Groups components into logical domains for service-based architecture...
This skill groups architectural components into logical domains (business areas) to prepare for creating domain services in a service-based architecture.
Request analysis of your codebase:
Example 1: Domain Identification
User: "Group components into logical domains"
The skill will:
1. Analyze component responsibilities and relationships
2. Identify business domains based on functionality
3. Group components into domains
4. Create domain diagrams
5. Suggest namespace refactoring for domain alignment
Example 2: Domain Analysis
User: "Which domain should the billing components belong to?"
The skill will:
1. Analyze billing component functionality
2. Check relationships with other components
3. Identify appropriate domain (e.g., Customer or Financial)
4. Recommend domain assignment
Example 3: Domain Refactoring
User: "What namespace refactoring is needed to align components with domains?"
The skill will:
1. Compare current component namespaces to identified domains
2. Identify misaligned components
3. Suggest namespace changes
4. Create refactoring plan
Apply this skill when:
A domain is a logical grouping of components that:
Examples:
One-to-Many: A single domain contains multiple components
Domain: Customer
āāā Component: Customer Profile
āāā Component: Billing Payment
āāā Component: Billing History
āāā Component: Support Contract
Domains are physically manifested through namespace structure:
Before Domain Alignment:
services/billing/payment
services/billing/history
services/customer/profile
services/supportcontract
After Domain Alignment:
services/customer/billing/payment
services/customer/billing/history
services/customer/profile
services/customer/supportcontract
Notice how all customer-related functionality is grouped under .customer domain.
Analyze the codebase to identify distinct business domains:
Examine Component Responsibilities
Look for Business Language
Identify Domain Boundaries
Collaborate with Business Stakeholders
Example Domain Identification:
## Identified Domains
1. **Ticketing Domain** (ss.ticket)
- Ticket creation, assignment, routing, completion
- Customer surveys
- Knowledge base
2. **Customer Domain** (ss.customer)
- Customer profile
- Billing and payment
- Support contracts
3. **Reporting Domain** (ss.reporting)
- Ticket reports
- Expert reports
- Financial reports
4. **Admin Domain** (ss.admin)
- User maintenance
- Expert profile management
5. **Shared Domain** (ss.shared)
- Login
- Notification
Assign each component to an appropriate domain:
Analyze Component Functionality
Check Component Relationships
Assign to Domain
Handle Edge Cases
Example Component Grouping:
## Component Domain Assignment
### Ticketing Domain (ss.ticket)
- Ticket Shared (ss.ticket.shared)
- Ticket Maintenance (ss.ticket.maintenance)
- Ticket Completion (ss.ticket.completion)
- Ticket Assign (ss.ticket.assign)
- Ticket Route (ss.ticket.route)
- KB Maintenance (ss.ticket.kb.maintenance)
- KB Search (ss.ticket.kb.search)
- Survey (ss.ticket.survey)
### Customer Domain (ss.customer)
- Customer Profile (ss.customer.profile)
- Billing Payment (ss.customer.billing.payment)
- Billing History (ss.customer.billing.history)
- Support Contract (ss.customer.supportcontract)
### Reporting Domain (ss.reporting)
- Reporting Shared (ss.reporting.shared)
- Ticket Reports (ss.reporting.tickets)
- Expert Reports (ss.reporting.experts)
- Financial Reports (ss.reporting.financial)
Ensure components fit well in their assigned domains:
Check Cohesion
Verify Boundaries
Assess Completeness
Get Stakeholder Validation
Validation Checklist:
Align component namespaces with identified domains:
Compare Current vs Target Namespaces
services/billing/paymentservices/customer/billing/payment.customer domain nodeIdentify Refactoring Needed
Create Refactoring Plan
Execute Refactoring
Example Namespace Refactoring:
## Namespace Refactoring Plan
### Customer Domain Alignment
| Component | Current Namespace | Target Namespace | Action |
| ---------------- | ------------------- | --------------------------- | ------------- |
| Billing Payment | ss.billing.payment | ss.customer.billing.payment | Add .customer |
| Billing History | ss.billing.history | ss.customer.billing.history | Add .customer |
| Customer Profile | ss.customer.profile | ss.customer.profile | No change |
| Support Contract | ss.supportcontract | ss.customer.supportcontract | Add .customer |
### Ticketing Domain Alignment
| Component | Current Namespace | Target Namespace | Action |
| -------------- | ----------------- | ------------------------ | ----------- |
| KB Maintenance | ss.kb.maintenance | ss.ticket.kb.maintenance | Add .ticket |
| KB Search | ss.kb.search | ss.ticket.kb.search | Add .ticket |
| Survey | ss.survey | ss.ticket.survey | Add .ticket |
Visualize domain structure and component groupings:
Create Domain Diagram
Document Domain Structure
Create Domain Inventory
Example Domain Map:
## 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 ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
## Output Format
### Domain Identification Report
```markdown
## Domain Identification
### Domain: Customer (ss.customer)
**Business Capability**: Manages customer relationships, billing, and support contracts
**Components**:
- Customer Profile (ss.customer.profile)
- Billing Payment (ss.customer.billing.payment)
- Billing History (ss.customer.billing.history)
- Support Contract (ss.customer.supportcontract)
**Component Count**: 4
**Total Size**: ~15,000 statements (18% of codebase)
**Domain Cohesion**: ā
High
- Components share customer-related vocabulary
- Components frequently used together
- Direct relationships between components
**Boundaries**:
- Clear separation from Ticketing domain
- Clear separation from Reporting domain
- Shared components (Notification) used by all domains
## Component Domain Assignment
| Component | Current Namespace | Assigned Domain | Target Namespace |
| ------------------ | --------------------- | --------------- | --------------------------------- |
| Customer Profile | ss.customer.profile | Customer | ss.customer.profile (no change) |
| Billing Payment | ss.billing.payment | Customer | ss.customer.billing.payment |
| Ticket Maintenance | ss.ticket.maintenance | Ticketing | ss.ticket.maintenance (no change) |
| KB Maintenance | ss.kb.maintenance | Ticketing | ss.ticket.kb.maintenance |
| Reporting Shared | ss.reporting.shared | Reporting | ss.reporting.shared (no change) |
## Namespace Refactoring Plan
### Priority: High
**Customer Domain Alignment**
**Components to Refactor**:
1. Billing Payment: `ss.billing.payment` ā `ss.customer.billing.payment`
2. Billing History: `ss.billing.history` ā `ss.customer.billing.history`
3. Support Contract: `ss.supportcontract` ā `ss.customer.supportcontract`
**Steps**:
1. Update namespace declarations in source files
2. Update import statements in dependent components
3. Update directory structure
4. Run tests to verify changes
5. Update documentation
**Expected Impact**:
- All customer-related components aligned under `.customer` domain
- Clearer domain boundaries
- Easier to identify domain components
## Domain Map
### Domain Structure
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
### Domain Relationships
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)
Domain Identification:
Component Grouping:
Domain Validation:
Namespace Refactoring:
Domain Mapping:
Domains typically organized in services/ directory:
services/
āāā customer/ ā Customer Domain
ā āāā profile/
ā āāā billing/
ā ā āāā payment/
ā ā āāā history/
ā āāā supportcontract/
āāā ticket/ ā Ticketing Domain
ā āāā shared/
ā āāā maintenance/
ā āāā assign/
ā āāā route/
āāā reporting/ ā Reporting Domain
āāā shared/
āāā tickets/
āāā experts/
Domains identified by package structure:
com.company.customer ā Customer Domain
āāā profile
āāā billing
ā āāā payment
ā āāā history
āāā supportcontract
com.company.ticket ā Ticketing Domain
āāā shared
āāā maintenance
āāā assign
āāā route
Strategy 1: Business Capability Analysis
Strategy 2: Vocabulary Analysis
Strategy 3: Relationship Analysis
Strategy 4: Stakeholder Collaboration
After creating domains, create automated checks:
// Ensure components belong to correct domain
function validateDomainNamespaces(components, domainRules) {
const violations = []
components.forEach((comp) => {
const domain = identifyDomain(comp.namespace)
const expectedDomain = domainRules[comp.name]
if (domain !== expectedDomain) {
violations.push({
component: comp.name,
currentDomain: domain,
expectedDomain: expectedDomain,
namespace: comp.namespace,
})
}
})
return violations
}
// Prevent components from accessing other domains directly
function enforceDomainBoundaries(components) {
const violations = []
components.forEach((comp) => {
comp.imports.forEach((imp) => {
const importedDomain = identifyDomain(imp)
const componentDomain = identifyDomain(comp.namespace)
if (importedDomain !== componentDomain && importedDomain !== 'shared') {
violations.push({
component: comp.name,
domain: componentDomain,
importsFrom: imp,
importedDomain: importedDomain,
issue: 'Cross-domain direct dependency',
})
}
})
})
return violations
}
After creating component domains: