A modern, full-stack e-commerce platform built specifically for fashion companies using cutting-edge technologies.
- Product Browsing: Advanced filtering, sorting, and search with grid/list views
- Product Details: Image gallery, variants, reviews, and related products
- Shopping Cart: Real-time cart management with quantity controls
- Secure Checkout: 3-step checkout (shipping, payment, review)
- User Authentication: Email/password and OAuth (Google, GitHub)
- Order Tracking: Complete order history with status timeline and tracking numbers
- User Profile: Account management with order history and saved addresses
- Address Management: Save multiple addresses with default selection
- Product Reviews: Customer reviews with star ratings
- Virtual Try-On: AI-powered try-on using OpenAI image model (upload photo, see products on you)
- Wishlist: Save favorite products for later
- Responsive Design: Fully optimized for mobile, tablet, and desktop
- Admin Dashboard: Overview with key metrics (products, orders, revenue)
- Product Management: Full CRUD operations with search and filters
- Inventory Tracking: Real-time stock management and status updates
- Order Management: Process orders, update status, and add tracking numbers
- Order Details: View customer info, shipping address, and payment status
- Role-Based Access: Protected admin routes for ADMIN and SUPER_ADMIN roles
- Quick Actions: Easy navigation to manage products, orders, and categories
- Server-Side Rendering: Fast page loads with Next.js 15 App Router
- Type Safety: End-to-end TypeScript for reliability
- Database Caching: Redis for improved performance
- Optimized Images: Next.js Image component for fast loading
- Protected Routes: Middleware-based authentication
- Form Validation: Zod schemas for data integrity
- SEO Optimized: Meta tags and semantic HTML
- Frontend: Next.js 15 (React 19), TypeScript, Tailwind CSS v4
- Backend: Next.js API Routes, Prisma ORM
- Database: PostgreSQL
- Caching: Redis (ioredis)
- Authentication: NextAuth.js with Prisma adapter
- AI Integration: OpenAI image model for Virtual Try-On feature
- Validation: Zod
- Icons: Lucide React
- Build Tool: Turbopack
Before you begin, ensure you have:
- Node.js 18 or higher
- npm or yarn
- PostgreSQL database (local or cloud - Railway, Supabase, Neon)
- Redis server (local or cloud - Upstash, Redis Cloud)
- Git
git clone <your-repo-url>
cd next-ecomnpm installCreate .env file from example:
cp .env.example .envRequired environment variables:
# Database
DATABASE_URL="postgresql://user:password@localhost:5432/fashion_ecom"
# Redis
REDIS_URL="redis://localhost:6379"
# NextAuth (Generate secret with: openssl rand -base64 32)
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-secret-here"
# Optional OAuth Providers
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"
GITHUB_CLIENT_ID="your-github-client-id"
GITHUB_CLIENT_SECRET="your-github-client-secret"
# Virtual Try-On (OpenAI)
OPENAI_API_KEY="your-openai-api-key"
OPENAI_IMAGE_MODEL="gpt-image-1" # Optional override# Generate Prisma Client
npx prisma generate
# Run migrations
npx prisma migrate dev --name init
# (Optional) Open Prisma Studio to view database
npx prisma studionpm run devVisit http://localhost:5000 π
After running the database seed, you can login with these admin credentials:
Email: admin@fashionstore.com
Password: admin123456
next-ecom/
βββ app/ # Next.js App Router
β βββ api/ # API endpoints
β β βββ auth/ # Authentication routes
β β βββ products/ # Product CRUD
β β βββ cart/ # Shopping cart
β β βββ orders/ # Order management
β β βββ categories/ # Category management
β β βββ addresses/ # Address management
β β βββ reviews/ # Product reviews
β β βββ virtual-tryon/# AI virtual try-on
β βββ products/ # Product listing & detail pages
β β βββ [slug]/ # Product detail with virtual try-on
β βββ cart/ # Shopping cart page
β βββ checkout/ # Checkout flow
β βββ auth/ # Sign in/up pages
β βββ profile/ # User profile & addresses
β βββ orders/ # Order history
β βββ admin/ # Admin dashboard
β βββ layout.tsx # Root layout with providers
β βββ page.tsx # Homepage
β βββ globals.css # Global styles
βββ components/ # Reusable components
β βββ Header.tsx # Navigation header
β βββ Footer.tsx # Site footer
β βββ ProductCard.tsx # Product card component
β βββ ProductGrid.tsx # Product grid layout
β βββ VirtualTryOnClient.tsx # AI try-on component
β βββ WishlistButton.tsx # Wishlist functionality
β βββ Providers.tsx # Context providers
βββ contexts/ # React contexts
β βββ CartContext.tsx # Cart state management
β βββ WishlistContext.tsx # Wishlist state management
βββ lib/ # Utilities and configs
β βββ prisma.ts # Prisma client singleton
β βββ redis.ts # Redis client & cache helpers
β βββ auth.ts # NextAuth configuration
β βββ utils.ts # Helper functions
β βββ validations.ts # Zod validation schemas
βββ prisma/
β βββ schema.prisma # Database schema
βββ types/ # TypeScript definitions
β βββ index.ts
β βββ next-auth.d.ts
βββ middleware.ts # Route protection
βββ .env.example # Environment template
- User: Customer accounts with role-based access
- Product: Product catalog with variants, images, and tags
- Category: Hierarchical category structure
- Order: Order management with status tracking
- OrderItem: Individual items in orders
- Cart: Shopping cart items
- Wishlist: Saved items
- Review: Product reviews and ratings
- Address: Shipping and billing addresses
- Products belong to categories
- Products have multiple images and variants
- Users have addresses, orders, cart items, and reviews
- Orders contain order items linked to products
See prisma/schema.prisma for the complete schema.
- Credentials: Email and password
- Google OAuth: Sign in with Google
- GitHub OAuth: Sign in with GitHub
CUSTOMER: Standard user (default)ADMIN: Can manage products and ordersSUPER_ADMIN: Full system access
/profile/*- User profile pages/orders/*- Order history/checkout- Checkout process/admin/*- Admin dashboard (Admin only)
GET /api/products // List products (with filters)
GET /api/products/[slug] // Get product details
POST /api/products // Create product (Admin)
PUT /api/products/[slug] // Update product (Admin)
DELETE /api/products/[slug] // Delete product (Admin)GET /api/cart // Get cart items
POST /api/cart // Add to cart
PATCH /api/cart // Update quantity
DELETE /api/cart // Remove itemGET /api/orders // List orders
POST /api/orders // Create order (checkout)
GET /api/orders/[id] // Get order details
PATCH /api/orders/[id] // Update order (Admin)POST /api/virtual-tryon // Generate virtual try-on image (multipart/form-data)The project uses Tailwind CSS v4 with custom configuration:
- Colors: Purple primary theme with gray accents
- Fonts: Geist Sans and Geist Mono
- Responsive: Mobile-first breakpoints (sm, md, lg)
- Dark Mode: System preference-based
// Button example
<button className="bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg">
Click Me
</button>
// Card example
<div className="bg-white rounded-lg shadow-sm hover:shadow-md transition-shadow">
{/* Content */}
</div>- Push code to GitHub
- Import project in Vercel
- Add environment variables
- Deploy!
Ensure these are set in your deployment platform:
DATABASE_URL: PostgreSQL connection stringREDIS_URL: Redis connection stringNEXTAUTH_URL: Your production URLNEXTAUTH_SECRET: Production secretOPENAI_API_KEY: OpenAI API key (for Virtual Try-On)- OAuth credentials (if using)
# Production migration
npx prisma migrate deploynpm run dev # Start development server (port 5000)
npm run build # Build for production
npm start # Start production server
npm run db:generate # Generate Prisma Client
npm run db:migrate # Run database migrations
npm run db:seed # Seed database with sample data
npm run db:studio # Open Prisma Studio
npm run db:reset # Reset database- Redis Caching: Products and categories cached for faster loads
- Image Optimization: Next.js Image component with WebP
- Server Components: Reduced JavaScript bundle size
- Code Splitting: Automatic route-based splitting
- Turbopack: Ultra-fast bundling in development
- Password hashing with bcrypt
- JWT-based session management
- CSRF protection
- SQL injection prevention via Prisma
- Input validation with Zod
- Protected API routes
- Environment variable management
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Prisma Client not found:
npx prisma generateDatabase connection failed:
- Check DATABASE_URL format
- Ensure PostgreSQL is running
- Verify credentials
Redis errors:
- Ensure Redis server is running
- Check REDIS_URL format
Build errors:
rm -rf .next node_modules
npm install
npm run buildFor help and questions:
- Open an Issue
- Next.js team for the amazing framework
- Prisma for the excellent ORM
- Vercel for hosting platform
- Tailwind CSS for the utility-first CSS framework
Built with β€οΈ for modern fashion e-commerce