Skip to content

Latest commit

Β 

History

87 Commits

Folders and files

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

Repository files navigation

freeCommerce - E-commerce App

A modern open-source e-commerce application built with React, TypeScript, and Vite, using DummyJSON API for product data.

πŸš€ Features Implemented

Core Functionality

  • Product Catalog: Browse all products with pagination
  • Category Navigation: Filter products by categories
  • Product Search: Search functionality across all products
  • Product Details: Individual product pages with images, reviews, and pricing
  • Shopping Basket: Add/remove items with persistent storage
  • Price Display: Formatted pricing with discount calculations

Routing & Navigation

  • File-based routing with TanStack Router
  • Dynamic routes for products and categories
  • Search functionality with URL parameters

State Management

  • Zustand for basket state management
  • Persistent storage using localStorage
  • React Query for server state and caching

UI/UX

  • Responsive design with Tailwind CSS
  • Loading states with spinners
  • Toast notification system for user feedback
  • Error handling and user feedback
  • Material Symbols icons
  • Custom components library with enhanced Button component
  • User Menu Dropdown: Interactive menu for logged-in users with My Account, Order History, and Logout options
  • Order History Display: Full order history with expandable details showing items, shipping, and payment info
  • Product Filters: Sort by name/price/rating and filter by minimum rating

πŸ”§ Tech Stack

Core Technologies

  • React 19 - UI framework
  • TypeScript - Type safety
  • Vite - Build tool and dev server
  • Tailwind CSS 4 - Styling framework

Key Libraries

  • @tanstack/react-router - File-based routing
  • @tanstack/react-query - Server state management
  • Zustand - Client state management
  • Zod - Schema validation and data safety
  • @vitejs/plugin-react-swc - Fast refresh with SWC

Development Tools

  • ESLint - Code linting
  • Prettier - Code formatting
  • TypeScript ESLint - TypeScript-specific linting
  • Vitest - Unit testing framework
  • pnpm - Package manager

πŸ“ Project Structure

src/
β”œβ”€β”€ api/           # API layer (products, auth)
β”‚   β”œβ”€β”€ auth/      # Authentication endpoints (login, me, logout)
β”‚   └── products/  # Product endpoints (getProducts, etc.)
β”œβ”€β”€ routes/        # File-based routes
β”‚   β”œβ”€β”€ auth/      # Authentication routes (login, my-account)
β”‚   β”œβ”€β”€ checkout/  # Checkout routes (index, order-confirmation)
β”‚   β”œβ”€β”€ product/   # Individual product pages
β”‚   └── products/  # Product listing pages
β”œβ”€β”€ stores/        # Zustand stores
β”‚   β”œβ”€β”€ basket/    # Shopping basket state
β”‚   β”œβ”€β”€ order/     # Order state and history
β”‚   β”œβ”€β”€ toast/     # Toast notification state
β”‚   └── user/      # User state (empty - using context instead)
β”œβ”€β”€ types/         # TypeScript type definitions
β”œβ”€β”€ ui/            # UI components and styles
β”‚   └── components/# Reusable components (Button, Login, Basket, Toast, etc.)
β”œβ”€β”€ utils/         # Utility functions (price, date formatting)
└── main.tsx       # App entry point

πŸ”§ How It Works & Customization

Architecture Overview

The app follows a modular architecture with clear separation of concerns:

  • API Layer (src/api/): Handles all external data fetching
  • Routes (src/routes/): File-based routing with TanStack Router
  • Stores (src/stores/): Client-side state management with Zustand
  • Components (src/ui/components/): Reusable UI components
  • Types (src/types/): TypeScript interfaces for type safety

Customizing API Endpoints

  1. Change Base URL: Update vite.config.ts proxy configuration:
proxy: {
  '/api': {
    target: 'https://your-api.com',
    changeOrigin: true,
    rewrite: (path) => path.replace(/^\/api/, '')
  }
}
  1. Update API Functions: Modify functions in src/api/ to match your backend:

  2. Update Type Definitions: Modify src/types/index.d.ts to match your data contracts:

Adding New Features

  • New Routes: Add files to src/routes/ (auto-generated routing)
  • New API Endpoints: Create functions in src/api/
  • New State: Add stores in src/stores/
  • New Components: Add to src/ui/components/

πŸ› οΈ Development

# Install dependencies
pnpm install

# Start development server
pnpm dev

# Build for production
pnpm build

# Preview production build
pnpm preview

# Lint code
pnpm lint

# Format code
pnpm format

# Run tests
pnpm test

🌐 API Integration

The app uses DummyJSON API with a proxy configuration:

  • Base URL: https://dummyjson.com/
  • Proxy: /api routes are proxied to the base URL
  • Endpoints: Products, categories, search, authentication

πŸš€ Deployment

Netlify

The app is configured for Netlify deployment with:

  • _redirects file: Handles API proxy and SPA routing in production
  • API Proxy: /api/* routes redirect to https://dummyjson.com/
  • SPA Support: All routes serve index.html for client-side routing

πŸ“± Routes

  • / - Homepage with categories and top products
  • /products/all - All products listing
  • /products/search - Search results
  • /products/$category - Category-specific products
  • /product/$productSku - Individual product details
  • /basket - Shopping basket
  • /auth/login - User login
  • /auth/my-account - User profile
  • /checkout - Complete 3-step checkout process
  • /checkout/order-confirmation - Order confirmation with full details

πŸ—ΊοΈ Development Roadmap

Overall Completion: ~85% ⬆️ (Updated December 2025)

πŸ“‹ Recent Updates (December 2025)

  • βœ… User Menu Dropdown: Replaced static user name with interactive dropdown menu
  • βœ… Order History UI: Full order history display with expandable details
  • βœ… Product Filters: Added sorting (name/price/rating) and rating filter
  • βœ… Bug Fixes: Fixed order history persistence, removed non-functional features
  • βœ… Code Quality: TypeScript strict mode, all type checks passing

🚨 Critical Fixes (Priority 1) - 100% COMPLETE βœ…

  • Fix Authentication Flow βœ…

    • βœ… Update my-account.tsx - remove token parameter from me() call
    • βœ… Implement logout functionality (using login with 0 expiry)
    • βœ… Add silent error handling for expected 401s during auth checks
  • Complete Missing API Functions βœ…

    • βœ… Implement logout.ts function
    • βœ… Add proper error handling to all API calls
  • Security Enhancements βœ…

    • βœ… Fixed SSRF vulnerabilities in API layer
    • βœ… Refactored getProducts and getCategories to use structured parameters
    • βœ… Added Zod schema validation for all API responses
    • βœ… Implemented data transformation for Date fields

πŸ”§ Core Functionality (Priority 2) - 90% COMPLETE

  • User Account Management βœ…

    • βœ… Build user profile display in my-account.tsx
    • βœ… Add user data fetching and display
    • βœ… Optimize API calls with context passing
    • βœ… Add date formatting utility
    • βœ… Global auth context for shared state
    • βœ… Dynamic UI based on auth state (Login component)
    • βœ… Protected routes with beforeLoad guards
    • ❌ Implement account settings/preferences - TODO
  • Checkout Process βœ… FULLY IMPLEMENTED!

    • βœ… Complete CheckoutForm component with 3-step flow (shipping β†’ payment β†’ review)
    • βœ… Shipping form with Zod validation
    • βœ… Payment form with card validation
    • βœ… Review step before order placement
    • βœ… Order confirmation page with full details
    • βœ… Order store with localStorage persistence
    • βœ… Cart summary display in sidebar
    • βœ… Guest and logged-in user support
    • βœ… Input component for forms
    • βœ… Validation schemas (shipping, billing, payment)

🎨 UI/UX Improvements (Priority 3) - 100% COMPLETE βœ…

  • Form Validation βœ…

    • βœ… Zod installed and integrated in dependencies
    • βœ… Zod validation for API responses
    • βœ… Enhanced Button component with disabled state
    • βœ… Error messages in all forms
    • βœ… Loading states in components
  • Navigation & State βœ…

    • βœ… Show login/logout states in header (Login component)
    • βœ… Basket persists across sessions (localStorage)
    • βœ… Order history persists in localStorage
  • User Feedback βœ…

    • βœ… Toast notification system implemented with Zustand
    • βœ… Success notifications (green) when adding products to basket
    • βœ… Error notifications (red) when removing products from basket
    • βœ… Auto-dismiss notifications after 3 seconds
    • βœ… Image error handling with fallback placeholders
    • βœ… Enhanced Button component with disabled state support

πŸ§ͺ Testing & Quality (Priority 4) - 60% COMPLETE ⚠️

  • Fix Critical Security Issues βœ…

    • βœ… Implemented CSRF protection in API calls
    • βœ… Zod validation for API responses to prevent malicious data
    • βœ… Improved error handling in auth API calls
    • βœ… Runtime data validation with Zod schemas
    • ❌ Add input sanitization for user inputs - TODO
  • Expand Test Coverage ⚠️

    • βœ… Unit tests for utility functions (price, date formatting)
    • ❌ Add tests for auth API functions - TODO
    • ❌ Test protected route behavior - TODO
    • ❌ Add integration tests for login flow - TODO
    • ❌ Add component tests - TODO
  • Error Handling & Performance βœ…

    • βœ… Global error boundaries implemented (ErrorFallback, ErrorInfo)
    • βœ… Proper API error handling in auth functions
    • βœ… User-friendly error recovery UI
    • βœ… Development vs production error displays
    • ❌ Review performance in utility functions - TODO
    • ❌ Add network error recovery - TODO

πŸš€ Future Enhancements (Priority 5) - 100% COMPLETE βœ…

  • βœ… User Menu Dropdown: Interactive dropdown when logged in with navigation to My Account, Order History, and Logout
  • βœ… Order History UI: Complete order history display with expandable order details, persisted in localStorage
  • βœ… Product Filters: Sort by name/price/rating and filter by minimum rating with URL parameter persistence
  • ❌ Wishlist functionality - TODO
  • ❌ Product reviews/ratings submission (data exists, no form) - TODO
  • βœ… Mobile responsive improvements

πŸ”’ Security Best Practices

  • Use environment variables for sensitive configuration
  • Implement proper CORS policies
  • Add rate limiting for API endpoints
  • Validate and sanitize all user inputs

Sorry for not doing TDD! πŸ™ˆ I promise the code works... mostly... probably... please don't break it

🀝 Contributing & Collaboration

We Need Help! 🎨

This is currently a Proof of Concept focusing on technology implementation. We're looking for collaborators to help improve:

Design & UX

  • UI/UX Designer to create a cohesive design system
  • Improve visual hierarchy and user experience
  • Mobile-first responsive design improvements
  • Accessibility enhancements

Frontend Development

  • Component library expansion
  • Animation and micro-interactions
  • Performance optimizations
  • Advanced filtering and search features

Backend Integration

  • Real API integration beyond DummyJSON
  • Authentication and user management
  • Payment processing integration
  • Order management system

How to Contribute

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and add tests
  4. Run tests: pnpm test
  5. Commit changes: git commit -m 'Add amazing feature'
  6. Push to branch: git push origin feature/amazing-feature
  7. Open a Pull Request

Contact: Open an issue to discuss ideas or reach out for collaboration opportunities!

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages