A modern, full-stack e-commerce application for a baseball cap store built with Next.js 15 and Cloudinary. This project demonstrates media literacy best practices for developers, showcasing how to effectively manage and transform images using Cloudinary's powerful API enhanced with AI.
This application supports the "Cloud to Crowd" Media IQ for Developers with AI course on Cloudinary Academy, free for all and designed for the Cloudinary Creators Program. Learn more at https://community.cloudinary.com and take the course at https://training.cloudinary.com/learn/course/devrel-c2c-ai
- Product Catalog: Browse available baseball caps with detailed product pages
- Cloudinary Integration: Dynamic image optimization, transformations, and overlays
- Responsive Design: Beautiful, mobile-first UI built with Tailwind CSS
- Admin Panel: Access admin features and utilities
- Image Transformations: Automatic cropping, watermarking, and discount badges
- AI Enhancements: Color picker and AI-generated recoloring
- Server-Side Rendering: Fast, SEO-friendly pages with Next.js App Router
- Framework: Next.js 15+ (App Router)
- Language: TypeScript 5
- Styling: Tailwind CSS 4
- Image Management: Cloudinary & next-cloudinary
- Deployment: Platform-agnostic (build/run from
final/) - Runtime: React 19+
- Node.js 20+
- npm or yarn
- Cloudinary account (free tier works)
- CodeSandbox account (if you want to try a sandbox rather than a local build)
-
Clone the repository
git clone <repository-url> cd start # starter, or cd final # completed version
-
Install dependencies
npm install
-
Set up environment variables
To run either version of this app, create a
.env.localfile in thestart/orfinal/directory you're using with the following variables (seestart/.env.examplefor the required variable names):NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME=your_cloud_name NEXT_PUBLIC_CLOUDINARY_API_KEY=your_api_key CLOUDINARY_API_SECRET=your_api_secret NEXT_PUBLIC_CLOUDINARY_UPLOAD_PRESET=baseball-cap-store NEXT_PUBLIC_CLOUDINARY_FOLDER_NAME=baseball-cap-store
Run these commands from the directory you want to run: start/ or final/.
npm run devThe application will be available at http://localhost:3000
npm run build
npm startnpm run lintThe start/ directory contains the starter version; final/ contains the completed version. The structure below is for final/.
final/
├── app/ # Next.js App Router pages
│ ├── admin/ # Admin panel pages
│ ├── products/ # Product detail pages
│ └── page.tsx # Home page
├── components/ # React components
│ ├── ProductCard.tsx # Product card component
│ └── ProductImage.tsx # Cloudinary image component
│ └── ImageModal.tsx # Opening an image in a modal
│ └── ColorSelector.tsx # An AI-enhanced color picker
├── lib/ # Utility libraries
│ ├── cloudinary.ts # Cloudinary configuration
├── products/ # Product data
│ └── products.json # Product catalog
├── scripts/ # Utility scripts
│ └── add-logo.ts # Logo upload script
├── types/ # TypeScript type definitions
└── logo/ # Logo assets
This repo does not include a platform-specific deployment config (for example, no netlify.toml).
Build and run from the final/ directory and set the required Cloudinary env vars:
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAMENEXT_PUBLIC_CLOUDINARY_API_KEYCLOUDINARY_API_SECRETNEXT_PUBLIC_CLOUDINARY_UPLOAD_PRESETNEXT_PUBLIC_CLOUDINARY_FOLDER_NAME
This project demonstrates several Cloudinary capabilities:
- Automatic Image Optimization: Format and quality optimization
- Smart Cropping: Automatic gravity-based cropping (
gravity: 'auto') - Overlays: Logo watermarking on product images
- Dynamic Transformations: Discount badges and text overlays
- Responsive Images: Automatic sizing and format selection
Run these scripts from start/ or final/.
npm run dev- Start development server with Turbopacknpm run build- Build for production with Turbopacknpm run start- Start production servernpm run lint- Run ESLint
final/app/page.tsx- Home page with product listingfinal/app/products/[id]/page.tsx- Individual product detail pagefinal/components/ProductImage.tsx- Cloudinary image component with transformationsfinal/components/ImageModal.tsx- Modal windowfinal/ColorSelector.tsx- Color picker with AI integrationfinal/lib/cloudinary.ts- Cloudinary SDK configurationfinal/next.config.ts- Next.js configuration (Server Actions body size limit)
The app reads products/products.json from process.cwd(). If you still encounter issues:
- Verify your build/run working directory is
final/ - Verify the deployed files include
final/products/products.json
- Verify all environment variables are set correctly
- Check that the upload preset exists in your Cloudinary dashboard
- Ensure product images are uploaded to the correct folder in Cloudinary
- Run
npm run initto upload the logo if it's missing
- Check that all required environment variables are set
- Ensure the build/run working directory is
final/ - Ensure Node.js version is 20+ in your build settings
- Next.js Documentation
- Cloudinary Documentation
- next-cloudinary Documentation
- Tailwind CSS Documentation
This project is part of our 'Cloud to Crowd' course on media literacy for developers.
Built with ❤️ using Next.js by the Cloudinary Developer Relations Team