Verity is a modern and responsive e-commerce product discovery platform built with Next.js. It delivers a seamless shopping experience by enabling users to explore top-selling items, perform product searches, and view detailed product information β all in real-time using Amazonβs product data via RapidAPI.
It employs intelligent client-side caching strategies to reduce API calls, manage quota limits, and provide faster load times.
-
Curated Bestsellers: Homepage showcases top-selling items in categories like Electronics, Books, and Fashion.
-
Global Search: A universal search bar enables keyword-based product search.
-
Paginated Results: Dynamically renders search results with pagination support.
-
Product Detail Pages: Each product links to a dedicated page with complete details (price, ratings, specs, etc.).
-
Client-side Caching: Reduces redundant API calls using
sessionStorageto cache:- Bestseller lists
- Search results (per page)
- Product detail responses
-
Quantity Selector: Interactive control for choosing item quantity.
-
Action Buttons: βAdd to Cartβ and βBuy Nowβ buttons (placeholders for future integration).
-
Wishlist & Alternatives: Additional product interaction options to increase user engagement.
-
Responsive UI: Tailwind CSS ensures mobile-first design and cross-device compatibility.
-
Refined Aesthetics: Visually appealing product cards with hover effects and badges.
-
Next.js App Router: Utilizes dynamic routing (e.g.,
/products/[asin],/search/[query]) for SEO and structured navigation. -
Client Components: Pages and components that rely on state and effects are explicitly marked using
"use client". -
Custom Hooks: Abstraction for API interactions, loading states, and caching via:
useBestsellersuseSearchResultsuseProductDetails
-
API Integration: Connects to the Real-Time Amazon Data API via RapidAPI, using secure environment variables.
-
Image Optimization: Leverages Next.js
Imagecomponent for efficient rendering and lazy loading.
- Next.js 14+ (App Router)
- React & TypeScript
- Tailwind CSS
- Lucide React (icons)
- RapidAPI (Amazon product data)
- fetch API (network requests)
- sessionStorage (temporary client-side caching)
- Node.js v18+
- npm or yarn
git clone <your-repository-url>
cd verity
# Install dependencies
npm install
# or
yarn installCreate a .env.local file at the root and add:
NEXT_PUBLIC_RAPIDAPI_KEY=YOUR_RAPIDAPI_KEY_HERE
Note: Host and base URL (
real-time-amazon-data.p.rapidapi.com) are hardcoded insrc/lib/fetchProducts.ts. You may externalize them as needed.
In next.config.js, allow Amazon's CDN for image optimization:
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'm.media-amazon.com',
pathname: '/**',
},
],
},
};
module.exports = nextConfig;npm run dev
# or
yarn devVisit http://localhost:3000 in your browser.
verity/
βββ public/ # Static assets
βββ src/
β βββ app/ # App Router pages
β β βββ layout.tsx
β β βββ page.tsx
β β βββ products/
β β β βββ [asin]/page.tsx
β β βββ search/
β β βββ [id]/page.tsx
β βββ components/ # UI components
β β βββ ProductCard.tsx
β β βββ GridOption.tsx
β β βββ Header.tsx
β β βββ ui/ # Shadcn components
β βββ hooks/ # Custom React hooks
β β βββ useBestsellers.ts
β β βββ useSearchResults.ts
β β βββ useProductDetails.ts
β βββ lib/
β β βββ fetchProducts.ts
β βββ types/
β β βββ types.ts
β βββ globals.css # Tailwind & global styles
βββ next.config.js
βββ tailwind.config.ts
βββ tsconfig.json
βββ .env.local
βββ package.json
- Site navigation with search input and user icons.
- Uses
useRouterfor client-side navigation.
-
Reusable product display component with:
- Image hover effects
- Price and discount formatting
- "Best Seller" badge
- Links to
/products/[asin]
useBestsellers.ts: Fetches and caches category-based bestsellers.useSearchResults.ts: Handles paginated search queries and caching.useProductDetails.ts: Fetches full product data by ASIN and caches it.
- Centralized API utility with consistent headers, error handling, and response parsing.
-
Type definitions for:
BestsellerProduct,SearchProduct,ProductDetailsData- Associated API response types for safety and intellisense.
- Trigger: User action (e.g., search, navigation) initiates data fetch.
- Hook: Relevant custom hook is called.
- Cache Check: Hook looks up
sessionStoragefor cached results. - Cache Hit: Uses cached data to update UI instantly.
- Cache Miss: Calls
fetchProducts.tsto request new data. - Fetch: Constructs request with headers and API key.
- Response: Parses response or handles errors.
- Update: Updates component state and caches result.
- Tailwind CSS: Provides utility-first, responsive styling.
- Clean Layouts: Grid and flex layouts ensure a polished UX.
- Typography: Clear font sizing and spacing for readability.
- Animations: Smooth hover states, shadows, and transitions.
- Image Optimization: Uses
next/imagefor fast and responsive image loading.
You can deploy Verity using platforms like Vercel (recommended) or Netlify.
- Push your code to a Git repository (GitHub, GitLab, etc.).
- Import the repository into Vercel.
- Set environment variables (
NEXT_PUBLIC_RAPIDAPI_KEY) in the Vercel dashboard. - Deploy.
Contributions are welcome! Feel free to fork the repo, open issues, or submit PRs to improve functionality, fix bugs, or enhance the UI.
This project is licensed under the MIT License.