initial commit

This commit is contained in:
2025-08-27 14:12:38 -06:00
parent 7b28148b02
commit 0ca7d8353d
40 changed files with 2122 additions and 126 deletions

55
lib/history-storage.ts Normal file
View File

@@ -0,0 +1,55 @@
import type { Shoe } from "./shoe-database";
const HISTORY_KEY = "shoe_scan_history";
export function getHistory(): Shoe[] {
if (typeof window === "undefined") {
return [];
}
try {
const historyJson = localStorage.getItem(HISTORY_KEY);
if (historyJson) {
return JSON.parse(historyJson) as Shoe[];
}
} catch (error) {
console.error("Error reading history from localStorage", error);
}
return [];
}
export function addToHistory(shoe: Shoe): Shoe[] {
if (typeof window === "undefined") {
return [];
}
const currentHistory = getHistory();
// Avoid adding duplicates
if (currentHistory.some((item) => item.id === shoe.id)) {
return currentHistory;
}
const newHistory = [shoe, ...currentHistory];
// Limit history size if needed (e.g., to 20 items)
// const limitedHistory = newHistory.slice(0, 20);
try {
localStorage.setItem(HISTORY_KEY, JSON.stringify(newHistory));
return newHistory;
} catch (error) {
console.error("Error saving history to localStorage", error);
return currentHistory; // Return original history on error
}
}
export function clearHistory(): void {
if (typeof window === "undefined") {
return;
}
try {
localStorage.removeItem(HISTORY_KEY);
} catch (error) {
console.error("Error clearing history from localStorage", error);
}
}

17
lib/ml-classification.ts Normal file
View File

@@ -0,0 +1,17 @@
import { SHOE_DATABASE, type Shoe } from "./shoe-database";
/**
* Simulates detecting a shoe from a list of possible shoes.
* In a real application, this would involve a machine learning model.
* @param allShoes The list of all shoes in the database.
* @returns A randomly selected shoe.
*/
export function detectShoe(allShoes: Shoe[]): Shoe | null {
if (allShoes.length === 0) {
return null;
}
// Simulate detection by picking a random shoe from the database.
const randomIndex = Math.floor(Math.random() * allShoes.length);
return allShoes[randomIndex];
}

57
lib/shoe-database.ts Normal file
View File

@@ -0,0 +1,57 @@
export type Shoe = {
id: string;
name: string;
price: number;
description: string;
imageUrl: string;
colorOptions: { color: string; imageUrl: string }[];
};
export const SHOE_DATABASE: Shoe[] = [
{
id: "nike-air-max-90",
name: "Nike Air Max 90",
price: 130,
description: "A classic silhouette that has stood the test of time, offering comfort and style with its visible Air unit.",
imageUrl: "/nike-air-max-90-sneakers-main-view.png",
colorOptions: [
{ color: "White/Black", imageUrl: "/nike-air-max-90-white-black-sneakers.png" },
{ color: "Black/Red", imageUrl: "/nike-air-max-90-black-red-sneakers.png" },
{ color: "Blue/White", imageUrl: "/nike-air-max-90-blue-white-sneakers.png" },
],
},
{
id: "adidas-ultraboost-22",
name: "Adidas Ultraboost 22",
price: 190,
description: "Experience incredible energy return and cushioning with the BOOST midsole, designed for high-performance running.",
imageUrl: "/adidas-ultraboost-22-running-shoes-main-view.png",
colorOptions: [
{ color: "Black/White", imageUrl: "/adidas-ultraboost-22-black-white-running-shoes.png" },
{ color: "Grey/Orange", imageUrl: "/adidas-ultraboost-22-grey-orange-running-shoes.png" },
],
},
{
id: "converse-chuck-taylor",
name: "Converse Chuck Taylor",
price: 60,
description: "The iconic, timeless sneaker that works with any outfit. A staple for any wardrobe.",
imageUrl: "/converse-chuck-taylor-all-star-sneakers-main-view.png",
colorOptions: [
{ color: "Black", imageUrl: "/converse-chuck-taylor-black-canvas-sneakers.png" },
{ color: "White", imageUrl: "/converse-chuck-taylor-white-canvas-sneakers.png" },
{ color: "Red", imageUrl: "/converse-chuck-taylor-red-canvas-sneakers.png" },
],
},
{
id: "vans-old-skool",
name: "Vans Old Skool",
price: 65,
description: "The original skate shoe featuring the iconic sidestripe. A durable classic for on and off the board.",
imageUrl: "/vans-old-skool-skate-shoes-main-view.png",
colorOptions: [
{ color: "Black/White", imageUrl: "/vans-old-skool-black-white-skate-shoes.png" },
{ color: "Navy", imageUrl: "/vans-old-skool-navy-blue-skate-shoes.png" },
],
},
];

6
lib/utils.ts Normal file
View File

@@ -0,0 +1,6 @@
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}