---
id: feedback
name: Feedback
version: 1.0.0
identifier: id
aggregateRoot: true
summary: Represents an individual customer's rating and optional written review for a Catalog book.
owners:
  - catalog-experience-team
badges:
  - content: Aggregate Root
    backgroundColor: blue
    textColor: blue
  - content: Contains PII
    backgroundColor: yellow
    textColor: yellow
properties:
  - name: id
    type: UUID
    required: true
    description: Globally unique UUIDv7 identifier generated when the feedback is created.
  - name: bookId
    type: UUID
    required: true
    description: Cross-context identifier of the Catalog Book being reviewed (also the partition key).
    references: book
    referencesIdentifier: id
    relationType: references
  - name: firstName
    type: string
    required: true
    description: Reviewer's first name (non-empty, up to 50 characters).
  - name: lastName
    type: string
    required: true
    description: Reviewer's last name (non-empty, up to 50 characters).
  - name: comment
    type: string
    required: false
    description: Optional written review text (up to 1,000 characters).
  - name: rating
    type: integer
    required: true
    description: Integer satisfaction score from 0 through 5, inclusive.
  - name: createdAt
    type: datetime
    required: true
    description: UTC timestamp when the feedback was submitted.
  - name: lastModifiedAt
    type: datetime
    required: false
    description: UTC timestamp of the most recent modification.
---

## Domain Role & Boundary

**Feedback** is the Aggregate Root in the [[domain|reviews]] bounded context representing one customer's numeric rating and optional written review for a book. Owned by [[service|rating-api]], it serves as the authoritative source for individual customer sentiment and AI-assisted review summarization via [[agent|rating-agent]]. It explicitly does **not** own canonical book metadata or the aggregate rating summary displayed on product listings (both owned by [[domain|catalog]]).

## Entity Profile

| Property                      | Value                                                                                     |
| :---------------------------- | :---------------------------------------------------------------------------------------- |
| **Bounded Context / Domain**  | [[domain\|reviews]]                                                                       |
| **Owning Service**            | [[service\|rating-api]]                                                                   |
| **DDD Role**                  | Aggregate Root                                                                            |
| **Identifier Strategy**       | UUIDv7 generated at creation                                                              |
| **Persistence Store**         | Reviews document store (`feedbacks`, partitioned by `bookId`)                             |
| **Deletion Semantics**        | Hard-delete (explicit admin removal or automated compensation)                            |
| **Concurrency Control**       | Optimistic concurrency via document ETag                                                  |
| **PII / Data Classification** | Confidential PII (`firstName`, `lastName`) — screened fail-closed before AI summarization |

## Attributes & Constraints

<EntityPropertiesTable />

| Attribute               | Business Rule / Constraint                                                                           | Sensitivity / Notes                   |
| :---------------------- | :--------------------------------------------------------------------------------------------------- | :------------------------------------ |
| `bookId`                | Required non-empty UUID; serves as both the cross-context book reference and document partition key. | Cross-context ID reference            |
| `firstName`, `lastName` | Required at API boundary; non-empty, max 50 characters each.                                         | PII — redacted in logs and AI prompts |
| `comment`               | Optional free text, max 1,000 characters.                                                            | Screened for PII during summarization |
| `rating`                | Required integer from `0` through `5`, inclusive.                                                    | Domain invariant                      |

## Domain Invariants & Lifecycle

- **Bounded rating score:** Ratings outside `0`–`5` (inclusive) are rejected by the domain model.
- **Asynchronous rating projection:** Creating or deleting feedback emits integration events so [[service|catalog-api]] can update [[entity|book]] `averageRating` and `totalReviews` eventually.
- **Compensating deletion:** If [[service|catalog-api]] rejects a rating delta because the target book does not exist or was soft-deleted, [[service|rating-api]] performs an idempotent compensating delete on the orphaned feedback.
- **Read-only AI summarization:** [[agent|rating-agent]] reads feedback for a book and screens inputs/outputs fail-closed through [[service|presidio-api]] without mutating persisted records.

:::warning
Because Reviews references [[entity|book]] strictly by `bookId` without synchronous Catalog validation on write, orphaned feedback is resolved asynchronously via [[event|BookUpdatedRatingFailedIntegrationEvent]]. Additionally, reviewer uniqueness per `(bookId, firstName, lastName)` is enforced at the application/conflict layer rather than via a database unique-key policy.
:::

## Relationships & Associated Operations

| Category                     | Resource                                                                                                                                   | Role / Interaction                                          |
| :--------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------- |
| **Cross-Context References** | [[entity\|book]]                                                                                                                           | Referenced strictly by `bookId` across service boundaries   |
| **Mutating Commands**        | [[command\|CreateFeedback]], [[command\|DeleteFeedback]]                                                                                   | Submit a new review or remove an existing review            |
| **Read Queries**             | [[query\|ListFeedbacks]], [[query\|SummarizeFeedback]]                                                                                     | List book reviews or generate a privacy-screened AI summary |
| **Events**                   | [[event\|FeedbackCreatedIntegrationEvent]], [[event\|FeedbackDeletedIntegrationEvent]], [[event\|BookUpdatedRatingFailedIntegrationEvent]] | Propagate rating deltas to Catalog and handle compensation  |
