PR
ProgrammerSiam/ps-Ecommerce
A modern, full-featured e-commerce dashboard built with Next.js 15, TypeScript, Tailwind CSS, and React Context for state management.
E-Commerce Dashboard
A modern, full-featured e-commerce dashboard built with Next.js 15, TypeScript, Tailwind CSS, and React Context for state management.
๐ Features
Core Functionality
- Product Listing: Browse all products with responsive grid layout
- Product Details: Comprehensive product pages with add-to-cart functionality
- Category Filtering: Filter products by category with real-time updates
- Search Functionality: Search products by title and description
- Sorting Options: Sort by name, price (low/high), and rating
- Shopping Cart: Add, remove, and update quantities with persistent state
- Add Products: Form to add new products with validation
- Pagination: Navigate through large product catalogs
Technical Features
- Next.js 15 with App Router for modern React development
- TypeScript for type safety and better developer experience
- Tailwind CSS for responsive, utility-first styling
- React Context for global state management
- TanStack Query for efficient data fetching and caching
- Image Optimization with Next.js Image component
- Responsive Design that works on all devices
๐ ๏ธ Tech Stack
- Framework: Next.js 15 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- State Management: React Context + TanStack Query
- API: FakeStore API (https://fakestoreapi.com)
- Deployment: Vercel-ready
๐ฆ Installation & Setup
Prerequisites
- Node.js 18+
- npm or yarn
Quick Start
-
Clone the repository
git clone <repository-url> cd yoooooo
-
Install dependencies
npm install
-
Run the development server
npm run dev
-
Open your browser
Navigate to http://localhost:3000
Available Scripts
npm run dev- Start development servernpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLint
๐๏ธ Project Structure
src/
โโโ app/ # Next.js App Router pages
โ โโโ layout.tsx # Root layout with providers
โ โโโ page.tsx # Home page
โ โโโ products/ # Product pages
โ โ โโโ page.tsx # Product listing
โ โ โโโ [id]/ # Dynamic product detail
โ โโโ cart/ # Cart page
โ โโโ add-product/ # Add product form
โโโ components/ # Reusable components
โ โโโ Header.tsx # Navigation header
โโโ context/ # React Context providers
โ โโโ CartContext.tsx # Cart state management
โโโ hooks/ # Custom React hooks
โ โโโ useProducts.ts # Data fetching hooks
โโโ styles/ # Global styles
โโโ globals.css # Tailwind CSS imports
๐จ Design Choices & Architecture
State Management
- React Context: Used for cart state management due to its simplicity and built-in React support
- TanStack Query: Implemented for server state management with caching, retries, and background updates
Component Architecture
- Functional Components: Modern React with hooks
- TypeScript: Full type safety for better development experience
- Responsive Design: Mobile-first approach with Tailwind CSS
Data Fetching Strategy
- TanStack Query: Provides caching, background updates, and error handling
- Optimistic Updates: Cart updates are immediate for better UX
- Error Boundaries: Graceful error handling with retry mechanisms
Performance Optimizations
- Image Optimization: Next.js Image component with proper sizing
- Code Splitting: Automatic with Next.js App Router
- Caching: TanStack Query provides intelligent caching
- Lazy Loading: Images and components load as needed
๐ง Configuration
Environment Variables
No environment variables required for this demo. The app uses the public FakeStore API.
Tailwind Configuration
Custom Tailwind config with:
- Custom color palette
- Responsive breakpoints
- Custom utilities
Next.js Configuration
- Image domains configured for FakeStore API
- TypeScript strict mode enabled
- ESLint configuration
๐ Deployment
Vercel (Recommended)
- Push your code to GitHub
- Connect your repository to Vercel
- Deploy automatically
Manual Deployment
npm run build
npm run start๐ฏ Features Breakdown
1. Product Listing (/products)
- Search: Real-time search by title and description
- Filtering: Category-based filtering
- Sorting: Multiple sort options (name, price, rating)
- Pagination: 12 items per page with navigation
- Responsive Grid: Adapts to screen size
2. Product Details (/products/[id])
- Comprehensive Info: Title, price, description, category, rating
- Add to Cart: Quantity selection and cart integration
- Image Gallery: Optimized product images
- Error Handling: Graceful 404 and error states
3. Shopping Cart (/cart)
- Item Management: Add, remove, update quantities
- Price Calculation: Real-time total calculation
- Empty State: Helpful messaging when cart is empty
- Order Summary: Subtotal, shipping, and total
4. Add Product (/add-product)
- Form Validation: Client-side validation with error messages
- API Integration: POST request to FakeStore API
- Success Feedback: Success message with auto-redirect
- Category Selection: Dropdown with predefined categories
๐ฎ Future Improvements
Performance Enhancements
- Server-Side Rendering: Implement SSR for better SEO
- Static Generation: Pre-render product pages
- Incremental Static Regeneration: Update content without full rebuild
- Bundle Optimization: Code splitting and tree shaking
Feature Additions
- User Authentication: Login/signup system
- Wishlist: Save products for later
- Product Reviews: User-generated reviews and ratings
- Advanced Search: Filters, price range, ratings
- Checkout Process: Payment integration
- Order History: Track past purchases
- Admin Dashboard: Manage products and orders
Technical Improvements
- Testing: Unit and integration tests
- Error Monitoring: Sentry or similar service
- Analytics: User behavior tracking
- PWA: Progressive Web App features
- Internationalization: Multi-language support
- Accessibility: WCAG compliance improvements
State Management
- Zustand: Consider replacing Context for complex state
- Redux Toolkit: For larger applications
- Server State: Expand TanStack Query usage
๐ Known Issues
- FakeStore API is for demo purposes only
- No real backend integration
- Cart state resets on page refresh (could be fixed with localStorage)
๐ Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
๐ License
This project is open source and available under the MIT License.
๐ Acknowledgments
- FakeStore API for providing demo data
- Next.js for the amazing framework
- Tailwind CSS for the utility-first CSS framework
- TanStack Query for data fetching
- Vercel for deployment platform
Built with โค๏ธ using Next.js, TypeScript, and Tailwind CSS
On this page
Languages
TypeScript94.4%CSS5.1%JavaScript0.5%
Contributors
Created August 1, 2025
Updated August 2, 2025