---
id: basket-item
name: Basket Item
version: 1.0.0
identifier: bookId
aggregateRoot: false
summary: Child entry within a Basket pairing a Catalog book identifier with a positive requested quantity.
owners:
  - commerce-fulfillment-team
badges:
  - content: Child Entity
    backgroundColor: teal
    textColor: teal
properties:
  - name: bookId
    type: UUID
    required: true
    description: Cross-context identifier of the requested Catalog Book.
    references: book
    referencesIdentifier: id
    relationType: references
  - name: quantity
    type: integer
    required: true
    description: Positive number of copies requested (must be greater than zero).
---

## Domain Role & Boundary

**Basket Item** is a child object owned by the [[entity|basket]] Aggregate Root in the [[domain|shopping]] bounded context, recording a single requested book identifier and its desired quantity. Stored embedded inside the parent basket payload by [[service|basket-api]], it is enriched at read time with live titles and prices from [[service|catalog-api]]. It explicitly does **not** store or lock book titles, descriptions, or prices—those remain owned by [[domain|catalog]] until checkout locks them onto an [[entity|order-item]].

## Entity Profile

| Property                      | Value                                                                                               |
| :---------------------------- | :-------------------------------------------------------------------------------------------------- |
| **Bounded Context / Domain**  | [[domain\|shopping]]                                                                                |
| **Owning Service**            | [[service\|basket-api]]                                                                             |
| **DDD Role**                  | Child Entity / Value Object (embedded in [[entity\|basket]])                                        |
| **Identifier Strategy**       | Scoped by Catalog `bookId` within parent [[entity\|basket]]                                         |
| **Persistence Store**         | Embedded inside parent `basket:{customerId}` key-value payload                                      |
| **Deletion Semantics**        | Removed by replacing parent `items` without the entry, or when parent [[entity\|basket]] is deleted |
| **Concurrency Control**       | Governed by parent [[entity\|basket]] whole-set replacement                                         |
| **PII / Data Classification** | Internal pre-order item reference (non-PII)                                                         |

## Attributes & Constraints

<EntityPropertiesTable />

| Attribute  | Business Rule / Constraint                                                     | Sensitivity / Notes        |
| :--------- | :----------------------------------------------------------------------------- | :------------------------- |
| `bookId`   | Required non-empty UUID referencing a [[entity\|book]] in [[domain\|catalog]]. | Cross-context ID reference |
| `quantity` | Required integer strictly greater than zero (`> 0`).                           | Domain invariant           |

## Domain Invariants & Lifecycle

- **Positive quantity:** Zero or negative quantities are rejected; removing an item requires submitting the updated basket without that item.
- **No persisted price snapshot:** Basket items intentionally omit prices so customers always see current [[domain|catalog]] pricing while browsing.
- **Read-time enrichment:** When reading a basket, [[service|basket-api]] batches distinct `bookId` values into a single lookup against [[service|catalog-api]] to attach `name`, `price`, and `priceSale` to the response.

:::note
If [[service|catalog-api]] returns no match for a `bookId` during read-time enrichment (for example, if the book was soft-deleted), the item remains in the basket response with unpopulated display fields rather than inventing metadata.
:::

## Relationships & Associated Operations

| Category                     | Resource                                             | Role / Interaction                                              |
| :--------------------------- | :--------------------------------------------------- | :-------------------------------------------------------------- |
| **Parent Aggregate**         | [[entity\|basket]]                                   | Embedded child item within the customer's basket                |
| **Cross-Context References** | [[entity\|book]]                                     | Referenced strictly by `bookId` for live price/title enrichment |
| **Mutating Commands**        | [[command\|CreateBasket]], [[command\|UpdateBasket]] | Replaced as part of parent basket mutations                     |
| **Read Queries**             | [[query\|GetBasket]], [[query\|GetBasketGrpc]]       | Returned enriched to storefront or raw to checkout              |
