<aside> <img src="/icons/checklist_green.svg" alt="/icons/checklist_green.svg" width="40px" />

</aside>

Persistence Model

Table carts [note: 'Giỏ hàng tạm của learner trước khi tạo order'] 
{
  id                  uuid              [pk, note: 'Giỏ hàng tạm của user']  
  user_id             uuid              [ref: > users.id, note: 'Chủ giỏ hàng']
  status              enum              [default:'active', enum: 'active', 'pending_payment', 'paid', 'canceled', 'abandoned']
  created_at          timestamp         [default: `now()`]  
  updated_at          timestamp         [default: `now()`]
  deleted_at          timestamp         [default: `now()`]    
}
Table cart_items [note: 'Các món trong giỏ, có thể là course hoặc specialization'] 
{
  id                  uuid               [pk, note: 'Mục riêng trong giỏ']  
  cart_id             uuid               [ref: > carts.id, note: 'Thuộc giỏ hàng nào']  
  product_id          uuid               [not null, ref: > products.id]
  qty                 int                [not null, default: 1] 
  
  added_at            timestamp          [default: `now()`, note: 'Thời điểm thêm vào giỏ']
	deleted_at          timestamp          [null]
	
  indexes { (cart_id, product_id) [unique] }  
}

Domain Use Cases

Create Cart Command

Add Item Command

Update Item Qty Command

Remove Item Command

Clear Cart Command

Get Cart Detail Query