Skip to content

About

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

๐Ÿ›’ Multi-Vendor E-Commerce Frontend

๐ŸŒŸ Overview

A modern, responsive frontend application for the multi-vendor e-commerce platform built with React 18, TypeScript, and Tailwind CSS. This application provides an intuitive interface for customers, vendors, and administrators with a focus on performance, accessibility, and user experience.

โœจ Key Features

๐Ÿ›๏ธ Customer Experience

  • Modern Marketplace: Beautiful product discovery with advanced filtering
  • Responsive Design: Optimized for all devices and screen sizes
  • Shopping Cart: Persistent cart with real-time updates
  • Wishlist: Save favorite products for later
  • Order Tracking: Real-time order status updates
  • User Reviews: Rate and review products and vendors
  • Search & Filter: Advanced product search with multiple filters

๐Ÿช Vendor Features

  • Vendor Dashboard: Comprehensive analytics and performance metrics
  • Product Management: Advanced product catalog with bulk operations
  • Order Management: Track and manage customer orders
  • Inventory Tracking: Real-time stock management with alerts
  • Sales Analytics: Detailed sales reports and insights
  • Profile Management: Complete vendor profile customization

๐Ÿ‘‘ Admin Features

  • System Dashboard: Platform-wide analytics and metrics
  • Vendor Management: Approve, reject, and manage vendor applications
  • User Management: Comprehensive user administration
  • Content Management: Manage categories, products, and content
  • System Analytics: Platform performance and usage statistics

๐ŸŽจ Modern UI/UX

  • Design System: Consistent, professional design language
  • Smooth Animations: Framer Motion powered transitions
  • Loading States: Skeleton screens and loading indicators
  • Error Handling: User-friendly error messages and fallbacks
  • Accessibility: WCAG 2.1 AA compliant components
  • Dark Mode: Optional dark theme support

๐Ÿš€ Quick Start

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn
  • Backend API running (see backend README)

Installation

  1. Clone and navigate to the project:

    git clone https://github.com/your-username/multi-vendor-ecommerce
    cd multi_vendor_ecom-main
  2. Install dependencies:

    npm install
    # or
    yarn install
  3. Environment Setup: Create a .env file in the root directory:

    # API Configuration
    VITE_API_BASE_URL=http://localhost:5000/api
    
    # Cloudinary Configuration
    VITE_CLOUDINARY_CLOUD_NAME=your_cloud_name
    VITE_CLOUDINARY_UPLOAD_PRESET=your_upload_preset
    
    # App Configuration
    VITE_APP_NAME=Multi-Vendor Marketplace
    VITE_APP_VERSION=1.0.0
    
    # Feature Flags
    VITE_ENABLE_DARK_MODE=true
    VITE_ENABLE_PWA=true
    VITE_ENABLE_ANALYTICS=true
  4. Start the development server:

    npm run dev
    # or
    yarn dev
  5. Open your browser: Navigate to http://localhost:5173

๐Ÿ—๏ธ Architecture

Technology Stack

  • Framework: React 18 with TypeScript
  • Build Tool: Vite for fast development and optimized builds
  • Styling: Tailwind CSS for utility-first styling
  • State Management: Redux Toolkit for predictable state management
  • Routing: React Router v6 for client-side routing
  • Animations: Framer Motion for smooth animations
  • Forms: React Hook Form for efficient form handling
  • HTTP Client: Axios for API communication
  • UI Components: Custom components with Radix UI primitives

Project Structure

src/
โ”œโ”€โ”€ components/                    # Reusable UI components
โ”‚   โ”œโ”€โ”€ ui/                       # Base UI components (Button, Input, etc.)
โ”‚   โ”œโ”€โ”€ modern/                   # Modern design components
โ”‚   โ”œโ”€โ”€ vendor/                   # Vendor-specific components
โ”‚   โ”œโ”€โ”€ marketplace/              # Marketplace components
โ”‚   โ”œโ”€โ”€ Dashboard/                # Dashboard components
โ”‚   โ”œโ”€โ”€ Home/                     # Homepage components
โ”‚   โ””โ”€โ”€ ErrorBoundary/            # Error handling components
โ”œโ”€โ”€ pages/                        # Page components
โ”‚   โ”œโ”€โ”€ HomePage/                 # Homepage and landing pages
โ”‚   โ”œโ”€โ”€ Products/                 # Product-related pages
โ”‚   โ”œโ”€โ”€ UserDashboard/            # User dashboard pages
โ”‚   โ”œโ”€โ”€ LoginPage/                # Authentication pages
โ”‚   โ””โ”€โ”€ ErrorPage/                # Error pages
โ”œโ”€โ”€ redux/                        # State management
โ”‚   โ”œโ”€โ”€ store.ts                  # Redux store configuration
โ”‚   โ”œโ”€โ”€ hook.ts                   # Typed hooks
โ”‚   โ”œโ”€โ”€ api/                      # RTK Query API slices
โ”‚   โ””โ”€โ”€ features/                 # Feature-based slices
โ”œโ”€โ”€ utils/                        # Utility functions
โ”œโ”€โ”€ types/                        # TypeScript type definitions
โ”œโ”€โ”€ hooks/                        # Custom React hooks
โ”œโ”€โ”€ lib/                          # Third-party library configurations
โ””โ”€โ”€ assets/                       # Static assets

Component Architecture

components/
โ”œโ”€โ”€ ui/                           # Base components
โ”‚   โ”œโ”€โ”€ button.tsx               # Reusable button component
โ”‚   โ”œโ”€โ”€ input.tsx                # Form input component
โ”‚   โ”œโ”€โ”€ card.tsx                 # Card container component
โ”‚   โ”œโ”€โ”€ table.tsx                # Data table component
โ”‚   โ””โ”€โ”€ badge.tsx                # Status badge component
โ”œโ”€โ”€ modern/                       # Modern UI components
โ”‚   โ”œโ”€โ”€ ModernNavbar.tsx         # Navigation component
โ”‚   โ”œโ”€โ”€ ModernFooter.tsx         # Footer component
โ”‚   โ”œโ”€โ”€ ModernBanner.tsx         # Hero banner component
โ”‚   โ”œโ”€โ”€ ProductCard.tsx          # Product display card
โ”‚   โ””โ”€โ”€ ProductGrid.tsx          # Product grid layout
โ”œโ”€โ”€ vendor/                       # Vendor components
โ”‚   โ”œโ”€โ”€ VendorDashboard.tsx      # Vendor analytics dashboard
โ”‚   โ”œโ”€โ”€ VendorRegistration.tsx   # Vendor application form
โ”‚   โ””โ”€โ”€ VendorProductManagement.tsx # Product management interface
โ””โ”€โ”€ marketplace/                  # Marketplace components
    โ”œโ”€โ”€ MarketplaceHome.tsx      # Marketplace homepage
    โ”œโ”€โ”€ VendorDirectory.tsx      # Vendor listing page
    โ””โ”€โ”€ ProductCatalog.tsx       # Product catalog page

๐ŸŽจ Design System

Color Palette

/* Primary Colors */
--primary-50: #eff6ff;
--primary-500: #3b82f6;
--primary-600: #2563eb;
--primary-700: #1d4ed8;

/* Secondary Colors */
--gray-50: #f9fafb;
--gray-100: #f3f4f6;
--gray-500: #6b7280;
--gray-900: #111827;

/* Status Colors */
--success: #10b981;
--warning: #f59e0b;
--error: #ef4444;
--info: #3b82f6;

Typography

  • Font Family: Inter (system fallback)
  • Font Sizes: 12px - 48px (responsive scale)
  • Font Weights: 400, 500, 600, 700, 800
  • Line Heights: 1.2 - 1.8 (contextual)

Spacing System

  • Base Unit: 4px
  • Scale: 4px, 8px, 12px, 16px, 20px, 24px, 32px, 40px, 48px, 64px
  • Breakpoints:
    • Mobile: < 768px
    • Tablet: 768px - 1024px
    • Desktop: > 1024px

๐Ÿ”„ State Management

Redux Store Structure

interface RootState {
  auth: {
    user: User | null;
    token: string | null;
    isAuthenticated: boolean;
    loading: boolean;
  };
  products: {
    items: Product[];
    filters: ProductFilters;
    loading: boolean;
    error: string | null;
  };
  cart: {
    items: CartItem[];
    total: number;
    itemCount: number;
  };
  vendors: {
    list: Vendor[];
    current: Vendor | null;
    loading: boolean;
  };
  ui: {
    theme: "light" | "dark";
    sidebarOpen: boolean;
    notifications: Notification[];
  };
}

API Integration

// RTK Query API slices
export const authApi = createApi({
  reducerPath: "authApi",
  baseQuery: fetchBaseQuery({
    baseUrl: "/api/auth",
    prepareHeaders: (headers, { getState }) => {
      const token = (getState() as RootState).auth.token;
      if (token) {
        headers.set("authorization", `Bearer ${token}`);
      }
      return headers;
    },
  }),
  tagTypes: ["User"],
  endpoints: (builder) => ({
    login: builder.mutation<LoginResponse, LoginRequest>({
      query: (credentials) => ({
        url: "/login",
        method: "POST",
        body: credentials,
      }),
    }),
    // ... other endpoints
  }),
});

๐Ÿ“ฑ Responsive Design

Mobile-First Approach

  • Base styles: Mobile (320px+)
  • Tablet styles: md: prefix (768px+)
  • Desktop styles: lg: prefix (1024px+)
  • Large desktop: xl: prefix (1280px+)

Touch-Friendly Interface

  • Minimum touch targets: 44px ร— 44px
  • Gesture support: Swipe, pinch, tap
  • Optimized navigation: Bottom navigation on mobile
  • Reduced motion: Respects user preferences

๐Ÿš€ Performance Optimization

Code Splitting

// Route-based code splitting
const HomePage = lazy(() => import("../pages/HomePage/HomePage"));
const ProductPage = lazy(() => import("../pages/Products/ProductsDetails"));
const VendorDashboard = lazy(
  () => import("../components/vendor/VendorDashboard")
);

// Component-based code splitting
const HeavyComponent = lazy(() => import("./HeavyComponent"));

Image Optimization

// Lazy loading with intersection observer
const LazyImage: React.FC<ImageProps> = ({ src, alt, ...props }) => {
  const [isLoaded, setIsLoaded] = useState(false);
  const [isInView, setIsInView] = useState(false);
  const imgRef = useRef<HTMLImageElement>(null);

  useEffect(() => {
    const observer = new IntersectionObserver(
      ([entry]) => {
        if (entry.isIntersecting) {
          setIsInView(true);
          observer.disconnect();
        }
      },
      { threshold: 0.1 }
    );

    if (imgRef.current) {
      observer.observe(imgRef.current);
    }

    return () => observer.disconnect();
  }, []);

  return (
    <img
      ref={imgRef}
      src={isInView ? src : undefined}
      alt={alt}
      onLoad={() => setIsLoaded(true)}
      className={`transition-opacity duration-300 ${
        isLoaded ? "opacity-100" : "opacity-0"
      }`}
      {...props}
    />
  );
};

Bundle Optimization

  • Tree shaking: Automatic dead code elimination
  • Code splitting: Route and component-based splitting
  • Asset optimization: Image compression and format optimization
  • Caching: Service worker for offline functionality

๐Ÿงช Testing

Testing Stack

  • Unit Testing: Vitest + React Testing Library
  • Component Testing: Storybook for component development
  • E2E Testing: Playwright for end-to-end testing
  • Visual Testing: Chromatic for visual regression testing

Test Structure

src/
โ”œโ”€โ”€ __tests__/                    # Test files
โ”‚   โ”œโ”€โ”€ components/              # Component tests
โ”‚   โ”œโ”€โ”€ pages/                   # Page tests
โ”‚   โ”œโ”€โ”€ utils/                   # Utility tests
โ”‚   โ””โ”€โ”€ hooks/                   # Custom hook tests
โ”œโ”€โ”€ __mocks__/                   # Mock files
โ””โ”€โ”€ test-utils/                  # Testing utilities

Running Tests

# Unit tests
npm run test
npm run test:watch
npm run test:coverage

# E2E tests
npm run test:e2e
npm run test:e2e:ui

# Visual tests
npm run test:visual

๐Ÿ”’ Security

Authentication

  • JWT tokens: Secure token-based authentication
  • Token refresh: Automatic token renewal
  • Route protection: Protected routes for authenticated users
  • Role-based access: Different access levels for users

Data Protection

  • Input sanitization: XSS protection
  • HTTPS enforcement: Secure data transmission
  • Environment variables: Secure configuration management
  • Content Security Policy: CSP headers for additional security

๐ŸŒ Internationalization (i18n)

Multi-language Support

// Language configuration
const resources = {
  en: {
    translation: {
      welcome: "Welcome to our marketplace",
      products: "Products",
      vendors: "Vendors",
    },
  },
  es: {
    translation: {
      welcome: "Bienvenido a nuestro mercado",
      products: "Productos",
      vendors: "Vendedores",
    },
  },
};

// Usage in components
const { t } = useTranslation();
return <h1>{t("welcome")}</h1>;

๐Ÿ“Š Analytics

User Analytics

  • Page views: Track page navigation
  • User interactions: Button clicks, form submissions
  • Performance metrics: Load times, error rates
  • Conversion tracking: Purchase funnel analysis

Implementation

// Analytics service
export const analytics = {
  track: (event: string, properties?: Record<string, any>) => {
    if (import.meta.env.VITE_ENABLE_ANALYTICS === "true") {
      // Send to analytics service
      gtag("event", event, properties);
    }
  },
  page: (path: string) => {
    if (import.meta.env.VITE_ENABLE_ANALYTICS === "true") {
      gtag("config", "GA_MEASUREMENT_ID", {
        page_path: path,
      });
    }
  },
};

๐Ÿ”ง Build & Deployment

Build Configuration

// vite.config.ts
export default defineConfig({
  plugins: [
    react(),
    // PWA plugin for offline functionality
    VitePWA({
      registerType: "autoUpdate",
      workbox: {
        globPatterns: ["**/*.{js,css,html,ico,png,svg}"],
      },
    }),
  ],
  build: {
    // Optimize bundle size
    rollupOptions: {
      output: {
        manualChunks: {
          vendor: ["react", "react-dom"],
          ui: ["@radix-ui/react-dialog", "@radix-ui/react-dropdown-menu"],
        },
      },
    },
  },
});

Deployment Scripts

{
  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
    "preview": "vite preview",
    "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
    "lint:fix": "eslint . --ext ts,tsx --fix",
    "type-check": "tsc --noEmit",
    "test": "vitest",
    "test:ui": "vitest --ui",
    "test:coverage": "vitest --coverage",
    "storybook": "storybook dev -p 6006",
    "build-storybook": "storybook build"
  }
}

๐Ÿš€ Deployment

Netlify Deployment

  1. Build the project:

    npm run build
  2. Deploy to Netlify:

    # Using Netlify CLI
    npm install -g netlify-cli
    netlify deploy --prod --dir=dist
    
    # Or connect GitHub repository in Netlify dashboard
  3. Environment Variables: Configure in Netlify dashboard:

    VITE_API_BASE_URL=https://your-api-domain.vercel.app/api
    VITE_CLOUDINARY_CLOUD_NAME=your_cloud_name
    VITE_CLOUDINARY_UPLOAD_PRESET=your_upload_preset
    

Vercel Deployment

  1. Install Vercel CLI:

    npm i -g vercel
  2. Deploy:

    vercel --prod

๐Ÿ“ˆ Performance Metrics

Core Web Vitals

  • Largest Contentful Paint (LCP): < 2.5s
  • First Input Delay (FID): < 100ms
  • Cumulative Layout Shift (CLS): < 0.1

Bundle Size Targets

  • Initial bundle: < 200KB gzipped
  • Route chunks: < 100KB gzipped
  • Vendor chunks: < 150KB gzipped

๐Ÿ”ฎ Future Enhancements

Planned Features

  • Progressive Web App (PWA) capabilities
  • Offline functionality with service workers
  • Real-time notifications with WebSockets
  • Advanced search with Elasticsearch integration
  • Voice search capabilities
  • Augmented Reality (AR) product preview
  • Social commerce features
  • Advanced personalization engine

Technical Improvements

  • Micro-frontend architecture
  • Server-side rendering (SSR) with Next.js
  • Edge computing with Cloudflare Workers
  • Advanced caching strategies
  • Performance monitoring with Sentry
  • A/B testing framework
  • Advanced analytics dashboard

๐Ÿค Contributing

Development Workflow

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes with proper testing
  4. Commit your changes: git commit -m 'Add amazing feature'
  5. Push to the branch: git push origin feature/amazing-feature
  6. Open a Pull Request

Code Standards

  • TypeScript: Strict type checking enabled
  • ESLint: Code quality and consistency
  • Prettier: Code formatting
  • Conventional Commits: Standardized commit messages
  • Component Documentation: Storybook stories for components

Pull Request Guidelines

  • Include tests for new features
  • Update documentation as needed
  • Ensure all tests pass
  • Follow the existing code style
  • Add screenshots for UI changes

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • React Team: For the amazing React framework
  • Tailwind CSS: For the utility-first CSS framework
  • Framer Motion: For smooth animations
  • Radix UI: For accessible UI primitives
  • Vite Team: For the fast build tool
  • Open Source Community: For the incredible ecosystem

๐Ÿ“ž Support


Built with โค๏ธ for the modern web

About

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages