# Shopping Cart Architecture ## Guest & Customer Session Management Managed via `CartRouter.py`. Frontend client prices are **NEVER trusted**. --- ## Storage Model * **Guest Carts**: Saved in Redis (`cart:visitor:{visitor_id}`) with 7-day TTL. * **Customer Carts**: Persisted in MySQL (`carts` table with JSON items) and cached in Redis (`cart:customer:{customer_id}`). --- ## Price Recalculation Engine Every read or item addition forces server-side recalculation: ```text Unit Base Price (from MySQL ProductVariant) - Promotional Discount / Coupon + Tax (CGST / SGST / IGST) + Shipping Charges ------------------------------------------- = Total Final Amount ```