Skip to content

EmanuelLt/modern-clothing-ecommerce

Repository files navigation

Modern Clothing E-commerce

A modern e-commerce platform built with Next.js, TypeScript, and Tailwind CSS, featuring real product images, optimized performance, and powerful search functionality.

✨ Recent Updates - Global Search Implementation

🔍 Search System Overhaul

We've implemented a comprehensive search system that allows users to find products quickly and efficiently across the entire catalog.

1. Advanced Search Features

  • Global Search Bar: Accessible from navbar on all pages
  • Real-time Search: Instant results as you type (debounced for performance)
  • Smart Suggestions: Auto-complete suggestions based on product names, categories, and tags
  • Recent Searches: Persistent search history with localStorage
  • Search Highlighting: Visual highlighting of search terms in results
  • Multi-field Search: Searches across product names, descriptions, categories, colors, and tags

2. Search Implementation Details

Search Store (Zustand):

// lib/stores/search-store.ts
- Global search state management
- Recent searches persistence
- Search results caching
- Loading states and error handling

Search API Functions:

// lib/api/products.ts
- searchProducts(): Full-text search across product data
- getSearchSuggestions(): Auto-complete suggestions
- Relevance-based sorting (exact matches first)
- Performance optimized with debouncing

Advanced Search Component:

// components/search/search-component.tsx
- Dropdown with suggestions and recent searches
- Real-time results preview
- Keyboard navigation (Escape, Ctrl+K)
- Click-outside handling
- Mobile-responsive design

3. Search Features in Detail

Smart Search Algorithm:

  • ✅ Product name matching (exact and partial)
  • ✅ Description text search
  • ✅ Category matching
  • ✅ Color matching
  • ✅ Tag-based search
  • ✅ Relevance scoring (exact matches prioritized)
  • ✅ Case-insensitive search
  • ✅ Special character handling

User Experience:

  • Instant Search: Results appear as you type (300ms debounce)
  • Search Suggestions: Auto-complete with recent searches
  • Loading States: Visual feedback during search
  • No Results Handling: Helpful messages and alternatives
  • Search Persistence: Recent searches saved to localStorage
  • URL Integration: Search terms reflected in URL for bookmarking

Search UI Components:

  • Navbar Integration: Seamlessly integrated search bar
  • Mobile Search: Optimized mobile search experience
  • Search Results Page: Dedicated page with filtering
  • Quick Results Preview: Preview results in dropdown
  • Search Query Display: Clear indication of current search

4. Technical Implementation

Search Hook:

// hooks/use-search.ts
const {
  query,
  searchResults,
  suggestions,
  isSearching,
  search,
  clear
} = useSearch({
  debounceMs: 300,
  enableSuggestions: true,
  persistToLocalStorage: true
})

Search Utilities:

// lib/utils.ts
- normalizeSearchQuery(): Clean and normalize search terms
- highlightSearchTerm(): Highlight matches in results
- debounce(): Performance optimization for search input
- areQueriesSimilar(): Prevent duplicate recent searches

5. Search Performance Optimizations

  • Debounced Input: 300ms delay to reduce API calls
  • Query Caching: TanStack Query caching for repeated searches
  • Stale-while-revalidate: 30s stale time for search results
  • Efficient Filtering: Client-side filtering for better performance
  • Lazy Loading: Search suggestions loaded only when needed

🚀 Search Usage Examples

Basic Search:

// Search for "jacket"
searchProducts("jacket") // Returns leather jacket, denim jacket, etc.

Category Search:

// Search for "shoes" 
searchProducts("shoes") // Returns all shoe products

Tag-based Search:

// Search for "casual"
searchProducts("casual") // Returns products tagged as casual

Color Search:

// Search for "black"
searchProducts("black") // Returns all black products

🎯 Search Performance Metrics

  1. Search Speed: < 300ms average response time
  2. Accuracy: Relevance-based scoring ensures best matches first
  3. Coverage: Searches across 5+ product fields
  4. UX: Instant feedback with loading states
  5. Persistence: Recent searches saved locally

🛠️ Search Architecture

┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│   Search Bar    │───▶│   Search Store   │───▶│   Search API    │
│  (Navbar/Page)  │    │   (Zustand)      │    │  (Products)     │
└─────────────────┘    └──────────────────┘    └─────────────────┘
         │                       │                       │
         ▼                       ▼                       ▼
┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│   Search UI     │    │  Recent Searches │    │ Search Results  │
│  (Suggestions)  │    │ (localStorage)   │    │   (Filtered)    │
└─────────────────┘    └──────────────────┘    └─────────────────┘

📱 Mobile Search Experience

  • Responsive Design: Optimized for mobile screens
  • Touch-friendly: Large touch targets and smooth interactions
  • Mobile Sheet: Full-screen search on mobile devices
  • Keyboard Handling: Proper mobile keyboard support

✨ Previous Updates - Real Product Images Implementation

🖼️ Image System Overhaul

We've completely replaced placeholder images with high-quality, real product images from Unsplash. Here's what was implemented:

1. Product Catalog Enhancement

  • 12 new products with real clothing images
  • Multiple images per product for better product showcasing
  • Diverse categories: T-Shirts, Jeans, Blazers, Dresses, Jackets, Sweaters, Shoes, Accessories, Hoodies, Shirts, Athletic wear
  • Realistic pricing and detailed descriptions

2. Image Optimization & Performance

  • Next.js Image Optimization: Configured for external Unsplash images
  • Responsive sizing: Optimized for different screen sizes
  • Lazy loading: Images load as needed to improve performance
  • Error handling: Fallback to placeholder if images fail to load
  • Loading states: Smooth transitions with loading animations

3. Component Improvements

ProductCard Component:

  • ✅ Loading state indicators
  • ✅ Error handling with fallbacks
  • ✅ Optimized image sizing
  • ✅ Better hover effects
  • ✅ Stock status indicators

ProductDetails Component:

  • ✅ Image gallery with thumbnail navigation
  • ✅ Smooth image transitions
  • ✅ Multiple image viewing
  • ✅ Enhanced loading states
  • ✅ Stock quantity management

Hero Section & Categories:

  • ✅ High-quality hero background
  • ✅ Category showcase with real fashion images
  • ✅ Optimized for different viewports

4. Technical Enhancements

Next.js Configuration:

// next.config.js
images: {
  remotePatterns: [
    {
      protocol: 'https',
      hostname: 'images.unsplash.com',
      pathname: '/**',
    }
  ],
  unoptimized: false, // Enable optimization
}

Utility Functions:

  • getSafeImageUrl() - Safe image URL handling
  • getOptimizedImageUrl() - Unsplash URL optimization
  • formatPrice() - Consistent price formatting
  • calculateDiscountPercentage() - Sale calculations

5. Image Sources & Quality

  • Source: High-resolution images from Unsplash
  • Optimization: Automatic format conversion (WebP when supported)
  • Sizing: Responsive with proper aspect ratios
  • Quality: 80% quality for optimal balance of size/quality

🚀 Performance Benefits

  1. Faster Loading: Optimized images with Next.js Image component
  2. Better UX: Loading states and smooth transitions
  3. Mobile Optimized: Responsive images for all devices
  4. SEO Friendly: Proper alt text and semantic markup
  5. Error Resilient: Graceful fallbacks if images fail

🎨 Visual Improvements

  • Professional Look: Real product photography
  • Consistent Styling: Uniform image treatment across components
  • Modern Design: Updated hover effects and transitions
  • Accessibility: Proper alt text and loading indicators

🛠️ Development Features

  • TypeScript: Full type safety for image handling
  • Error Boundaries: Graceful error handling
  • Loading States: User-friendly loading indicators
  • Responsive Design: Mobile-first approach
  • Performance Monitoring: Optimized Core Web Vitals

🚀 Getting Started

# Install dependencies
npm install

# Run development server
npm run dev

# Build for production
npm run build

📁 Project Structure

├── components/
│   ├── products/           # Product-related components
│   ├── search/             # Search components
│   ├── home/              # Homepage components
│   └── ui/                # Reusable UI components
├── lib/
│   ├── api/               # API functions (including search)
│   ├── stores/            # State management (including search store)
│   ├── types.ts           # TypeScript definitions
│   └── utils.ts           # Utility functions
├── hooks/
│   └── use-search.ts      # Search hook
└── app/                   # Next.js app directory

🌟 Features

  • 🔍 Global Search: Advanced search with suggestions and real-time results
  • 🖼️ Real Product Images: Professional clothing photography
  • 📱 Responsive Design: Mobile-first approach
  • ⚡ Performance Optimized: Next.js Image optimization and search debouncing
  • 🔒 Type Safe: Full TypeScript implementation
  • 🎨 Modern UI: Tailwind CSS + Shadcn/ui components
  • 🛒 Shopping Cart: Zustand state management
  • 🔧 Product Filtering: Advanced filtering options
  • 💾 Search Persistence: Recent searches saved locally
  • ⌨️ Keyboard Shortcuts: Ctrl+K to focus search, Escape to close

🧰 Tech Stack

Category Technology
Framework Next.js 14 (App Router, RSC)
Language TypeScript 5
UI & Styling Tailwind CSS, Radix UI primitives via shadcn/ui, tailwind-merge, tailwindcss-animate
State Management Zustand
Data Fetching TanStack React Query (+ Devtools)
Validation Zod
Auth & DB Firebase v10 (easily swappable for Supabase)
Charts & Visuals Recharts
Carousel Embla Carousel
Icons Lucide-react
Misc clsx, cva, immer, date-fns, use-sync-external-store

All dependencies are pinned to their latest stable versions as listed in package.json.

Built with ❤️ using Next.js, TypeScript, and modern web technologies.

About

clothe store

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published