From 7f45d387c115d61d84a17b7365cec9c494353a32 Mon Sep 17 00:00:00 2001 From: jsimonsmoj <176372445+jsimonsmoj@users.noreply.github.com> Date: Wed, 22 Jan 2025 08:28:55 +0000 Subject: [PATCH] PI-2187 Add tech docs for domain events and Delius (#4561) * PI-2187 Add tech docs for domain events and Delius * PI-2187 Fix the paths to the generated images in the tech docs --- projects/domain-events-and-delius/README.md | 31 +- .../diag/domain-events-context-map.d2 | 33 + .../domain-events-enhancement-workflow.d2 | 30 + .../source/img/domain-events-context-map.svg | 122 +++ .../domain-events-enhancement-workflow.svg | 855 ++++++++++++++++++ 5 files changed, 1069 insertions(+), 2 deletions(-) create mode 100644 projects/domain-events-and-delius/tech-docs/diag/domain-events-context-map.d2 create mode 100644 projects/domain-events-and-delius/tech-docs/diag/domain-events-enhancement-workflow.d2 create mode 100644 projects/domain-events-and-delius/tech-docs/source/img/domain-events-context-map.svg create mode 100644 projects/domain-events-and-delius/tech-docs/source/img/domain-events-enhancement-workflow.svg diff --git a/projects/domain-events-and-delius/README.md b/projects/domain-events-and-delius/README.md index eed97528c..606b30fff 100644 --- a/projects/domain-events-and-delius/README.md +++ b/projects/domain-events-and-delius/README.md @@ -1,3 +1,30 @@ -# domain-events-and-delius +# Domain events and Delius +This domain event service enables enhancement of domain events from Delius. The domain events are retrieved from the database in batches, enhanced and published to SNS. -// TODO Describe the service \ No newline at end of file +The supported domain event enhancers are: + +| Message event type | Description | +| --------------------------------- | --------------------------------------------- | +| probation-case.engagement.created | Adds a detail URL to retrieve engagement data | + +# Data dependencies +Domain event service depends on Delius for retrieving batches of domain events waiting to be processed. Each domain event will contain a unique ID, message body and message attributes. The message body will contain the event type. + +## Context map - Domain Event Data + +![](./tech-docs/source/img/domain-events-context-map.svg) + +# Workflows +## Enhancing a domain event +Domain events are retrieved from the database in batches. Each domain event will be processed in order. The domain event will contain an event type within the message body. The event type is mapped to an enhancement if one exists, otherwise it is matched to a no enhancement catch-all which will just publish the original domain event. Once a domain event has been enhanced it will be published to SNS. + +![](./tech-docs/source/img/domain-events-enhancement-workflow.svg) + +# API Access Control +API endpoints are available to retrieve additional information related to a domain event. These URLs will be added to the domain event message by enhancers within the domain event service. + +The API endpoints are secured by roles supplied by the HMPPS Auth client used in the requests. + +| API endpoint | Required role | +| --------------------------------------- | ------------------------------------------ | +| probation-case.engagement.created/{crn} | PROBATION_API_\_DOMAIN_EVENTS_\_ENGAGEMENT | \ No newline at end of file diff --git a/projects/domain-events-and-delius/tech-docs/diag/domain-events-context-map.d2 b/projects/domain-events-and-delius/tech-docs/diag/domain-events-context-map.d2 new file mode 100644 index 000000000..454e776d6 --- /dev/null +++ b/projects/domain-events-and-delius/tech-docs/diag/domain-events-context-map.d2 @@ -0,0 +1,33 @@ + +style { ...@../../../../script/style.style } +vars { ...@../../../../script/style.vars } +** { ...@../../../../script/style.all-style } + +context-delius: Delius Context { + + entities: Entities { + grid-columns: 2 + person: Person on Probation + event: Domain event { + message: Message body + attributes: Message attributes + } + } +} + +context-notification: Notification Context { + + interface: Delius and\n Notification { + type: Anti-Corruption\nLayer + } + + entities: Entities { + grid-columns: 2 + notification: Notification { + message: Message + attributes: Attributes + } + } +} + +context-delius--context-notification.interface: Upstream\n\n\nDownstream diff --git a/projects/domain-events-and-delius/tech-docs/diag/domain-events-enhancement-workflow.d2 b/projects/domain-events-and-delius/tech-docs/diag/domain-events-enhancement-workflow.d2 new file mode 100644 index 000000000..a0fee85e1 --- /dev/null +++ b/projects/domain-events-and-delius/tech-docs/diag/domain-events-enhancement-workflow.d2 @@ -0,0 +1,30 @@ +# Domain Event Workflow: Domain Event Enhancement + +direction: right + +style { ...@../../../../script/style.style } +vars { ...@../../../../script/style.vars } +** { ...@../../../../script/style.all-style } + +# Domain Event Enhancement +domain-event-enhancement: Domain Event Enhancement { + style.font-size: 24 + grid-columns: 2 + + d_get_events: Get domain events batch + d_enhance_events: Enhance domain event + d_publish: Publish notification + + d_get_events -> d_enhance_events -> d_publish + + explanation: |md + ## Enhance an event + - Get batch of domain events + - If event type is supported,\ + enhance the event + - Transform the event to\ + a notification + - Publish the notification + | + +} diff --git a/projects/domain-events-and-delius/tech-docs/source/img/domain-events-context-map.svg b/projects/domain-events-and-delius/tech-docs/source/img/domain-events-context-map.svg new file mode 100644 index 000000000..c9f27701f --- /dev/null +++ b/projects/domain-events-and-delius/tech-docs/source/img/domain-events-context-map.svg @@ -0,0 +1,122 @@ +Delius ContextNotification ContextEntitiesDelius and NotificationEntitiesPerson on ProbationDomain eventAnti-CorruptionLayerNotificationMessage bodyMessage attributesMessageAttributesUpstream Downstream + + + + + + + + + + + + + + + + diff --git a/projects/domain-events-and-delius/tech-docs/source/img/domain-events-enhancement-workflow.svg b/projects/domain-events-and-delius/tech-docs/source/img/domain-events-enhancement-workflow.svg new file mode 100644 index 000000000..0923024bf --- /dev/null +++ b/projects/domain-events-and-delius/tech-docs/source/img/domain-events-enhancement-workflow.svg @@ -0,0 +1,855 @@ +Domain Event EnhancementGet domain events batchEnhance domain eventPublish notification

Enhance an event

+
    +
  • Get batch of domain events
  • +
  • If event type is supported,
    +enhance the event
  • +
  • Transform the event to
    +a notification
  • +
  • Publish the notification
  • +
+
+ + + + + + +