Skip to content

Service dependencies

A class diagram. A controller with its service and mapper, and the service's repository, validator and event publisher, laid out left to right.

A controller with its service and mapper, and the service's repository, validator and event publisher, laid out left to rightA controller with its service and mapper, and the service's repository, validator and event publisher, laid out left to right

Spec

service-dependencies.json
{
"type": "class",
"direction": "RIGHT",
"classes": [
{
"id": "controller",
"label": "OrderController",
"methods": [{"visibility": "+", "text": "create(req): Response"}]
},
{
"id": "service",
"label": "OrderService",
"methods": [{"visibility": "+", "text": "placeOrder(cmd): Order"}]
},
{
"id": "repo",
"label": "OrderRepository",
"methods": [
{"visibility": "+", "text": "save(order): void"},
{"visibility": "+", "text": "findById(id): Order"}
]
},
{
"id": "validator",
"label": "OrderValidator",
"methods": [{"visibility": "+", "text": "validate(cmd): bool"}]
},
{
"id": "publisher",
"label": "EventPublisher",
"methods": [{"visibility": "+", "text": "publish(event): void"}]
},
{
"id": "mapper",
"label": "OrderMapper",
"methods": [{"visibility": "+", "text": "toDto(order): Dto"}]
}
],
"relations": [
{
"id": "r-controller-service",
"from": "controller",
"to": "service",
"kind": "association",
"directed": true,
"from_card": "1",
"to_card": "1"
},
{
"id": "r-controller-mapper",
"from": "controller",
"to": "mapper",
"kind": "association",
"directed": true
},
{
"id": "r-service-repo",
"from": "service",
"to": "repo",
"kind": "association",
"directed": true,
"from_card": "1",
"to_card": "1"
},
{
"id": "r-service-validator",
"from": "service",
"to": "validator",
"kind": "association",
"directed": true
},
{
"id": "r-service-publisher",
"from": "service",
"to": "publisher",
"kind": "association",
"directed": true
}
]
}

Draw it yourself

Terminal window
diago render service-dependencies.json > service-dependencies.svg

Open it in the playground to edit it in your browser.