---
id: buyer
name: Buyer
version: 1.0.0
identifier: id
aggregateRoot: true
summary: Represents a customer's ordering profile and delivery address within the Ordering bounded context.
owners:
  - commerce-fulfillment-team
badges:
  - content: Aggregate Root
    backgroundColor: blue
    textColor: blue
  - content: Contains PII
    backgroundColor: yellow
    textColor: yellow
properties:
  - name: id
    type: UUID
    required: true
    description: Identifier associated with the authenticated customer.
  - name: name
    type: string
    required: true
    description: Buyer's display name (non-whitespace, up to 20 characters).
  - name: address
    type: object
    required: true
    description: Buyer's delivery address value object.
    properties:
      - name: street
        type: string
        required: true
        description: Street address line (non-whitespace, up to 50 characters).
      - name: city
        type: string
        required: true
        description: City name (non-whitespace, up to 50 characters).
      - name: province
        type: string
        required: true
        description: Province or state name (non-whitespace, up to 50 characters).
---

## Domain Role & Boundary

**Buyer** is an Aggregate Root in the [[domain|ordering]] bounded context representing a customer's ordering profile and delivery address. Owned by [[service|order-api]], it links an authenticated customer identity to their placed [[entity|order]] history. It explicitly does **not** own authentication credentials or roles (owned by [[system|identity-provider]]) or pre-purchase shopping baskets (owned by [[domain|shopping]]).

## Entity Profile

| Property                      | Value                                                                                               |
| :---------------------------- | :-------------------------------------------------------------------------------------------------- |
| **Bounded Context / Domain**  | [[domain\|ordering]]                                                                                |
| **Owning Service**            | [[service\|order-api]]                                                                              |
| **DDD Role**                  | Aggregate Root                                                                                      |
| **Identifier Strategy**       | Authenticated customer UUID                                                                         |
| **Persistence Store**         | Ordering relational database (`buyers`)                                                             |
| **Deletion Semantics**        | Hard-delete; clears `buyerId` to null on existing [[entity\|order]] records without deleting orders |
| **Concurrency Control**       | Buyer-scoped distributed write locks during mutations                                               |
| **PII / Data Classification** | Confidential PII (`name`, `address`) — redacted from logs, events, and incident reports             |

## Attributes & Constraints

<EntityPropertiesTable />

| Attribute | Business Rule / Constraint                                                                        | Sensitivity / Notes             |
| :-------- | :------------------------------------------------------------------------------------------------ | :------------------------------ |
| `id`      | Required; derived from the authenticated customer identity.                                       | Internal/Customer identifier    |
| `name`    | Required; non-whitespace, max 20 characters.                                                      | PII — redact in structured logs |
| `address` | Embedded value object (`street`, `city`, `province` each required, non-whitespace, max 50 chars). | PII — redact in structured logs |

## Domain Invariants & Lifecycle

- **Required profile fields:** Both the buyer's name and all three delivery address components (`street`, `city`, `province`) must be non-whitespace; invalid inputs are rejected at creation and update.
- **Whole-address replacement:** Updating a buyer's delivery address replaces the entire `address` value object atomically rather than patching individual fields.
- **Order preservation on delete:** Deleting a buyer removes the buyer profile while preserving historical [[entity|order]] records with `buyerId` set to null.

:::warning
`name` and `address` are Personal Identifiable Information (PII). Never emit raw buyer names or street addresses into structured application logs, integration events, or telemetry traces.
:::

## Relationships & Associated Operations

| Category              | Resource                                                                       | Role / Interaction                                                  |
| :-------------------- | :----------------------------------------------------------------------------- | :------------------------------------------------------------------ |
| **Related Entities**  | [[entity\|order]]                                                              | One buyer places zero or more orders                                |
| **Mutating Commands** | [[command\|CreateBuyer]], [[command\|UpdateAddress]], [[command\|DeleteBuyer]] | Register buyer profile, replace delivery address, or remove profile |
| **Read Queries**      | [[query\|GetBuyer]], [[query\|ListBuyers]]                                     | Retrieve individual buyer details or paginated buyer lists          |
