### Run Development Server Source: https://github.com/coder-cr07/databaes/blob/master/README.md Commands to start the local development environment using various package managers. ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` -------------------------------- ### Fetch Products by Keyword Source: https://context7.com/coder-cr07/databaes/llms.txt Retrieves matching products from multiple sources with optional pagination seeds. ```typescript import { fetchProductsByKeyword, FetchProductsOptions } from "@/data/products"; // Basic product search const products = await fetchProductsByKeyword("laptop"); // With pagination seed for varied results const options: FetchProductsOptions = { pageSeed: 42 }; const variedProducts = await fetchProductsByKeyword("jacket", options); // Returns Product[] with up to 12 items: // [ // { // id: "dummyjson-1", // title: "MacBook Pro 14", // image: "https://cdn.dummyjson.com/...", // price: 1749.99, // link: "https://dummyjson.com/products/1" // }, // ... // ] ``` -------------------------------- ### Implement WalletBar Component Source: https://context7.com/coder-cr07/databaes/llms.txt Displays the Algorand wallet connection status and auto-buy monitoring information. ```tsx import { WalletBar } from "@/components/WalletBar"; ``` -------------------------------- ### Detect Product Keywords from Images Source: https://context7.com/coder-cr07/databaes/llms.txt Analyzes uploaded image data to identify product categories using a hint-based matching system. ```typescript import { detectKeywordFromImage } from "@/data/products"; // Detect product category from uploaded image const payload = { fileName: "blue-leather-jacket.jpg", imageDataUrl: "data:image/jpeg;base64,/9j/4AAQ..." }; const keyword = await detectKeywordFromImage(payload); // Returns: "jacket" // Supported categories with hint matching: // jacket, coat, headphone, watch, camera, laptop, phone, shoe, bag, shirt, dress, perfume ``` -------------------------------- ### Integrate Pera Wallet with Algorand Source: https://context7.com/coder-cr07/databaes/llms.txt Handles Pera Wallet connection, session reconnection, and transaction signing for autonomous purchases on the Algorand testnet. ```typescript import algosdk from "algosdk"; import { PeraWalletConnect } from "@perawallet/connect"; // Initialize Pera Wallet (testnet) const peraWallet = new PeraWalletConnect({ chainId: 416002 }); const algodClient = new algosdk.Algodv2("", "https://testnet-api.algonode.cloud", ""); // Connect wallet const connectWallet = async () => { const accounts = await peraWallet.connect(); const walletAddress = accounts[0]; console.log("Connected:", walletAddress); }; // Reconnect existing session const reconnect = async () => { const accounts = await peraWallet.reconnectSession(); if (accounts.length > 0) { setWalletAddress(accounts[0]); } }; // Execute auto-buy payment const sendPayment = async (product: Product, walletAddress: string) => { const suggestedParams = await algodClient.getTransactionParams().do(); const txn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({ sender: walletAddress, receiver: walletAddress, // Demo: self-payment amount: 1000, // microAlgos suggestedParams, note: new TextEncoder().encode(`AURA auto-buy: ${product.title}`), }); const signedTxn = await peraWallet.signTransaction([[{ txn, signers: [walletAddress] }]]); const result = await algodClient.sendRawTransaction(signedTxn[0]).do(); console.log("Transaction ID:", result.txId); }; ``` -------------------------------- ### Implement PriceModal Component Source: https://context7.com/coder-cr07/databaes/llms.txt Displays a modal for setting target prices on products. Requires the PriceModal component and state management for the selected product. ```tsx import { PriceModal } from "@/components/PriceModal"; const [selectedProduct, setSelectedProduct] = useState(null); {selectedProduct && ( setSelectedProduct(null)} onSave={(targetPrice: number) => { // Store target price and start tracking setTargetPrices(prev => ({ ...prev, [selectedProduct.id]: targetPrice })); setStatusMap(prev => ({ ...prev, [selectedProduct.id]: "tracking" })); }} /> )} ``` -------------------------------- ### Implement ProductCard Component Source: https://context7.com/coder-cr07/databaes/llms.txt Displays individual product information with tracking status badge, target price display, and action buttons. ```tsx import { ProductCard } from "@/components/ProductCard"; import { Product, TrackingStatus } from "@/types/product"; const product: Product = { id: "dummyjson-1", title: "Wireless Headphones Pro", image: "https://cdn.dummyjson.com/products/images/headphones.png", price: 149.99, link: "https://dummyjson.com/products/1" }; openPriceModal(product.id)} /> // Displays: // - Product image with fallback handling // - Title and current price // - "View deal" link to external source // - Status badge: "Not tracking", "Tracking price...", or "Ready to buy" // - Target price if set // - "Set Target Price" button ``` -------------------------------- ### Define Application Routes Source: https://context7.com/coder-cr07/databaes/llms.txt Outlines the primary pages for the shopping workflow within the Next.js App Router structure. ```typescript // src/app/page.tsx - Home/Landing page // Displays hero section with "AI-NATIVE SHOPPING" tagline and "Get Started" CTA // src/app/upload/page.tsx - Image upload page // Drop zone for product images, triggers AI analysis on submit // src/app/results/page.tsx - Product results page // URL params: ?keyword=jacket&sig=12345 // Shows matching products, price tracking, wallet connection, auto-buy controls ``` -------------------------------- ### Define Product and Tracking Types Source: https://context7.com/coder-cr07/databaes/llms.txt Defines the core data structures for products and tracking states used throughout the application. ```typescript // src/types/product.ts export type TrackingStatus = "idle" | "tracking" | "success"; export type Product = { id: string; title: string; image: string; price: number; link: string; }; ``` -------------------------------- ### Implement Price Tracking and Auto-Buy Logic Source: https://context7.com/coder-cr07/databaes/llms.txt Uses useEffect hooks to poll product prices every 5 seconds and trigger transactions when target prices are met. ```typescript // Track prices with 5-second polling useEffect(() => { const trackingProducts = Object.entries(statusMap) .filter(([, status]) => status === "tracking") .map(([id]) => id); if (!trackingProducts.length) return; const timer = setInterval(() => { setCurrentPrices((prev) => { const next = { ...prev }; for (const productId of trackingProducts) { const current = prev[productId]; if (!current) continue; // Simulate price drift (0.94x to 1.0x) const drift = 0.94 + Math.random() * 0.06; next[productId] = Number((current * drift).toFixed(2)); } return next; }); }, 5000); return () => clearInterval(timer); }, [statusMap]); // Auto-buy when target price is reached useEffect(() => { for (const product of products) { const target = targetPrices[product.id]; if (!target || boughtProducts.includes(product.id)) continue; const current = currentPrices[product.id] ?? product.price; if (current <= target) { // Target hit! Execute purchase setStatusMap(prev => ({ ...prev, [product.id]: "success" })); await sendTestnetPayment(product); setBoughtProducts(prev => [...prev, product.id]); } } }, [currentPrices, targetPrices, products]); ``` -------------------------------- ### Implement UploadBox Component Source: https://context7.com/coder-cr07/databaes/llms.txt Provides drag-and-drop or click-to-select image upload functionality with preview display. ```tsx import { UploadBox } from "@/components/UploadBox"; function UploadPage() { const [loading, setLoading] = useState(false); const handleAnalyze = async (payload: { fileName: string; imageDataUrl: string }) => { setLoading(true); try { // Process the uploaded image const keyword = await detectKeywordFromImage(payload); router.push(`/results?keyword=${encodeURIComponent(keyword)}`); } finally { setLoading(false); } }; return ; } ``` -------------------------------- ### Persist Tracking State with localStorage Source: https://context7.com/coder-cr07/databaes/llms.txt Uses localStorage to maintain target prices and tracking status across sessions. Requires a browser environment to access the window object. ```typescript const STORAGE_KEY = "aura-tracking"; // Load tracking state on mount function loadTrackingState(): { targetPrices: PriceMap; statusMap: StatusMap } { if (typeof window === "undefined") { return { targetPrices: {}, statusMap: {} }; } const raw = localStorage.getItem(STORAGE_KEY); if (!raw) return { targetPrices: {}, statusMap: {} }; const parsed = JSON.parse(raw); return { targetPrices: parsed.targetPrices ?? {}, statusMap: parsed.statusMap ?? {}, }; } // Persist on every change useEffect(() => { localStorage.setItem(STORAGE_KEY, JSON.stringify({ targetPrices, statusMap })); }, [targetPrices, statusMap]); ``` -------------------------------- ### Implement TransactionModal Component Source: https://context7.com/coder-cr07/databaes/llms.txt Displays blockchain transaction status with visual feedback. Handles automated state transitions from processing to confirmed. ```tsx import { TransactionModal } from "@/components/TransactionModal"; setShowTxModal(false)} /> // Stages: // 1. "Processing on Algorand..." with spinner (2.2 seconds) // 2. "Transaction Confirmed!" with success checkmark // 3. Auto-closes after 4 seconds or manual "Done" button // Displays truncated then full transaction ID ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.