A modern, fully-typed React e-commerce application with advanced filtering, sorting, and cart management.
- Product Listing with real-time filtering
- Advanced Sorting (Price, Name, Default)
- Multi-Filter Support (Category, Color, Brand)
- Search Functionality with instant results
- Shopping Cart with localStorage persistence
- URL State Sync for shareable links
- AI Shopping Assistant with Gemini integration
- Responsive Design (Mobile, Tablet, Desktop)
- TypeScript 6.0 for type safety
- Context API for state management
- Custom Hooks for reusable logic
- SCSS Modules for scoped styling
- Code Quality Tools (ESLint, Prettier, Husky)
- AI Integration (Google Gemini API)
- Production-Ready Error Handling with retry logic
- Mock API with real API ready structure
- React 18
- TypeScript 6.0
- React Router DOM v6
- Context API
- SCSS Modules
- Responsive Design
- Mobile-first approach
- ESLint
- Prettier
- Husky (Git hooks)
- lint-staged
- Axios
- LocalStorage
- Mock API with 500ms delay
- Google Gemini AI API
- Production-grade retry logic
- Node.js 24.x or higher
- npm or yarn
# Clone the repository
git clone https://github.com/Muhammet-Duran/product-list.git
# Navigate to project directory
cd product-list
# Install dependencies
npm install
# Create environment file
cp .env.example .env
# Add your Gemini API key to .env
REACT_APP_GEMINI_API_KEY=your_api_key_here
# Start development server
npm startThe app will open at http://localhost:3000
npm start # Start development server
npm run build # Build for production
npm test # Run testsnpm run fix # Format + Lint + Type check (all-in-one)
npm run format # Format with Prettier
npm run lint:fix # Fix ESLint errors
npm run type-check # Check TypeScript typessrc/
βββ api/ # API layer (mock & real)
β βββ fetch.ts # Axios instance
β βββ productData.ts # Product API calls
βββ components/ # Reusable components
β βββ SortControl/ # Product sorting dropdown
β βββ Sidebar/ # Filter sidebar
β βββ Products/ # Product grid
β βββ ChatWidget.tsx # AI chat assistant
β βββ ChatMessage.tsx # Chat message component
β βββ ...
βββ contexts/ # React Context
β βββ ProductContext.tsx # Global state management
β βββ ChatContext.tsx # Chat state management
βββ hooks/ # Custom hooks
β βββ useCart.ts # Cart logic
β βββ useProductFiltering.ts # Filter & sort logic
β βββ useWindowSize.ts # Responsive utilities
βββ services/ # External services
β βββ geminiService.ts # AI API integration
βββ constants/ # App constants
β βββ filterOptions.ts # Filter configurations
βββ types/ # TypeScript definitions
β βββ index.ts # Core types
β βββ api.types.ts # API types
β βββ hooks.types.ts # Hook types
β βββ chat.types.ts # Chat & AI types
βββ pages/ # Page components
β βββ Home.tsx # Product listing page
β βββ Cart.tsx # Shopping cart page
βββ Helpers/ # Utility functions
βββ styles/ # Global styles
Sort products by:
- Default (API order)
- Price: Low to High
- Price: High to Low
- Name: A-Z
- Name: Z-A
URL Sync: Sort state is saved in URL (?sort=price_asc)
Filter by multiple criteria:
- Category: Headset, Notebook, Phone
- Color: Black, Blue, Gold, Cream, White, Silver, Ivory, Pink
- Brand: Apple, Asus, Huawei, JBL, Samsung, Sony
- Add/remove products
- Increase/decrease quantity
- Persistent storage (localStorage)
- Real-time total calculation
- Mobile: Optimized layout with overlay filters
- Tablet: Adaptive grid system
- Desktop: Full-featured interface
Powered by Google Gemini AI:
- Smart Product Recommendations based on user queries
- Cart-Aware Responses considering current cart items
- Turkish Language Support for local users
- Scope-Limited AI (only shopping-related questions)
- Production-Grade Error Handling with automatic fallback
- Rate Limiting to prevent API abuse
Features:
- Real-time chat interface
- Typing indicators
- Message history
- Floating chat widget
- Mobile-optimized design
Example Queries:
- "Telefon ΓΆner" (Recommend a phone)
- "Sepetim ne kadar?" (How much is my cart?)
- "En ucuz laptop hangisi?" (Which is the cheapest laptop?)
Technical Implementation:
- Multiple Gemini model fallback (2.0-flash-lite β flash-lite-latest β 2.5-flash-lite)
- Exponential backoff retry logic
- User-friendly error messages
- Type-safe API integration
The app uses a mock API with local data for development and integrates with Google Gemini AI for the shopping assistant.
Features:
- β 500ms delay simulation
- β Async/await structure
- β Easy migration to real API
- β Axios configured
- β Google Gemini AI integration
- β Production-grade error handling
Create a .env file in the root directory:
# Base API URL (for future real API)
REACT_APP_BASE_URL=http://localhost:3002
# Google Gemini AI API Key (required for chat assistant)
REACT_APP_GEMINI_API_KEY=your_gemini_api_key_here
# Gemini API Base URL
REACT_APP_GEMINI_BASE_URL=https://generativelanguage.googleapis.com/v1- Visit Google AI Studio
- Create a new API key
- Copy the key to your
.envfile - Restart the development server
Free Tier Limits:
- 1,500 requests/day
- 15 requests/minute
- Completely free (no credit card required)
- Update
REACT_APP_BASE_URLin.env - Open
src/api/productData.ts - Uncomment the real API code
- Restart the app
Product API:
GET /products
GET /products?category=phone&color=black&brand=Samsung
AI Chat API:
POST https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent
Response Format:
{
"products": [
{
"productId": "uuid",
"title": "Product Name",
"brand": "Brand",
"category": "phone",
"color": "black",
"price": "100,00",
"discount": 10,
"imgUrl": "/path/to/image.png",
"quantity": 5
}
]
}This project uses automated code quality tools:
Every commit automatically runs:
- Prettier (formatting)
- ESLint (linting)
- Only on changed files (fast!)
- Strict mode enabled
- Path aliases configured (
@components,@hooks, etc.) - Full type coverage
See CODE_QUALITY.md for detailed setup and best practices.
Clean imports with configured aliases:
// Instead of this:
import { Product } from "../../../types";
// Use this:
import { Product } from "@types";
import Button from "@components/Button";
import { useCart } from "@hooks/useCart";Available aliases:
@/*βsrc/*@components/*βsrc/components/*@contexts/*βsrc/contexts/*@types/*βsrc/types/*@hooks/*βsrc/hooks/*@api/*βsrc/api/*
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Note: Pre-commit hooks will automatically format and lint your code!
This project follows conventional commits:
feat: add new feature
fix: bug fix
chore: maintenance tasks
docs: documentation updates
style: code style changes
refactor: code refactoring- React team for the amazing framework
- TypeScript team for type safety
- All contributors and users of this project
β If you like this project, please give it a star!



