Back to Examples

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
1

Project Setup

Let's start by creating the project structure and setting up the development environment.

Initialize the Project

BASH
# 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-js

AI Prompt for Project Structure

TEXT
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.
2

Database Schema Design

Design the database schema using Prisma ORM with AI assistance.

AI Prompt for Database Schema

TEXT
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.
3

Authentication System

Implement secure user authentication with Next.js API routes and JWT tokens.

AI Prompt for Auth API

TEXT
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.
4

Product Management

Create product catalog with search, filtering, and admin management features.

AI Prompt for Product API

TEXT
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.
5

Shopping Cart

Implement shopping cart functionality with persistent storage and real-time updates.

AI Prompt for Cart Context

TEXT
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.
6

Stripe Payment Integration

Integrate Stripe for secure payment processing with checkout sessions and webhooks.

AI Prompt for Stripe Integration

TEXT
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.
7

Deployment

Deploy your e-commerce platform to production with Vercel and Railway.

AI Prompt for Deployment

TEXT
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

Set up PostgreSQL database on Railway
Configure environment variables
Run database migrations
Deploy backend to Railway
Deploy frontend to Vercel
Configure Stripe webhooks

Congratulations! 🎉

You've built a complete e-commerce platform! This project demonstrates advanced AI-assisted development techniques and real-world application architecture.