Overview
KAIU Natural Living’s e-commerce platform provides a seamless shopping experience for customers to browse, purchase, and track natural wellness products. The system integrates real-time inventory, multiple payment methods, and automated logistics.Customer Shopping Flow
Browse Catalog
Customers explore products through an intuitive catalog with advanced filtering and search capabilities.
Product Catalog
Browsing Experience
The catalog page (src/pages/Catalogo.tsx:120-290) provides multiple ways to discover products:
- Search
- Categories
- Benefits
- View Modes
Smart Search BarExample searches:
- Fuzzy matching for typos (e.g., “Lavnda” finds “Lavanda”)
- Searches across product names, categories, and benefits
- Real-time results as you type
- “Lavanda” → Finds all lavender products
- “Relax” → Shows relaxation-focused items
- “Gotero” → Displays dropper bottle variants
Product Information
Each product card displays:- Product image gallery
- Name and variant (e.g., “10ml”, “30ml”)
- Price in Colombian Pesos (COP)
- Benefits and category
- Stock availability status
- “Add to Cart” or “Out of Stock” button
Stock Management
Real-time inventory tracking ensures customers only see available products. Out-of-stock items display a badge and disabled purchase button.
Product Variants
Products can have multiple variants (sizes, formats) managed as separate SKUs with individual pricing and stock levels.
Shopping Cart
Cart Management
The cart system (src/context/CartContextDef) provides:
Add Items
Add Items
- Stock validation before adding
- Quantity limits based on available inventory
- Duplicate detection (increases quantity instead)
Update Quantities
Update Quantities
Customers can adjust quantities directly in cart:
- Increment/decrement buttons
- Direct number input
- Real-time total recalculation
Remove Items
Remove Items
Items can be removed individually or the entire cart can be cleared.Cart persists across browser sessions using localStorage:
Cart Visibility
The cart icon in the navigation header shows:- Item count badge
- Slide-out drawer with full cart contents
- Running total
- Quick access to checkout
Checkout Process
Form Validation
The checkout form (src/pages/Checkout.tsx:69-95) implements strict validation:
Shipping Calculation
Shipping costs are calculated automatically (src/pages/Checkout.tsx:97-140):
-
Customer selects city → System captures:
- Department code
- City code
- Destination coordinates
-
API quote request → Sends:
- Receives shipping cost → Displays final total
Shipping is calculated in real-time using the logistics provider’s API. If the API fails, the system gracefully falls back to “TBD” status and allows order creation.
Payment Methods
- Cash on Delivery (COD)
- Online Payment (Wompi)
Contra EntregaThe most popular payment method in Colombia:
- Customer pays when receiving the package
- Order confirmed immediately upon checkout
- Inventory reserved instantly
- Confirmation email sent automatically
backend/create-order.js:203-224):Order Confirmation
After successful checkout:- Order ID generated → Readable PIN format (e.g.,
#1050) - Confirmation email sent → Includes:
- Order details and items
- Shipping address
- Total breakdown
- Tracking information (when available)
- Success page displayed → Shows order number and next steps
- Cart cleared → Ready for next purchase
Order Tracking
Customer Tracking Portal
The tracking page (src/pages/TrackOrder.tsx:24-193) allows customers to:
Search by:
- Order PIN (readable ID)
- Tracking number (from carrier)
- Database ID (UUID)
- Order status (Pending, Shipped, Delivered, etc.)
- Creation date
- Carrier name
- Tracking number with clickable link
- Order total
Auto-tracking Links
Tracking page supports URL parameters for instant lookup:- Email links that auto-search
- QR codes on shipping labels
- Customer support quick-links
Inventory Integration
Stock Reservation System
The backend implements a two-phase commit for inventory (backend/create-order.js:98-102):
Reserve Stock
When order is created, stock is temporarily reserved:This prevents overselling during checkout process.
Real-time Availability
Product availability updates instantly:- Frontend polls inventory status
- “Out of Stock” badges appear automatically
- Cart validation prevents checkout with unavailable items
Order Processing Backend
Complete Order Flow
The order creation endpoint (backend/create-order.js) orchestrates:
- Validation → Zod schema validation of all fields
- Stock Check → Reserve inventory or fail fast
- Database Entry → Create order record with PENDING status
- Logistics API → Create shipment with carrier
- Update Order → Add tracking info and external IDs
- Payment Handling → Process based on method (COD vs Online)
- Notifications → Send confirmation emails
Rollback Mechanism
Rollback Mechanism
If logistics API fails, system performs automatic rollback:This ensures data consistency across systems.
External ID Mapping
External ID Mapping
Orders maintain multiple identifiers:
- Database ID: UUID (e.g.,
a1b2c3d4-...) - Readable ID: Customer-facing PIN (e.g.,
1050) - External ID: Logistics provider reference
- Tracking Number: Carrier-assigned guide number
Key Features
Form Persistence
Checkout form data persists in localStorage, so customers don’t lose information if they navigate away:
Smart Validation
Real-time field validation with helpful error messages guides customers to provide correct information on first try.
Responsive Design
Catalog automatically switches between grid and list views based on screen size, optimizing for mobile shoppers.
SEO & URLs
Category and search parameters appear in URLs, allowing customers to share and bookmark specific catalog views:
API Endpoints
| Endpoint | Method | Purpose |
|---|---|---|
/api/create-order | POST | Create new order with logistics |
/api/quote-shipping | POST | Calculate shipping cost |
/api/track-order | GET | Retrieve order status by ID |
/api/wompi/sign | POST | Generate payment signature |
/api/products | GET | Fetch product catalog |
Related Features
Admin Dashboard
Manage orders and view sales analytics
Order Management
Process and fulfill customer orders
Inventory
Track and manage product stock