Customer DP Service
Data product service providing unified customer views by consuming policy and quote events and projecting them into a queryable customer aggregate.
Service Data Product
Overview
The Customer DP Service is a data product service within the Capstone PAS that provides a unified view of customer data. It consumes events from the Policy and Quote domains and projects them into a queryable customer aggregate stored in DynamoDB.
Architecture
- Event Sourced Projection: Consumes domain events to build customer read model
- Lambda-based Consumers: Separate Lambda functions for policy and quote events
- DynamoDB Storage: Customer state stored in DynamoDB with GSI for efficient queries
- Idempotent Processing: Logical clock readings ensure exactly-once semantics
Event Processing
Quote Events
The service consumes quote events via the quote-events SQS queue:
| Event | Handler | Effect |
|---|---|---|
| PolicyHolderAddedToQuoteEvent | PolicyHolderAddedToQuoteEventHandler | Creates customer if not exists, associates quote |
Policy Events
The service consumes policy events via the policy-events SQS queue:
| Event | Handler | Effect |
|---|---|---|
| PolicyCreatedEvent | PolicyCreatedFromQuoteEventHandler | Removes quote reference, adds policy to customer |
| PolicyCancelledEvent | PolicyCancelledEventHandler | Updates policy status to CANCELLED |
| PolicyExpiredEvent | PolicyExpiredEventHandler | Updates policy status to EXPIRED |
| PolicyVerificationCompletedEvent | PolicyVerificationCompletedEventHandler | Updates policy status from verification result |
Query Interface
The service exposes a single query endpoint:
| Query | Description |
|---|---|
| GetCustomer | Retrieves customer by policy holder ID |
Infrastructure
Kinesis (Policy Events) ─> SQS (policy-events) ─> Lambda (PolicyEventsHandler) │Kinesis (Quote Events) ─> SQS (quote-events) ─> Lambda (QuoteEventsHandler) │ ▼ DynamoDB (Customer Table) │ ▼ Lambda (GetCustomer API)Replay Support
Failed events can be replayed through dedicated replay queues:
- Policy events: Redrive from DLQ to
policy-eventsqueue - Quote events: Redrive from DLQ to
quote-eventsqueue
Invalid payloads are routed to Invalid Message Queues (IMQs) for investigation.