E-commerce Platform Tutorial
Build a complete online store with React, Node.js, and Stripe integration using Cursor's AI assistance.
Project Overview
What We'll Build
- Product catalog with search and filtering
- User authentication and profiles
- Secure payment processing with Stripe
- Order management and inventory tracking
Tech Stack
- Frontend: React with TypeScript
- Backend: Node.js with Express
- Database: PostgreSQL with Prisma ORM
- Payments: Stripe API
- Styling: Tailwind CSS
- Deployment: Vercel + Railway
Project Setup
Let's start by creating the project structure and setting up the development environment.
Initialize the Project
# Create project directory
mkdir ecommerce-platform
cd ecommerce-platform
# Initialize package.json
npm init -y
# Install dependencies
npm install react react-dom next typescript @types/react @types/node
npm install tailwindcss postcss autoprefixer
npm install prisma @prisma/client
npm install stripe
npm install @stripe/stripe-jsAI Prompt for Project Structure
Create a Next.js project structure for an e-commerce platform with the following features:
- User authentication (login/register)
- Product catalog with categories
- Shopping cart functionality
- Checkout process with Stripe
- Admin dashboard for product management
- Order history and tracking
Please create the folder structure and initial configuration files. Use TypeScript and Tailwind CSS for styling.Database Schema Design
Design the database schema using Prisma ORM with AI assistance.
AI Prompt for Database Schema
Create a Prisma schema for an e-commerce platform with the following entities:
1. User (id, email, password, firstName, lastName, role, createdAt, updatedAt)
2. Product (id, name, description, price, images, categoryId, stock, isActive, createdAt, updatedAt)
3. Category (id, name, description, slug, createdAt, updatedAt)
4. Cart (id, userId, productId, quantity, createdAt, updatedAt)
5. Order (id, userId, total, status, shippingAddress, billingAddress, createdAt, updatedAt)
6. OrderItem (id, orderId, productId, quantity, price, createdAt, updatedAt)
Include proper relationships, indexes, and constraints. Use appropriate data types and add validation rules.Authentication System
Implement secure user authentication with Next.js API routes and JWT tokens.
AI Prompt for Auth API
Create a complete authentication system for a Next.js e-commerce app with:
1. User registration with email validation
2. User login with JWT tokens
3. Password hashing with bcrypt
4. Protected API routes
5. Middleware for route protection
6. Logout functionality
Use Next.js API routes, Prisma for database operations, and include proper error handling and validation.Product Management
Create product catalog with search, filtering, and admin management features.
AI Prompt for Product API
Create a comprehensive product management API for an e-commerce platform with:
1. Get all products with pagination and filtering
2. Search products by name and description
3. Filter by category, price range, and availability
4. Get single product details
5. Admin endpoints for CRUD operations
6. Image upload functionality
7. Inventory management
Include proper validation, error handling, and TypeScript types.Shopping Cart
Implement shopping cart functionality with persistent storage and real-time updates.
AI Prompt for Cart Context
Create a React context for shopping cart management with:
1. Add/remove items from cart
2. Update quantities
3. Calculate totals and taxes
4. Persist cart data in localStorage
5. Sync with backend when user is logged in
6. Clear cart after successful checkout
Include TypeScript types, error handling, and optimistic updates.Stripe Payment Integration
Integrate Stripe for secure payment processing with checkout sessions and webhooks.
AI Prompt for Stripe Integration
Create a complete Stripe payment integration for an e-commerce platform with:
1. Create checkout sessions
2. Handle payment success/failure
3. Process webhooks for payment events
4. Store payment intents in database
5. Handle refunds and disputes
6. Send confirmation emails
Include proper error handling, security measures, and TypeScript types.Deployment
Deploy your e-commerce platform to production with Vercel and Railway.
AI Prompt for Deployment
Create deployment configuration for an e-commerce platform with:
1. Vercel configuration for frontend deployment
2. Railway configuration for backend and database
3. Environment variables setup
4. Database migrations
5. Stripe webhook configuration
6. Domain and SSL setup
Include step-by-step deployment instructions and troubleshooting tips.Deployment Checklist
Congratulations! 🎉
You've built a complete e-commerce platform! This project demonstrates advanced AI-assisted development techniques and real-world application architecture.