Skip to content

A full-stack, modern, and production-ready E-Commerce Web Application built using the latest Next.js 16 framework with React 19, secure authentication, integrated payments, admin dashboard, and a highly customizable UI toolkit.

Notifications You must be signed in to change notification settings

MohammedNaderAlGhussin/E-commerce

Repository files navigation

πŸ›’ Kaufra - Modern Full-Stack E-Commerce Platform

Kaufra is a high-performance full-stack, modern, and production-ready E-Commerce Web Application built using the latest Next.js 16 framework with React 19,It leverages a robust stack including Prisma, PostgreSQL, and Auth.js, secure authentication, integrated payments, admin dashboard, and a highly customizable UI toolkit.

Designed with scalability, developer experience, and real-world e-commerce flows in mind.


πŸ“ Folder Structure

Your project uses the Next.js App Router, structured for clarity between public, protected, and admin spaces.

Kaufra/
β”œβ”€β”€ app/                          # NEXT.JS 16 APP ROUTER
β”‚   β”œβ”€β”€ (auth)/                   # Authentication Group
β”‚   β”‚   β”œβ”€β”€ sign-in/              # Login Page
β”‚   β”‚   └── sign-up/              # Registration Page
β”‚   β”œβ”€β”€ (root)/                   # Main Application Group
β”‚   β”‚   β”œβ”€β”€ cart/                 # Shopping Cart UI
β”‚   β”‚   β”œβ”€β”€ order/                # Order Details & Summary
β”‚   β”‚   β”œβ”€β”€ payment-method/       # Payment Selection logic
β”‚   β”‚   β”œβ”€β”€ product/              # Dynamic [slug] Product Pages
β”‚   β”‚   β”œβ”€β”€ shipping-address/     # Checkout Shipping Step
β”‚   β”‚   └── page.tsx              # Home Page (Featured/New Arrivals)
β”‚   β”œβ”€β”€ admin/                    # PROTECTED ADMIN PANEL
β”‚   β”‚   β”œβ”€β”€ main-nav.tsx          # Dashboard Navigation
β”‚   β”‚   β”œβ”€β”€ orders/               # Order Management (CRUD)
β”‚   β”‚   β”œβ”€β”€ products/             # Inventory Management
β”‚   β”‚   β”œβ”€β”€ users/                # User Permissions/Management
β”‚   β”‚   └── overview/             # Recharts Analytics Dashboard
β”‚   β”œβ”€β”€ api/                      # BACKEND API ENDPOINTS
β”‚   β”‚   β”œβ”€β”€ auth/[...nextauth]/   # Auth.js Config
β”‚   β”‚   β”œβ”€β”€ uploadthing/          # Image Upload Handlers
β”‚   β”‚   └── webhooks/             # Stripe/PayPal Webhook Listeners
β”‚   β”œβ”€β”€ user/                     # PROTECTED USER DASHBOARD
β”‚   β”‚   β”œβ”€β”€ profile/              # Account Settings
β”‚   β”‚   └── orders/               # Personal Order History
β”‚   └── layout.tsx                # Global Layout (Navbar/Footer)
β”œβ”€β”€ components/                   # REUSABLE UI SYSTEM
β”‚   β”œβ”€β”€ admin/                    # Admin-specific UI (Product Forms)
β”‚   β”œβ”€β”€ shared/                   # Business Logic Components
β”‚   β”‚   β”œβ”€β”€ header/               # Navbar, Search, User Button
β”‚   β”‚   β”œβ”€β”€ product/              # Product Cards, Lists, Images
β”‚   β”‚   β”œβ”€β”€ checkout/             # Checkout Progress Stepper
β”‚   β”‚   └── cart/                 # Cart Table and Sidebars
β”‚   β”œβ”€β”€ ui/                       # ShadCN UI Primitives (Button, Input, etc)
β”‚   └── footer.tsx                # Global Footer
β”œβ”€β”€ db/                           # DATABASE LAYER
β”‚   β”œβ”€β”€ prisma.ts                 # Prisma Client Initialization
β”‚   β”œβ”€β”€ schema.prisma             # PostgreSQL Models (Neon)
β”‚   └── seed.ts                   # Sample Data for Testing
β”œβ”€β”€ email/                        # REACT-EMAIL TEMPLATES
β”‚   └── index.tsx                 # Purchase Receipts & Welcome Emails
β”œβ”€β”€ hooks/                        # CUSTOM REACT HOOKS (use-cart, etc)
β”œβ”€β”€ lib/                          # CORE UTILITIES & ACTIONS
β”‚   β”œβ”€β”€ actions/                  # SERVER ACTIONS (No API fetch needed)
β”‚   β”‚   β”œβ”€β”€ product.actions.ts    # CRUD for Products
β”‚   β”‚   β”œβ”€β”€ cart.actions.ts       # Cart Management Logic
β”‚   β”‚   β”œβ”€β”€ order.actions.ts      # Order Processing
β”‚   β”‚   └── user.actions.ts       # Profile & Role Updates
β”‚   β”œβ”€β”€ validators/               # ZOD SCHEMAS (Type-safe validation)
β”‚   β”œβ”€β”€ constants/                # Global Config (App Name, etc)
β”‚   └── utils.ts                  # Tailwind Merge & Formatting
β”œβ”€β”€ public/                       # STATIC ASSETS (Logo, Images)
β”œβ”€β”€ types/                        # GLOBAL TYPES & INTERFACES
β”œβ”€β”€ middleware.ts                 # NEXT AUTH ROUTE PROTECTION
└── tailwind.config.ts            # THEME & DARK MODE CONFIG
  • Public store pages are inside (root) πŸ‘
  • Auth pages live in (auth)πŸ‘
  • Admin section has its dedicated layout, routes & navigation πŸ‘
  • API routes handle auth, uploads, & webhooks server-side πŸ‘

🧩 Main Features

🏬 Storefront

  • Featured products & categories
  • Product detail pages with image gallery & inventory
  • Search & filters
  • Product slug routing (via Slugify)
  • Cart with quantities and dynamic totals
  • Shipping address & payment workflow
  • Fully responsive UX

πŸ” Authentication (NextAuth)

You are using NextAuth with:

  • Credentials Provider (Email + Password)

  • Encrypted passwords via bcrypt

  • Sessions handled using Cookies + JWT

  • Role-based Authorization (Admin/User)

Additional future-ready providers supported in codebase:

  • ⚑ Google OAuth
  • ✨ Magic Link

πŸ‘€ User Dashboard

  • Profile management
  • Order history
  • Saved shipping addresses
  • Saved payment methods (optional)

πŸ§‘β€πŸ’Ό Admin Dashboard

Protected via roles & middleware with capabilities:

  • Manage Orders & Status

  • Manage Products (CRUD)

  • Manage Users & Roles

  • Admin Analytics + Revenue Charts (Recharts)

  • Upload product images via UploadThing

πŸ’³ Payments

Supports multiple payment gateways:

πŸ”Ή PayPal

  • React SDK
  • Token generation
  • Order capture

πŸ”Ή Stripe

  • Server-side Payment Intents
  • Webhooks for verification

βœ‰οΈ Email System

Using React Email + Resend for transactional emails:

  • Order confirmations
  • User authentication flows
  • Future: password reset & email verification

🎨 UI/UX

Built with modern UI tooling:

  • ShadCN UI (Composable components)

  • Tailwind CSS

  • Lucide Icons

  • Embla Carousel (Featured products slider)


πŸŒ— Theming β€” Dark & Light Mode

The platform uses Next Themes to support:

  • System theme sync
  • Smooth toggling
  • SSR-friendly hydration

The UI stays consistent across:

  • Storefront pages
  • Admin dashboard
  • Auth pages

πŸ” Route Protection & Authorization

Authorization uses NextAuth + Middleware enforcing:

Route Type Requirements
Public None
User Protected Valid session
Admin Protected Session AND role = "ADMIN"

Examples:

Path Access
/cart Public
/order User
/admin Admin only

If unauthorized, users are:

  • Redirected to sign-in
  • Or given 403 pages (for admin access)

πŸ—οΈ Tech Stack

Frontend

  • Next.js 16 (App Router)
  • React 19
  • TypeScript
  • Tailwind CSS
  • ShadCN UI
  • Embla Carousel
  • Lucide Icons
  • Next Themes (dark/light mode)

Backend

  • Next.js Server Actions
  • Route Handlers (app/api)
  • NextAuth (Credentials Provider)
  • Cookies + JWT Sessions
  • Zod Validation
  • Prisma ORM

Database

  • PostgreSQL via Vercel (Neon)
  • Prisma migrations & seeders

Payments

  • PayPal React SDK
  • Stripe Checkout & Webhooks
  • cash on delivery COD

Storage

  • UploadThing (Product images)

Email

  • Resend
  • React Email Templates

πŸ—„οΈ Database & Schema

Managed via Prisma, featuring models such as:

  • User (with role field)
  • Product
  • Category
  • Order
  • OrderItem
  • Payment
  • Address

Supports migrations & seeding for development.


🧰 Developer Experience

  • TypeScript-first codebase

  • Prisma type-safety to DB layer

  • Zod validation on inputs

  • ESLint formatting & linting

  • RHF for form management

  • Strict mode compliant


πŸ› οΈ Environment Variables

Standard .env example:

DATABASE_URL=
NEXTAUTH_SECRET=
NEXTAUTH_URL=
PAYPAL_CLIENT_ID=
PAYPAL_SECRET=
STRIPE_SECRET_KEY=
STRIPE_WEBHOOK_SECRET=
RESEND_API_KEY=
UPLOADTHING_SECRET=

πŸš€ Achievements

This project successfully demonstrates:

  • Full-stack ecommerce architecture

  • Real authentication & authorization

  • Modern SSR/ISR patterns via Next.js 16

  • Admin dashboard with real CRUD flows

  • Stripe + PayPal payment integration

  • Dark/Light theme capabilities

  • Transactional email system

  • Cloud Postgres setup via Vercel/Neon

  • Type-safe development environment


⚠️ Challenges & Insights

While building this platform, notable challenges included:

πŸ” Credential Flow with NextAuth

  • Balancing cookie sessions + JWT-based flows required thoughtful config.

πŸ—ƒοΈ Database Modeling

  • Handling order β†’ items β†’ payments relationships required multi-step transactions.

πŸ’° Payment Webhooks

  • Stripe webhook handling had to respect edge/server limitations.

πŸ“¦ File Uploads

  • UploadThing + server actions coordination took careful setup.

πŸ’… Admin UX

  • Creating reusable admin UI patterns while remaining flexible.

Each challenge contributed to a more polished and production-ready result.


About

A full-stack, modern, and production-ready E-Commerce Web Application built using the latest Next.js 16 framework with React 19, secure authentication, integrated payments, admin dashboard, and a highly customizable UI toolkit.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published