Basket Service (v1.0.0)
Manages the lifecycle of customer shopping baskets in the BookWorm e-commerce system
Overview
The Basket Service is a domain-centric microservice within our bounded context that implements a gRPC-based API architecture to manage the transient state of customer shopping carts. This service encapsulates the complete lifecycle of a basket aggregate, from creation through modification to eventual checkout processing.
As a core part of our Domain-Driven Design implementation, the Basket Service maintains its own dedicated Redis persistence store, ensuring proper encapsulation of the basket domain model. It serves as the system of record for the shopping intent of customers before this intent is transformed into an order through domain events.
Key Responsibilities
- Basket Lifecycle Management: Creation, modification, and deletion of shopping baskets
- Item Management: Adding, updating, and removing items with quantity validation
- Checkout Orchestration: Coordinating the transition from basket to order
- State Persistence: Maintaining basket state in Redis with configurable TTL
- Event Publishing: Emitting domain events for basket state changes
Component Diagram
Loading graph...
Core Features
Feature | Description | Event Published |
---|---|---|
Get Basket | Retrieves the current basket for an authenticated user, including all items and their quantities. | - |
Add Item to Basket | Allows customers to add items to their basket, with validation ensuring quantities are greater than zero. | BasketItemAddedEvent |
Remove Item from Basket | Enables customers to remove items from their basket, maintaining data consistency. | BasketItemRemovedEvent |
Update Item Quantity | Supports customers in updating the quantity of items in their basket, with built-in validation. | BasketItemQuantityUpdatedEvent |
Clear Basket | Removes all items from the basket at once. | BasketClearedEvent |
Delete Basket | Permanently removes the basket from the system. | BasketDeletedCompletedEvent |
Architecture diagram
Messages for this service
Sends messages (3)
Quickly find the message you need by searching for the name, type, or summary.Receives messages (6)
Quickly find the message you need by searching for the name, type, or summary.Showing 1 to 4 of 6 results
Key Concepts
The basket is the core domain entity representing a customer’s shopping cart. It is identified by a unique ID and contains a collection of basket items. The basket is stored in Redis for fast access and persistence.
Basket items are the individual products added to the basket by the customer.
Infrastructure
The Basket Service is deployed as a containerized application within the BookWorm ecosystem, leveraging cloud-native technologies for scalability and resilience.
Loading graph...
Performance Optimizations
- Connection Pooling: Redis connection multiplexing
- Caching Strategy: L1 in-memory cache with L2 Redis cache
- Batch Operations: Bulk item updates in single transactions
- Async/Await: Non-blocking I/O throughout the stack
Security Considerations
- Authentication: JWT bearer tokens validated on each request
- Authorization: Customer can only access their own basket
- Input Validation: All inputs sanitized and validated
- Rate Limiting: Per-customer request throttling
- Data Encryption: TLS for transit, optional Redis encryption at rest