A modern e-commerce platform built with Next.js 14, featuring real-time inventory management, secure PayPal payments, and a comprehensive admin dashboard for product and order management.
This application provides a complete e-commerce solution with features like user authentication, shopping cart management, order processing, and inventory tracking. It leverages Next.js server components for optimal performance and Prisma ORM for reliable database operations. The platform includes both customer-facing interfaces for shopping and administrative tools for managing products, orders, and users.
.
├── src/
│ ├── actions/ # Server actions for data operations
│ │ ├── auth/ # Authentication-related actions
│ │ ├── products/ # Product management operations
│ │ └── orders/ # Order processing and management
│ ├── app/ # Next.js application routes and pages
│ │ ├── (shop)/ # Main shop routes (products, cart, checkout)
│ │ ├── admin/ # Admin dashboard routes
│ │ └── auth/ # Authentication pages
│ ├── components/ # Reusable React components
│ ├── interfaces/ # TypeScript type definitions
│ ├── store/ # Client-side state management with Zustand
│ └── utils/ # Utility functions and helpers
├── prisma/ # Prisma schema and migrations
└── public/ # Static assets
- Node.js 18 or later
- PostgreSQL database
- PayPal developer account
- Cloudinary account for image storage
# Clone the repository
git clone <repository-url>
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env.local
# Run database migrations
npx prisma migrate dev
# Seed the database (development only)
npm run seed- Configure environment variables:
DATABASE_URL="postgresql://user:password@localhost:5432/teslo"
NEXTAUTH_SECRET="your-secret"
CLOUDINARY_URL="your-cloudinary-url"
PAYPAL_CLIENT_ID="your-paypal-client-id"
PAYPAL_SECRET="your-paypal-secret"- Start the development server:
npm run dev- Access the application:
- Shop: http://localhost:3000
- Admin: http://localhost:3000/admin
- Managing Products (Admin):
// Create or update a product
const product = await createUpdateProduct(formData);- Processing Orders:
// Place a new order
const order = await placeOrder(productIds, address);- Database Connection Issues
- Error:
Could not connect to database - Solution:
# Verify database connection
npx prisma db push
# Check database URL in .env- Image Upload Failures
- Error:
Failed to upload image to Cloudinary - Solution:
- Verify Cloudinary credentials
- Check image file size (max 10MB)
- Ensure proper image format (JPG, PNG)
The application follows a structured data flow for processing orders and managing inventory.
User -> Cart -> Checkout -> Order Processing -> Payment -> Fulfillment
^ |
| v
Admin Dashboard <- Inventory Management <- Order Management
Key component interactions:
- User adds products to cart (client-side state)
- Checkout process validates inventory and user data
- Order creation triggers inventory updates
- Payment processing through PayPal integration
- Admin dashboard provides real-time order and inventory management
- Product updates trigger cache revalidation
- Authentication guards protect sensitive operations
- PostgreSQL database with Prisma ORM
- Tables:
- User
- Product
- Order
- Category
- ProductImage
- UserAddress
- OrderAddress
- Cloudinary: Image storage and optimization
- PayPal: Payment processing
- PostgreSQL: Database hosting
- Prerequisites:
- Vercel account
- PostgreSQL database
- Environment variables configured
- Deployment Steps:
# Build application
npm run build
# Deploy to Vercel
vercel --prod- Post-deployment:
- Run database migrations
- Verify environment variables
- Test payment integration