Overview
The Services Modeler is based on theIntent.Modelers.Services module, which provides:
- Visual modeling of service contracts and operations
- Support for CQRS (Command Query Responsibility Segregation) patterns
- DTO and service operation definitions
- Query and command modeling
- Pagination support
- Integration with domain models
Designer Configuration
The Services designer is configured with:- Designer ID:
81104ae6-2bc5-4bae-b05a-f987b0372d81 - Designer Name: Services
- Order: 20 (appears after Domain in the designer list)
- Type Systems: Common Types, Services Types
Core Elements
Service
Services represent logical groupings of related operations, typically corresponding to controllers or service classes. Properties:- Name: Service name (e.g.,
CustomerService,OrderManagement) - Operations: Collection of operations exposed by the service
- Folder: Organizational folder/namespace
Command
Commands represent operations that change state (following CQRS principles). Properties:- Name: Command name (e.g.,
CreateOrder,UpdateCustomer) - Return Type: Optional return type (often void or an ID)
- Parameters: Input parameters or a single DTO parameter
- Fields: When using request objects, fields on the command DTO
- Create operations: Return the created entity’s ID
- Update operations: Often return void
- Delete operations: Return void
Query
Queries represent operations that retrieve data without side effects (following CQRS principles). Properties:- Name: Query name (e.g.,
GetCustomerById,SearchProducts) - Return Type: The type of data returned
- Parameters: Query parameters (filters, search criteria)
- Pagination: Optional pagination support
- Single DTO
- Collection of DTOs
- Paged result
DTO (Data Transfer Object)
DTOs represent data structures transferred between service layers and clients. Properties:- Name: DTO name
- Fields: Properties on the DTO
- Mapping: Associations to domain entities for mapping
- Command DTOs: Input for commands
- Query DTOs: Output from queries
- Response DTOs: Structured responses
DTO Field
Fields represent properties on DTOs. Properties:- Name: Field name
- Type: Data type (primitives, enums, other DTOs, domain entities)
- Is Nullable: Whether the field can be null
- Is Collection: Whether it’s a collection type
Folder
Folders organize service elements hierarchically, typically mapping to namespaces or API route segments.CQRS Pattern Support
Commands
Commands modify application state and should:- Have clear, action-oriented names (verbs)
- Accept input data via parameters or a command DTO
- Return minimal data (ID, void, or success indicator)
- Trigger domain logic and validation
CreateCustomerUpdateOrderStatusDeleteProductProcessPayment
Queries
Queries retrieve data and should:- Have descriptive names indicating what data is retrieved
- Accept filter/search parameters
- Return DTOs (never domain entities directly)
- Be idempotent (no side effects)
GetCustomerByIdSearchProductsGetOrderHistoryFindUsersByRole
Segregation Benefits
- Scalability: Scale read and write operations independently
- Performance: Optimize queries separately from commands
- Clarity: Clear separation of intent in the API
- Security: Apply different authorization rules to reads vs writes
Pagination Support
The Services Modeler includes built-in pagination support through theIntent.Modelers.Services.Pagination package.
Adding Pagination
- Create a query operation
- Add the
Paginatedstereotype - Configure page size and offset parameters
Metadata API
Accessing Service Models
Working with Services
Working with DTOs
Mapping to Domain Entities
Designer Settings
The Services Modeler provides application-level settings:Naming Conventions
Property Naming Convention- Options: Manual, Pascal Case, Camel Case
- Default: Manual
- Controls automatic naming when creating/renaming DTO fields
- Options: Pascal Case, Camel Case, Manual
- Default: Manual
- Controls automatic naming when creating/renaming DTOs
- Options: Camel Case, Manual, Pascal Case
- Default: Manual
- Controls automatic naming when creating/renaming operations
Integration Capabilities
Domain Interactions
The Services Modeler can interact with the Domain Modeler:- Map DTOs to domain entities
- Call domain operations from commands
- Trigger domain events
- Access repositories
Intent.Modelers.Services.DomainInteractions package is auto-detected and installed when needed.
Event Interactions
Services can publish and subscribe to events:- Publish integration events from commands
- Subscribe to events in event handlers
- Model event-driven workflows
Intent.Modelers.Services.EventInteractions package is auto-detected when eventing is used.
Pagination
Pagination support is automatically detected and installed: Package:Intent.Application.Dtos.Pagination
Version: 4.0.13+
Common Modeling Scenarios
RESTful CRUD Service
- Create a Service (e.g.,
ProductService) - Add Command operations:
CreateProduct- ReturnsGuidUpdateProduct- ReturnsvoidDeleteProduct- Returnsvoid
- Add Query operations:
GetProductById- ReturnsProductDTOGetProducts- ReturnsList<ProductDTO>
- Create DTOs:
CreateProductDTO- Input for createUpdateProductDTO- Input for updateProductDTO- Output representation
Search with Pagination
- Create a Query:
SearchCustomers - Add parameters:
searchTerm,pageNo,pageSize - Add
Paginatedstereotype - Set return type:
CustomerDTO - Result: Returns
PagedResult<CustomerDTO>
Command with Complex Input
- Create a Command:
PlaceOrder - Create a command DTO:
PlaceOrderCommand - Add fields to the DTO:
CustomerId:GuidItems:List<OrderItemDTO>ShippingAddress:AddressDTO
- Set command parameter type to
PlaceOrderCommand - Return type:
Guid(order ID)
Integration with Modules
The Services Modeler integrates with:- ASP.NET Core Templates: Generate controllers and endpoints
- MediatR Templates: Generate CQRS command and query handlers
- Application Layer Templates: Generate application service classes
- Mapping Templates: Generate AutoMapper or Mapster configurations
- Validation Templates: Generate FluentValidation validators
- OpenAPI/Swagger: Generate API documentation
Best Practices
- Follow CQRS Principles: Separate commands from queries clearly
- Use DTOs: Never expose domain entities directly through services
- Name Intentionally: Use action verbs for commands, descriptive names for queries
- Organize by Feature: Group related operations in the same service
- Leverage Pagination: Add pagination to list queries early
- Version Appropriately: Use folders to organize API versions
- Document Operations: Add comments explaining business rules and validation
- Keep DTOs Focused: Create specific DTOs for different operations
- Map Carefully: Use explicit mapping stereotypes to link DTOs to domain entities
Example Service Model
A typical e-commerce service layer might include:Related Resources
- Domain Modeler - Model domain entities to map to DTOs
- Eventing Modeler - Add message-based integration
- UI Modeler - Connect UI components to service operations