Skip to content

About

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

95 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›οΈ Advanced React E-Commerce Application

A comprehensive, modern e-commerce platform showcasing enterprise-level React development with TypeScript, Redux Toolkit, React Query, and advanced state management patterns.

Live Demo GitHub License

πŸ“‹ Table of Contents

🎯 Overview

This advanced e-commerce application is a full-featured online shopping platform built as part of the Frontend Development Specialization course at Coding Temple. The project demonstrates mastery of modern React development practices, state management, data fetching strategies, and production-ready application architecture.

Live Application: https://advanced-react-chi.vercel.app/

The application integrates with the FakeStore API to provide a realistic e-commerce experience with product browsing, category filtering, shopping cart management, and checkout functionality.

✨ Features

Core Functionality

  • πŸ“¦ Product Catalog

    • Dynamic product listing fetched via React Query
    • Display of title, price, category, description, ratings, and images
    • Real-time product search and filtering
    • Responsive grid and list view options
  • πŸ—‚οΈ Category Navigation

    • Dynamic category dropdown populated from API
    • Filter products by category (Electronics, Jewelry, Men's/Women's Clothing)
    • Dedicated category pages with breadcrumb navigation
    • Sort products by price, rating, and newest arrivals
  • πŸ›’ Shopping Cart

    • Add/remove products with instant feedback
    • Update product quantities with increment/decrement controls
    • Real-time total price calculation
    • Session storage persistence across page refreshes
    • Redux Toolkit for centralized state management
    • Visual cart badge with item count
  • πŸ’³ Checkout Process

    • Simulated checkout with order confirmation
    • Cart clearing functionality
    • Success modal with visual feedback
    • Session storage cleanup

Technical Features

  • 🎨 Modern UI/UX

    • Responsive design (mobile-first approach)
    • Smooth animations and transitions
    • Tailwind CSS styling with custom color palette
    • Accessible components with ARIA labels
    • Image fallback handling for broken URLs
  • ⚑ Performance Optimizations

    • React Query caching and background refetching
    • Code splitting and lazy loading
    • Optimized bundle size
    • Fast page loads with Vite
  • πŸ” State Management

    • Redux Toolkit for global cart state
    • React Query for server state
    • Local storage for cart persistence
    • Centralized state logic with slices
  • πŸ§ͺ Testing & Quality

    • 14 unit tests with Vitest
    • 21 end-to-end tests with Playwright
    • GitHub Actions CI/CD pipeline
    • Automated testing on pull requests
  • πŸ“‘ Observability

    • OpenTelemetry distributed tracing
    • HTTP instrumentation
    • Performance monitoring ready

πŸ› οΈ Tech Stack

Frontend

  • React 18.2.0 - Modern UI library with hooks and concurrent features
  • TypeScript 5.3.0 - Type-safe JavaScript for better developer experience
  • Vite 7.2.7 - Next-generation frontend tooling for lightning-fast builds

State Management

  • Redux Toolkit 1.9.7 - Simplified Redux with best practices built-in
  • React Query 5.0.0 - Powerful data synchronization for server state
  • Session Storage - Client-side cart persistence

Routing & Navigation

  • React Router DOM 6.20.0 - Declarative routing for React applications

Styling

  • Tailwind CSS 3.4.18 - Utility-first CSS framework
  • PostCSS - CSS transformations and optimizations
  • CSS Modules - Scoped styling for components

HTTP & API

  • Axios - Promise-based HTTP client
  • FakeStore API - RESTful API for product data

Testing

  • Vitest 4.0.15 - Blazing fast unit testing framework
  • Playwright 1.57.0 - End-to-end testing automation
  • Testing Library - User-centric testing utilities

DevOps & Tooling

  • GitHub Actions - CI/CD pipeline automation
  • Vercel/Netlify - Deployment platforms
  • ESLint - Code linting and formatting
  • OpenTelemetry - Distributed tracing and observability

πŸŽ“ Project Requirements

This project fulfills all requirements for the Advanced React E-Commerce assignment:

βœ… Product Catalog Requirements

  • React Query retrieves all products and displays on Home component
  • Shows title, price, category, description, rating, and image for each product
  • Add to cart button on each product
  • Image fallback implementation for 404 errors

βœ… Category Navigation Requirements

  • Dynamic select dropdown for product categories (not hardcoded)
  • React Query fetches categories from API endpoint
  • Filter products by selected category
  • Uses category-specific API endpoint for filtered results

βœ… Shopping Cart Requirements

  • Redux Toolkit manages shopping cart state
  • Reducers and actions for add, update, and remove operations
  • Shopping Cart component displays cart items
  • Shows title, image, quantity (count), and price for each item
  • Remove button for each product in cart
  • Add to cart directly from home product listing page

βœ… Session Storage Requirements

  • Cart data stored in sessionStorage
  • Data persists across components and browser sessions
  • Cart stored as array of product objects

βœ… Cart Calculations Requirements

  • Display total number of products in cart
  • Display total price of all products
  • Dynamic updates as cart contents change

βœ… Checkout Requirements

  • Checkout feature implemented
  • Simulated checkout clears Redux state and sessionStorage
  • Visual feedback on successful checkout

βœ… GitHub Repository Requirements

  • GitHub repository created with regular commits
  • Clean and interactive README.md with instructions
  • Clear explanations of application features

πŸ“¦ Installation & Setup

Prerequisites

  • Node.js 20.19.0+ (required for Vite 7)
  • npm, yarn, or pnpm
  • Git for version control

1. Clone the Repository

git clone https://github.com/justinwols88/Advanced-React.git
cd Advanced-React/my-store

2. Install Dependencies

npm install

3. Run Development Server

npm run dev

Open http://localhost:5173 in your browser.

4. Build for Production

npm run build

Output will be in the dist/ directory.

5. Preview Production Build

npm run preview

6. Run Tests

# Unit tests
npm test

# E2E tests
npm run test:e2e

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

πŸ“ Project Structure

my-store/
β”œβ”€β”€ public/                     # Static assets
β”‚   └── images/                # Product images
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/            # React components
β”‚   β”‚   β”œβ”€β”€ cart/             # Cart-specific components
β”‚   β”‚   β”‚   β”œβ”€β”€ CartIcon.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ CartItem.tsx
β”‚   β”‚   β”‚   └── CartSummary.tsx
β”‚   β”‚   β”œβ”€β”€ checkout/         # Checkout components
β”‚   β”‚   β”‚   └── CheckoutModal.tsx
β”‚   β”‚   β”œβ”€β”€ common/           # Reusable UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ Button.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ErrorBoundary.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ImageWithFallback.tsx
β”‚   β”‚   β”‚   └── Loader.tsx
β”‚   β”‚   β”œβ”€β”€ layout/           # Layout components
β”‚   β”‚   β”‚   β”œβ”€β”€ Header.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Footer.tsx
β”‚   β”‚   β”‚   └── Layout.tsx
β”‚   β”‚   β”œβ”€β”€ products/         # Product components
β”‚   β”‚   β”‚   β”œβ”€β”€ CategoryDropdown.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ProductCard.tsx
β”‚   β”‚   β”‚   └── ProductGrid.tsx
β”‚   β”‚   β”œβ”€β”€ Breadcrumb.tsx
β”‚   β”‚   β”œβ”€β”€ FilterSidebar.tsx
β”‚   β”‚   └── Pagination.tsx
β”‚   β”œβ”€β”€ hooks/                # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ useCart.ts        # Cart management hook
β”‚   β”‚   └── useProducts.ts    # Product fetching hook
β”‚   β”œβ”€β”€ pages/                # Page components
β”‚   β”‚   β”œβ”€β”€ Home.tsx          # Homepage with products
β”‚   β”‚   β”œβ”€β”€ CategoryPage.tsx  # Category listing page
β”‚   β”‚   β”œβ”€β”€ ProductDetail.tsx # Single product page
β”‚   β”‚   └── CartPage.tsx      # Shopping cart page
β”‚   β”œβ”€β”€ services/             # External services
β”‚   β”‚   β”œβ”€β”€ api.ts           # API calls to FakeStore
β”‚   β”‚   └── storage.tsx      # Session storage utilities
β”‚   β”œβ”€β”€ store/                # Redux store
β”‚   β”‚   β”œβ”€β”€ index.ts         # Store configuration
β”‚   β”‚   └── cartSlice.ts     # Cart state slice
β”‚   β”œβ”€β”€ types/                # TypeScript definitions
β”‚   β”‚   β”œβ”€β”€ product.types.ts
β”‚   β”‚   β”œβ”€β”€ cart.types.tsx
β”‚   β”‚   └── index.ts
β”‚   β”œβ”€β”€ utils/                # Utility functions
β”‚   β”‚   └── cn.ts            # Class name utilities
β”‚   β”œβ”€β”€ App.tsx               # Root component
β”‚   β”œβ”€β”€ main.tsx             # Application entry point
β”‚   └── routes.tsx           # Route definitions
β”œβ”€β”€ e2e/                      # End-to-end tests
β”‚   └── app.spec.ts          # Playwright test suite
β”œβ”€β”€ test/                     # Test utilities
β”‚   └── setup.ts             # Test configuration
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── main.yml         # CI/CD pipeline
β”œβ”€β”€ package.json             # Dependencies and scripts
β”œβ”€β”€ tsconfig.json            # TypeScript configuration
β”œβ”€β”€ vite.config.ts           # Vite configuration
β”œβ”€β”€ tailwind.config.js       # Tailwind CSS configuration
└── playwright.config.ts     # Playwright configuration

πŸ”§ Key Implementation Details

1. Product Listing with React Query

// Efficient data fetching with caching
const { data: products, isLoading, error } = useProducts(categoryId);
  • Automatic caching and background refetching
  • Error handling and loading states
  • Category-based filtering
  • Optimistic UI updates

2. Shopping Cart with Redux Toolkit

// Centralized cart state management
const dispatch = useDispatch();
dispatch(addToCart(product));
dispatch(updateQuantity({ id, quantity }));
dispatch(removeFromCart(id));
  • Immutable state updates with Immer
  • Action creators automatically generated
  • DevTools integration for debugging
  • Session storage middleware

3. Image Fallback Handling

// Graceful degradation for broken images
<ImageWithFallback
  src={product.image}
  alt={product.title}
  fallbackSrc="https://via.placeholder.com/300"
/>
  • Handles 404 errors from FakeStore API
  • Automatic fallback to placeholder images
  • No broken image icons visible to users

4. Category Navigation

// Dynamic category dropdown
const { data: categories } = useCategories();
<CategoryDropdown
  categories={categories}
  onChange={setSelectedCategory}
/>
  • Fetches categories from API (not hardcoded)
  • Filters products by selected category
  • Updates URL with category parameter

5. Checkout Process

// Simulated checkout with state clearing
const handleCheckout = () => {
  dispatch(clearCart());
  sessionStorage.removeItem('cart');
  showSuccessModal();
};

πŸ§ͺ Testing

Unit Tests (Vitest)

  • 14 passing tests covering components, hooks, and utilities
  • Testing Library for user-centric assertions
  • Mock implementations for external dependencies
npm test

End-to-End Tests (Playwright)

  • 21 passing tests covering critical user flows
  • Homepage product display
  • Product detail navigation
  • Add to cart functionality
  • Quantity updates
  • Cart management
  • Checkout process
  • Category filtering
npm run test:e2e

Continuous Integration

  • GitHub Actions workflow runs on every push
  • Automated testing on Node 20.x
  • Build verification before deployment
  • Test results reported in pull requests

πŸš€ Deployment

Deployed Sites

Deploy to Vercel

  1. Push code to GitHub
  2. Import repository in Vercel dashboard
  3. Configure build settings:
    • Framework Preset: Vite
    • Build Command: npm run build
    • Output Directory: dist
  4. Deploy automatically on every push

Deploy to Netlify

  1. Connect GitHub repository
  2. Configure build settings:
    • Build Command: npm run build
    • Publish Directory: dist
  3. Enable automatic deployments

πŸ”Œ API Integration

FakeStore URL

Error Handling

  • Graceful fallbacks for API failures
  • Image placeholder for 404 image errors
  • User-friendly error messages
  • Retry logic with React Query

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License.

πŸ™ Acknowledgments

πŸ‘¨β€πŸ’» Author

Justin Wold


This project was hand-crafted with many hours of focused care to build the best possible e-commerce experience. Every component, every interaction, and every line of code was thoughtfully designed and implemented with attention to detail and dedication to quality.

About

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages