# Dual UX Specification: Modern App + E-commerce Flows **Document Purpose**: Comprehensive UX specification supporting both modern app-style instant purchase and traditional e-commerce cart workflows. **Last Updated**: 2025-08-04 **Status**: Implementation Ready --- ## Overview The Project Mycelium supports **two distinct user experience patterns** to accommodate different user preferences and use cases: 1. **Modern App Flow** (OpenRouter-style): Instant purchase with wallet top-up 2. **Traditional E-commerce Flow**: Cart-based shopping with checkout --- ## UX Flow Comparison ### **Flow 1: Modern App Style (OpenRouter-inspired)** ```mermaid graph TD A[Browse Marketplace] --> B[Register/Login] B --> C[View Service] C --> D[Buy Now Button] D --> E{TFC Balance Check} E -->|Sufficient| F[Instant Deploy] E -->|Insufficient| G[Auto Top-up Modal] G --> H[Stripe Payment] H --> I[TFC Added] I --> F F --> J[Deployment Status] J --> K[Service Active] ``` **Key Features:** - **Instant Purchase**: Single-click buying - **Auto Top-up**: Seamless balance management - **Wallet-centric**: Balance always visible - **Minimal Friction**: No cart, no checkout process ### **Flow 2: Traditional E-commerce Style** ```mermaid graph TD A[Browse Marketplace] --> B[View Service] B --> C[Add to Cart] C --> D[Continue Shopping] D --> E[Review Cart] E --> F[Checkout] F --> G{Payment Method} G -->|TFC Balance| H[Pay with TFC] G -->|Credit Card| I[Stripe Checkout] I --> J[TFC Purchase] J --> H H --> K[Batch Deployment] K --> L[Order Confirmation] ``` **Key Features:** - **Bulk Shopping**: Multiple items in cart - **Price Comparison**: Review before purchase - **Batch Deployment**: Deploy multiple services together - **Familiar UX**: Traditional e-commerce experience --- ## Detailed UX Specifications ### **Modern App Flow Implementation** #### **1. Wallet-First Interface** ```html
{{user.tfc_balance}} TFC ${{user.tfc_balance}} USD
``` #### **2. Buy Now Button (Primary Action)** ```html

{{service.name}}

{{service.price_tfc}} TFC ~2 min deploy
{{#if (gte user.tfc_balance service.price_tfc)}} Ready to deploy {{else}} Need {{subtract service.price_tfc user.tfc_balance}} more TFC {{/if}}
``` #### **3. Auto Top-up Configuration** ```html ``` ### **Traditional E-commerce Flow Implementation** #### **1. Shopping Cart Component** ```html

Shopping Cart

{{cart.items.length}} items
{{#each cart.items}}
{{this.service_name}}

{{this.cpu}}CPU • {{this.memory}}GB RAM • {{this.storage}}GB

{{this.price_tfc}} TFC
{{/each}}
Subtotal: {{cart.subtotal}} TFC
Estimated Deploy Time: ~{{cart.estimated_deploy_time}} minutes
Total: {{cart.total}} TFC
``` #### **2. Checkout Process** ```html
1. Review Order
2. Payment
3. Deployment
Order Summary
Deployment Options
Payment Method
Pay with TFC Balance {{user.tfc_balance}} TFC available
{{#if (lt user.tfc_balance cart.total)}}
Insufficient balance. Need {{subtract cart.total user.tfc_balance}} more TFC.
{{/if}}
Credit/Debit Card ${{cart.total}} USD
Use TFC + Credit Card {{user.tfc_balance}} TFC + ${{subtract cart.total user.tfc_balance}} USD
``` --- ## JavaScript Implementation ### **Modern App Flow Functions** ```javascript // Modern App Style - Instant Purchase async function buyNowInstant(serviceId) { try { // Check balance first const balance = await getUserTFCBalance(); const service = await getServiceDetails(serviceId); if (balance >= service.price_tfc) { // Sufficient balance - instant deploy showLoadingToast('Starting deployment...'); const result = await initiateDeployment(serviceId, 'tfc'); if (result.success) { showSuccessToast('Deployment started! Redirecting...'); window.location.href = `/dashboard/deployments/${result.deployment_id}`; } } else { // Insufficient balance - auto top-up flow const needed = service.price_tfc - balance; if (await isAutoTopUpEnabled()) { showAutoTopUpModal(needed, serviceId); } else { showManualTopUpModal(needed, serviceId); } } } catch (error) { showErrorToast('Failed to process purchase'); } } // Auto Top-up Flow async function handleAutoTopUp(amount, serviceId) { try { showLoadingToast('Processing auto top-up...'); const topUpResult = await processAutoTopUp(amount); if (topUpResult.success) { showSuccessToast('Balance updated! Starting deployment...'); // Proceed with deployment const deployResult = await initiateDeployment(serviceId, 'tfc'); if (deployResult.success) { window.location.href = `/dashboard/deployments/${deployResult.deployment_id}`; } } } catch (error) { showErrorToast('Auto top-up failed'); } } // Real-time Balance Updates function startBalancePolling() { setInterval(async () => { const balance = await getUserTFCBalance(); updateBalanceDisplay(balance); }, 10000); // Update every 10 seconds } function updateBalanceDisplay(balance) { document.querySelector('.balance-amount').textContent = `${balance} TFC`; document.querySelector('.usd-equivalent').textContent = `$${balance} USD`; // Update buy buttons state document.querySelectorAll('.buy-now-btn').forEach(btn => { const servicePrice = parseFloat(btn.dataset.price); if (balance >= servicePrice) { btn.classList.remove('insufficient-balance'); btn.disabled = false; } else { btn.classList.add('insufficient-balance'); btn.disabled = true; } }); } ``` ### **Traditional E-commerce Functions** ```javascript // Traditional E-commerce - Cart Management class ShoppingCart { constructor() { this.items = JSON.parse(localStorage.getItem('cart_items') || '[]'); this.updateCartDisplay(); } addItem(serviceId, serviceName, price, specs) { const existingItem = this.items.find(item => item.service_id === serviceId); if (existingItem) { showInfoToast('Item already in cart'); return; } this.items.push({ id: generateId(), service_id: serviceId, service_name: serviceName, price_tfc: price, specs: specs, added_at: new Date().toISOString() }); this.saveCart(); this.updateCartDisplay(); showSuccessToast('Added to cart'); } removeItem(itemId) { this.items = this.items.filter(item => item.id !== itemId); this.saveCart(); this.updateCartDisplay(); showSuccessToast('Removed from cart'); } getTotal() { return this.items.reduce((total, item) => total + item.price_tfc, 0); } async proceedToCheckout() { if (this.items.length === 0) { showErrorToast('Cart is empty'); return; } // Navigate to checkout page with cart data const cartData = encodeURIComponent(JSON.stringify(this.items)); window.location.href = `/checkout?cart=${cartData}`; } saveCart() { localStorage.setItem('cart_items', JSON.stringify(this.items)); } updateCartDisplay() { const cartCount = document.querySelector('.cart-count'); const cartTotal = document.querySelector('.cart-total'); if (cartCount) cartCount.textContent = this.items.length; if (cartTotal) cartTotal.textContent = `${this.getTotal()} TFC`; } } // Checkout Process async function processCheckout(paymentMethod, cartItems) { try { showLoadingToast('Processing order...'); const orderData = { items: cartItems, payment_method: paymentMethod, total_tfc: cartItems.reduce((sum, item) => sum + item.price_tfc, 0) }; const result = await fetch('/api/checkout/process', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(orderData) }); const response = await result.json(); if (response.success) { // Clear cart localStorage.removeItem('cart_items'); // Redirect to order confirmation window.location.href = `/orders/${response.order_id}`; } else { showErrorToast(response.message); } } catch (error) { showErrorToast('Checkout failed'); } } ``` --- ## User Preference System ### **UX Mode Selection** ```html
Shopping Experience
``` --- ## Benefits of Dual UX Approach ### **Modern App Flow Benefits:** - ✅ **Speed**: Instant purchases - ✅ **Simplicity**: Minimal clicks - ✅ **Mobile-friendly**: Touch-optimized - ✅ **Auto-management**: Set-and-forget top-ups ### **Traditional E-commerce Benefits:** - ✅ **Bulk Shopping**: Multiple services at once - ✅ **Price Comparison**: Review before buying - ✅ **Familiar**: Standard shopping experience - ✅ **Planning**: Schedule deployments ### **Combined Advantages:** - 🎯 **User Choice**: Accommodate different preferences - 🎯 **Use Case Flexibility**: Quick single purchases OR planned bulk orders - 🎯 **Market Coverage**: Appeal to both app users and traditional shoppers - 🎯 **Conversion Optimization**: Multiple paths to purchase --- This dual UX specification ensures the Project Mycelium appeals to both modern app users (who want instant, frictionless purchases) and traditional e-commerce users (who prefer to review and plan their purchases).