---
id: FeedbackDeletedIntegrationEvent
name: Feedback deleted
version: 1.0.0
summary: |
  Indicates that a customer feedback rating was deleted for a book. Rating API
  publishes this event so Catalog can remove it from its denormalized summary.
owners:
  - catalog-experience-team
schemaPath: schema.json
badges:
  - content: Reviews
    backgroundColor: purple
    textColor: purple
---

`FeedbackDeletedIntegrationEvent` (v1.0.0) signals that [[service|rating-api]] deleted an existing customer [[entity|feedback]] document from Azure Cosmos DB. [[service|catalog-api]] consumes this event to subtract the removed score from the target book's denormalized rating summary in PostgreSQL.

## Overview

| Property                             | Value                                                                                            |
| :----------------------------------- | :----------------------------------------------------------------------------------------------- |
| **Bounded Context**                  | Reviews                                                                                          |
| **Producer**                         | [[service\|rating-api]]                                                                          |
| **Consumer(s)**                      | [[service\|catalog-api]]                                                                         |
| **Protocol / Format**                | Kafka + CloudEvents JSON (camelCase payload)                                                     |
| **Channel / Topic**                  | [[channel\|bookworm.&#123;env&#125;.rating.feedback-delete]]                                     |
| **Dead-Letter Channel**              | [[channel\|bookworm.&#123;env&#125;.catalog.dead-letter-queue]]                                  |
| **Partition Key**                    | `BookId`                                                                                         |
| **Delivery / Idempotency Guarantee** | Published via transactional outbox; consumed with Redis-backed 24-hour idempotency keyed by `id` |

## Payload Fields & Envelope

### Event Payload

| Name           | Type                   | Required | Constraints                     | Description                                                                           |
| :------------- | :--------------------- | :------- | :------------------------------ | :------------------------------------------------------------------------------------ |
| `id`           | `string` (`uuid`)      | Yes      | UUIDv7                          | Unique event identifier used by [[service\|catalog-api]] as the Redis idempotency key |
| `creationDate` | `string` (`date-time`) | Yes      | ISO 8601 UTC timestamp          | UTC timestamp when the event was created                                              |
| `bookId`       | `string` (`uuid`)      | Yes      | Valid UUID; Kafka partition key | Identifier of the book whose rating summary must be decremented                       |
| `rating`       | `integer`              | Yes      | `0`-`5`                         | Rating score removed from the book's denormalized rating summary                      |
| `feedbackId`   | `string` (`uuid`)      | Yes      | Valid UUID                      | Identifier of the deleted feedback record                                             |

### CloudEvents Envelope Headers

| Header        | Value / Source                                         | Purpose                                                      |
| :------------ | :----------------------------------------------------- | :----------------------------------------------------------- |
| `messagetype` | `BookWorm.Contracts.FeedbackDeletedIntegrationEvent`   | Explicit message identity for cross-service deserialization  |
| `source`      | `urn:bookworm:bookworm-rating`                         | Identifies the producing service                             |
| `requestid`   | Propagated from `DELETE /rating/api/v1/feedbacks/{id}` | Correlates feedback deletion with catalog projection updates |

## Delivery Guarantees & Error Handling

| Condition                                         | System Behavior                                                                    | Recovery / Compensation                                                                     |
| :------------------------------------------------ | :--------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------ |
| Duplicate delivery within 24 hours                | Consumer skips reprocessing via Redis-backed 24-hour idempotency keyed by `id`     | Prevents double-subtracting a rating on retries                                             |
| Target book not found in [[service\|catalog-api]] | Consumer returns without modifying state or emitting a compensating event          | No action required; no local rating summary exists to adjust                                |
| Transient database or concurrency error           | Retried with cooldown (`50ms`, `250ms`, `1s`) and full jitter                      | Exhausted messages route to [[channel\|bookworm.&#123;env&#125;.catalog.dead-letter-queue]] |
| Deserialization failure                           | Routed directly to [[channel\|bookworm.&#123;env&#125;.catalog.dead-letter-queue]] | Inspect dead-letter payload against contract schema                                         |

## Related Documentation

- [[service|rating-api]] — Producer service owning feedback records.
- [[service|catalog-api]] — Consumer service maintaining denormalized book ratings.
- [[channel|bookworm.&#123;env&#125;.rating.feedback-delete]] — Kafka channel specification.
- [[channel|bookworm.&#123;env&#125;.catalog.dead-letter-queue]] — Dead-letter channel for failed Catalog consumers.
- [[event|FeedbackCreatedIntegrationEvent]] — Companion event for adding a new rating.
- [[entity|book]] — Catalog entity storing the denormalized rating summary.

<NodeGraph />

<SchemaViewer file="schema.json" title="Feedback deleted schema" maxHeight="500" search="true" />


 ## Raw Schema:schema.json

{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"title": "FeedbackDeletedIntegrationEvent",
	"type": "object",
	"additionalProperties": false,
	"required": ["id", "creationDate", "bookId", "rating", "feedbackId"],
	"properties": {
		"id": {
			"type": "string",
			"format": "uuid",
			"description": "Unique event identifier (UUIDv7) inherited from IntegrationEvent."
		},
		"creationDate": {
			"type": "string",
			"format": "date-time",
			"description": "ISO 8601 UTC timestamp when the event was created."
		},
		"bookId": {
			"type": "string",
			"format": "uuid",
			"description": "Identifier of the book whose rating summary changes."
		},
		"rating": {
			"type": "integer",
			"minimum": 0,
			"maximum": 5,
			"description": "Rating value removed from the book."
		},
		"feedbackId": {
			"type": "string",
			"format": "uuid",
			"description": "Identifier of the deleted feedback record."
		}
	}
}
