Skip to content

YASHDEV42/YASHSTORE

Repository files navigation

πŸ”Έ YASHSTORE

YASHSTORE is a full-stack modern e-commerce platform built with Next.js App Router, Prisma, PostgreSQL, NextAuth, and Stripe.
It provides a complete shopping flow: authentication, product catalog, cart, checkout, order creation, and an admin dashboard for store management.

🌐 Live Demo


πŸ“ Project Structure

YASHSTORE/
β”‚
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ (auth)/                 β†’ Login/Register pages
β”‚   β”œβ”€β”€ (pages)/                β†’ Storefront pages (products, cart, checkout, orders)
β”‚   β”œβ”€β”€ (admin)/dashboard/      β†’ Admin panel (products, categories, users, orders)
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ auth/[...nextauth]/ β†’ NextAuth handlers
β”‚   β”‚   β”œβ”€β”€ create-payment-intent/
β”‚   β”‚   └── webhook/            β†’ Stripe webhook event handling
β”‚   β”œβ”€β”€ payment-success/        β†’ Payment confirmation page
β”‚   β”œβ”€β”€ layout.tsx              β†’ Global layout + analytics + navbar
β”‚   └── globals.css             β†’ Global Tailwind styles/utilities
β”‚
β”œβ”€β”€ actions/                    β†’ Server Actions (auth, products, cart, order status)
β”œβ”€β”€ components/                 β†’ Reusable UI components (store + admin)
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ db.ts                   β†’ Prisma client singleton
β”‚   └── utils.ts                β†’ Utility helpers
β”œβ”€β”€ prisma/
β”‚   β”œβ”€β”€ schema.prisma           β†’ DB models (User, Product, Cart, Order, etc.)
β”‚   └── migrations/
β”œβ”€β”€ auth.ts                     β†’ NextAuth v5 config (Credentials + Google)
β”œβ”€β”€ middleware.ts               β†’ Middleware entry (currently empty)
β”œβ”€β”€ next.config.mjs             β†’ Next.js config + image domains
└── tailwind.config.ts          β†’ Tailwind theme and custom animations

πŸš€ Tech Stack

Core

Data & Auth

Payments

  • Payment Processor: Stripe
    • Payment intents from API route
    • Webhook verification and order creation

UI/UX & Utilities


🧩 Core Features

πŸ‘€ Authentication & Authorization

  • Register with name, email, phone, and password
  • Login with credentials
  • Google sign-in support
  • Session-based auth via NextAuth
  • Role-aware UI/route behavior for ADMIN and USER

πŸ›οΈ Storefront

  • Home page with hero and new products section
  • Product listing with:
    • Search by name
    • Category filters (mobile + desktop variants)
  • Product detail page with image carousel
  • Add/remove items from cart

πŸ’³ Checkout & Orders

  • Stripe Payment Element checkout flow
  • Server-side payment intent creation
  • Stripe webhook handling for successful payments
  • Automatic order creation and cart cleanup after payment
  • User order history and single-order detail page

πŸ› οΈ Admin Dashboard

  • Dashboard overview (users, products, orders, categories)
  • Product management:
    • Create product
    • Edit product
    • Delete product
  • Category management with category detail view
  • User listing and search
  • Order listing/search and per-order status update

πŸ—ƒοΈ Database Models (Prisma)

Main entities:

  • User
  • Product
  • Category
  • Cart
  • Order
  • Wishlist
  • Review

Also includes enums:

  • Role: ADMIN, USER
  • Status: PENDING, PROCESSING, DELIVERING, SHIPPED, COMPLETED, CANCELLED, REFUNDED

πŸ“¦ API Endpoints

Auth

Method Endpoint Description
GET /api/auth/[...nextauth] NextAuth route handler
POST /api/auth/[...nextauth] NextAuth route handler

Payments

Method Endpoint Description
POST /api/create-payment-intent Creates Stripe PaymentIntent and returns secret
POST /api/webhook Handles Stripe webhook events

βš™οΈ Environment Variables

Create a .env (or .env.local) file in the project root.

# Prisma / PostgreSQL
POSTGRES_PRISMA_URL="postgresql://..."
POSTGRES_URL_NON_POOLING="postgresql://..."

# NextAuth (Google)
clientId="your_google_client_id"
clientSecret="your_google_client_secret"

# Stripe
NEXT_PUBLIC_STRIPE_PUBLIC_KEY="pk_test_..."
STRIPE_SECRET_KEY="sk_test_..."
STRIPE_WEBHOOK_SECRET="whsec_..."

Note: Variable names clientId and clientSecret are used as-is in the current code.


πŸ› οΈ Getting Started

Prerequisites

  • Node.js 18+
  • npm
  • PostgreSQL database
  • Stripe account (test mode is fine)

Installation

  1. Clone the repository

    git clone <your-repo-url>
    cd YASHSTORE
  2. Install dependencies

    npm install
  3. Configure environment variables

    • Create .env or .env.local
    • Add all required variables from the section above
  4. Run Prisma migration and generate client

    npx prisma migrate dev
    npx prisma generate
  5. Start development server

    npm run dev
  6. Open app


πŸ“œ Scripts

npm run dev        # Start development server
npm run build      # Production build
npm start          # Start production server
npm run lint       # Run Next.js linting

☁️ Deployment

Recommended stack:

  • App: Vercel
  • Database: Neon / Supabase / Railway PostgreSQL
  • Payments: Stripe

Deployment checklist:

  1. Add all environment variables in hosting provider
  2. Run Prisma migrations in production database
  3. Configure Stripe webhook endpoint to:
    • https://your-domain.com/api/webhook
  4. Verify Google OAuth callback URL setup in Google Cloud Console

πŸ”’ Security Notes

  • Passwords are hashed with bcryptjs
  • Stripe webhook signature is verified before processing
  • Admin routes are protected by role checks in dashboard layout
  • Session tokens include user role for authorization decisions

πŸ“ˆ Future Improvements

  • Add unit/integration tests
  • Complete middleware-based route protection
  • Add inventory/stock management
  • Improve checkout address handling
  • Add wishlist/reviews UI (models already exist)

πŸ§‘β€πŸ’» Author

Built by YASHDEV42.


YASHSTORE β€” a modern full-stack e-commerce experience. ✨

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors