Basket (v1.0.0)
Overview
The Basket domain is responsible for managing the shopping basket of a customer throughout their shopping journey. It serves as a temporary storage for items that customers intend to purchase before proceeding to checkout and placing an order.
Key Responsibilities
- Managing the addition, removal, and updating of items in a customer’s basket
- Maintaining quantity information for each basket item
- Calculating pricing including subtotals, discounts, and estimated taxes
- Supporting the transition from anonymous to authenticated baskets when users log in
- Providing persistence for basket state between sessions
- Implementing basket expiration and cleanup processes
- Validating product availability and price consistency with the Catalog service
- Facilitating the checkout process by transferring basket data to the Ordering service
The domain uses an Active Record pattern for simplicity and performance, as basket operations need to be fast and highly available. The basket data is temporarily stored and doesn’t require complex domain modeling as found in other services.
Bounded context
Messages for this domain
Sends messages (2)
Quickly find the message you need by searching for the name, type, or summary.Receives messages (5)
Quickly find the message you need by searching for the name, type, or summary.Showing 1 to 4 of 5 results
Data Model
The Basket domain uses a simple data model optimized for Redis storage with the following structure:
Customer Basket
{ "id": "string", "items": [ { "id": "string", "quantity": "number" } ], "createdAt": "datetime", "updatedAt": "datetime"}
Storage Details
- Storage Type: Redis Hash
- Key Pattern:
/basket
- Hash Field: Customer ID
- Value: Serialized CustomerBasket object
Key Properties
id
: Unique identifier for the customer’s basketitems
: Collection of basket itemscreatedAt
: Timestamp of basket creationupdatedAt
: Timestamp of last update
BasketItem Properties
id
: Product identifierquantity
: Number of items (must be greater than 0)
Validation Rules
- Customer ID cannot be null
- Basket must contain at least one item
- Item quantity must be greater than zero
Serialization
- Uses System.Text.Json with camelCase naming policy
- Case-insensitive property matching
- Optimized serialization context for performance