Home
Softono
shofy-commerce-app-yt

shofy-commerce-app-yt

Open source TypeScript
19
Stars
11
Forks
0
Issues
0
Watchers
8 months
Last Commit

About shofy-commerce-app-yt

Modern full-stack eCommerce platform built with Next.js 15, TypeScript, Firebase & NextAuth.js. Features admin dashboard, role-based auth & responsive design.

Platforms

Web Self-hosted

Languages

TypeScript

πŸ›οΈ Shofy - Modern eCommerce Platform

Shofy eCommerce Platform

A modern, full-stack eCommerce application built with Next.js 15, TypeScript, Firebase, and NextAuth.js. Featuring a comprehensive admin dashboard, role-based authentication, and a responsive design.

Next.js TypeScript Firebase Tailwind CSS NextAuth

πŸš€ Quick Start

🌟 View Youtube Video for setup

Get your eCommerce store running in minutes:

# 1. Clone the repository
git clone https://github.com/noorjsdivs/shofy-commerce-app-yt.git
cd shofy-commerce-app-yt

# 2. Install dependencies
npm install

# 3. Set up environment variables (see setup guide below)
cp .env.example .env.local
# Fill in your credentials

# 4. Start development server
npm run dev

# 5. Open your browser
# Visit: http://localhost:3000

🌟 Live Demo

  • Frontend: Live Demo Link (if available)
  • Admin Dashboard: Available after completing setup (Premium Feature)

✨ Features

οΏ½ eCommerce Core

  • Product Catalog: Browse products with categories, search, and filtering
  • Shopping Cart: Add/remove items, quantity management, persistent cart
  • Checkout Process: Secure payment integration with Stripe
  • Order Management: Track orders, order history, and status updates
  • Wishlist/Favorites: Save products for later purchase
  • User Profiles: Manage personal information, addresses, and preferences

πŸ” Authentication & Authorization

  • Multi-Provider Auth: Google, GitHub, and Email/Password via NextAuth.js
  • Role-Based Access Control (RBAC):
    • User: Standard shopping experience
    • Admin: Full system access and management
    • Accountant: Financial data access
    • Delivery: Order fulfillment management
    • Packer: Warehouse and packing operations
  • Session Management: Secure session handling with automatic sync
  • Profile Management: Edit profiles, upload avatars, change passwords

οΏ½ Admin Dashboard

  • Analytics & Insights: Revenue tracking, user analytics, sales charts
  • User Management: View, edit, delete users with bulk operations
  • Order Management: Process orders, update status, bulk operations
  • Product Management: Add, edit, delete products and categories
  • Role Assignment: Assign and manage user roles
  • System Statistics: Real-time dashboard with key metrics

🎨 Design & UX

  • Responsive Design: Mobile-first approach, works on all devices
  • Modern UI: Clean, professional design with smooth animations
  • Dark/Light Mode: Theme switching capabilities
  • Multi-Currency: Support for different currencies with conversion
  • Multi-Language: Internationalization ready
  • Loading States: Skeleton loaders and smooth transitions
  • Toast Notifications: Real-time feedback for user actions

πŸ› οΈ Technical Features

  • Server-Side Rendering (SSR): Fast initial page loads
  • Static Site Generation (SSG): Optimized performance for static content
  • API Routes: RESTful API endpoints for all operations
  • Database: Firebase Firestore for real-time data
  • File Storage: Firebase Storage for images and files
  • State Management: Redux Toolkit with persistence
  • Form Handling: Advanced form validation and error handling
  • SEO Optimized: Meta tags, sitemap generation, and structured data
  • Performance: Code splitting, lazy loading, and optimization

πŸ“± Pages & Routes

Public Pages

  • Home: Featured products, categories, and promotional banners
  • Products: Product listing with search, filters, and pagination
  • Product Details: Detailed product view with images and specifications
  • Categories: Browse products by category
  • About: Company information and mission
  • Contact: Contact form and company details
  • FAQs: Frequently asked questions with search
  • Inquiry: Customer inquiry form

User Pages

  • Account Dashboard: Personal overview and quick actions
  • Profile: Edit personal information and upload avatar
  • Orders: Order history and tracking
  • Order Details: Detailed order information
  • Addresses: Manage shipping and billing addresses
  • Settings: Account preferences and notifications
  • Cart: Shopping cart management
  • Checkout: Secure payment process
  • Favorites: Saved products and wishlist

Admin Pages

  • Admin Dashboard: System overview and analytics
  • User Management: Comprehensive user administration
  • Order Management: Order processing and fulfillment
  • Analytics: Detailed business insights and reports

Role-Specific Dashboards

  • Accountant Dashboard: Financial reports and revenue tracking
  • Delivery Dashboard: Order delivery and logistics
  • Packer Dashboard: Warehouse and packing operations
  • User Dashboard: Standard user experience

πŸ—οΈ Tech Stack

Frontend

  • Next.js 15.4.6 - React framework with App Router
  • TypeScript - Type-safe development
  • Tailwind CSS - Utility-first CSS framework
  • Framer Motion - Smooth animations and transitions
  • React Icons - Comprehensive icon library
  • React Hot Toast - Beautiful notifications

Backend & Authentication

  • NextAuth.js 5.0 - Complete authentication solution
  • Firebase Firestore - NoSQL real-time database
  • Firebase Storage - File and image storage
  • Firebase Admin - Server-side operations
  • bcryptjs - Password hashing

State Management

  • Redux Toolkit - Predictable state management
  • Redux Persist - State persistence across sessions
  • React Redux - React bindings for Redux

Development & Build Tools

  • ESLint - Code linting and quality
  • TypeScript - Static type checking
  • PostCSS - CSS processing
  • Next Sitemap - Automatic sitemap generation
  • Wrangler - Cloudflare deployment (optional)

πŸ“ Project Structure

shofy-commerce-app-yt/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                           # Next.js 15 App Router
β”‚   β”‚   β”œβ”€β”€ (public)/                 # Public routes (no authentication required)
β”‚   β”‚   β”‚   β”œβ”€β”€ about/                # About page
β”‚   β”‚   β”‚   β”œβ”€β”€ contact/              # Contact page
β”‚   β”‚   β”‚   β”œβ”€β”€ faqs/                 # FAQ page
β”‚   β”‚   β”‚   └── inquiry/              # Customer inquiry
β”‚   β”‚   β”œβ”€β”€ (user)/                   # Protected user routes
β”‚   β”‚   β”‚   β”œβ”€β”€ account/              # User account management
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ admin/            # Admin dashboard (Premium)
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ addresses/        # Address management
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ notifications/    # User notifications
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ orders/           # Order history
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ payment/          # Payment methods
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ profile/          # User profile
β”‚   β”‚   β”‚   β”‚   └── settings/         # Account settings
β”‚   β”‚   β”‚   β”œβ”€β”€ cart/                 # Shopping cart
β”‚   β”‚   β”‚   β”œβ”€β”€ categories/           # Product categories
β”‚   β”‚   β”‚   β”œβ”€β”€ checkout/             # Checkout process
β”‚   β”‚   β”‚   β”œβ”€β”€ favorite/             # Wishlist/Favorites
β”‚   β”‚   β”‚   β”œβ”€β”€ offers/               # Special offers
β”‚   β”‚   β”‚   └── products/             # Product pages
β”‚   β”‚   β”œβ”€β”€ api/                      # API routes
β”‚   β”‚   β”‚   β”œβ”€β”€ admin/                # Admin API endpoints
β”‚   β”‚   β”‚   └── auth/                 # Authentication API
β”‚   β”‚   β”œβ”€β”€ auth/                     # Authentication pages
β”‚   β”‚   β”œβ”€β”€ dashboard/                # Role-based dashboards
β”‚   β”‚   β”œβ”€β”€ delivery/                 # Public delivery info
β”‚   β”‚   β”œβ”€β”€ delivery-dashboard/       # Delivery staff dashboard
β”‚   β”‚   β”œβ”€β”€ packer-dashboard/         # Packer staff dashboard
β”‚   β”‚   β”œβ”€β”€ unauthorized/             # Unauthorized access page
β”‚   β”‚   β”œβ”€β”€ user-dashboard/           # User dashboard
β”‚   β”‚   β”œβ”€β”€ globals.css               # Global styles
β”‚   β”‚   └── layout.tsx                # Root layout
β”‚   β”œβ”€β”€ components/                   # Reusable React components
β”‚   β”‚   β”œβ”€β”€ account/                  # Account-related components
β”‚   β”‚   β”œβ”€β”€ admin/                    # Admin dashboard components
β”‚   β”‚   β”œβ”€β”€ auth/                     # Authentication components
β”‚   β”‚   β”œβ”€β”€ cart/                     # Shopping cart components
β”‚   β”‚   β”œβ”€β”€ dashboard/                # Dashboard components
β”‚   β”‚   β”œβ”€β”€ header/                   # Header and navigation
β”‚   β”‚   β”œβ”€β”€ layout/                   # Layout components
β”‚   β”‚   β”œβ”€β”€ notifications/            # Notification components
β”‚   β”‚   β”œβ”€β”€ pages/                    # Page-specific components
β”‚   β”‚   β”œβ”€β”€ products/                 # Product-related components
β”‚   β”‚   β”œβ”€β”€ ui/                       # UI components (buttons, cards, etc.)
β”‚   β”‚   └── [Various Components]      # Core app components
β”‚   β”œβ”€β”€ assets/                       # Static assets (images, fonts)
β”‚   β”œβ”€β”€ contexts/                     # React Context providers
β”‚   β”œβ”€β”€ hooks/                        # Custom React hooks
β”‚   β”œβ”€β”€ lib/                          # Utility libraries
β”‚   β”‚   β”œβ”€β”€ auth/                     # Authentication utilities
β”‚   β”‚   β”œβ”€β”€ firebase/                 # Firebase configuration
β”‚   β”‚   └── rbac/                     # Role-based access control
β”‚   β”œβ”€β”€ redux/                        # Redux state management
β”‚   β”œβ”€β”€ types/                        # TypeScript type definitions
β”‚   └── constants/                    # Application constants
β”œβ”€β”€ public/                           # Static public assets
β”‚   β”œβ”€β”€ thumbnail.png                 # Project preview image
β”‚   β”œβ”€β”€ logo.png                      # App logo
β”‚   β”œβ”€β”€ robots.txt                    # SEO robots file
β”‚   └── [Other Assets]                # Images, icons, etc.
β”œβ”€β”€ middleware.ts                     # Route protection middleware
β”œβ”€β”€ auth.ts                          # NextAuth configuration
β”œβ”€β”€ config.ts                        # App configuration
β”œβ”€β”€ firebase.ts                      # Firebase client config
β”œβ”€β”€ type.ts                          # Global type definitions
β”œβ”€β”€ next.config.mjs                  # Next.js configuration
β”œβ”€β”€ tailwind.config.ts               # Tailwind CSS config
β”œβ”€β”€ tsconfig.json                    # TypeScript configuration
└── package.json                     # Dependencies and scripts

πŸš€ Complete Setup Guide

Prerequisites

Before you begin, make sure you have:

  • Node.js 18+ and npm installed
  • Git for cloning the repository
  • A Firebase account (free tier available)
  • A Google Cloud Console account (for OAuth)
  • A GitHub account (for OAuth - optional)

Step-by-Step Installation

1. Clone the Repository

git clone https://github.com/noorjsdivs/shofy-commerce-app-yt.git
cd shofy-commerce-app-yt

2. Install Dependencies

npm install

3. Environment Setup

Create a .env.local file in the root directory:

touch .env.local

Add the following environment variables (see detailed setup below):

# NextAuth Configuration
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-secret-key-here

# Google OAuth (Required)
AUTH_GOOGLE_ID=your-google-client-id
AUTH_GOOGLE_SECRET=your-google-client-secret

# GitHub OAuth (Optional)
AUTH_GITHUB_ID=your-github-client-id
AUTH_GITHUB_SECRET=your-github-client-secret

# Firebase Configuration
NEXT_PUBLIC_FIREBASE_API_KEY=your-api-key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your-project-id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your-sender-id
NEXT_PUBLIC_FIREBASE_APP_ID=your-app-id

# Firebase Admin SDK
FIREBASE_PROJECT_ID=your-project-id
FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYour-Private-Key-Here\n-----END PRIVATE KEY-----\n"
FIREBASE_CLIENT_EMAIL=your-service-account@your-project.iam.gserviceaccount.com

4. Start Development Server

npm run dev

5. Open Your Browser

Navigate to http://localhost:3000


πŸ”‘ Environment Credentials Setup

πŸ”₯ Firebase Setup (Required)

Step 1: Create Firebase Project

  1. Go to Firebase Console
  2. Click "Create a project"
  3. Enter project name (e.g., shofy-ecommerce)
  4. Enable Google Analytics (optional)
  5. Click "Create project"

Step 2: Get Client Configuration

  1. In Firebase Console, click βš™οΈ Project Settings
  2. Scroll to "Your apps" section
  3. Click "Add app" β†’ "Web" (</> icon)
  4. Register app with nickname (e.g., Shofy Web)
  5. Copy the config values:
// Firebase Config Object
const firebaseConfig = {
  apiKey: "AIzaSyC...", // β†’ NEXT_PUBLIC_FIREBASE_API_KEY
  authDomain: "project.firebaseapp.com", // β†’ NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN
  projectId: "your-project-id", // β†’ NEXT_PUBLIC_FIREBASE_PROJECT_ID
  storageBucket: "project.appspot.com", // β†’ NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET
  messagingSenderId: "123456789", // β†’ NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID
  appId: "1:123:web:abc123", // β†’ NEXT_PUBLIC_FIREBASE_APP_ID
};

Step 3: Setup Firestore Database

  1. In Firebase Console, go to "Firestore Database"
  2. Click "Create database"
  3. Choose "Start in test mode" (for development)
  4. Select your preferred location
  5. Click "Enable"

Step 4: Setup Firebase Storage

  1. Go to "Storage" in Firebase Console
  2. Click "Get started"
  3. Choose "Start in test mode"
  4. Select the same location as Firestore
  5. Click "Done"

Step 5: Get Admin SDK Credentials

  1. Go to Project Settings β†’ "Service accounts" tab
  2. Click "Generate new private key"
  3. Download the JSON file
  4. Extract these values for your .env.local:
    • project_id β†’ FIREBASE_PROJECT_ID
    • private_key β†’ FIREBASE_PRIVATE_KEY (keep \n characters)
    • client_email β†’ FIREBASE_CLIENT_EMAIL

πŸ” Google OAuth Setup (Required)

Step 1: Google Cloud Console

  1. Go to Google Cloud Console
  2. Create new project or select existing Firebase project
  3. Enable the project if prompted

Step 2: Configure OAuth Consent Screen

  1. Go to "APIs & Services" β†’ "OAuth consent screen"
  2. Choose "External" β†’ Click "Create"
  3. Fill in required fields:
    • App name: Shofy eCommerce
    • User support email: your email
    • Developer contact: your email
  4. Click "Save and Continue" through all steps

Step 3: Create OAuth Credentials

  1. Go to "APIs & Services" β†’ "Credentials"
  2. Click "+ CREATE CREDENTIALS" β†’ "OAuth 2.0 Client IDs"
  3. Application type: "Web application"
  4. Name: Shofy Web Client
  5. Add Authorized redirect URIs:
    http://localhost:3000/api/auth/callback/google
    https://yourdomain.com/api/auth/callback/google
  6. Click "Create"
  7. Copy the Client ID and Client Secret:
    • Client ID β†’ AUTH_GOOGLE_ID
    • Client Secret β†’ AUTH_GOOGLE_SECRET

πŸ™ GitHub OAuth Setup (Optional)

Step 1: Create GitHub OAuth App

  1. Go to GitHub Developer Settings
  2. Click "New OAuth App"
  3. Fill in the form:
    • Application name: Shofy eCommerce
    • Homepage URL: http://localhost:3000
    • Authorization callback URL: http://localhost:3000/api/auth/callback/github
  4. Click "Register application"

Step 2: Get Credentials

  1. Copy Client ID β†’ AUTH_GITHUB_ID
  2. Click "Generate a new client secret"
  3. Copy Client Secret β†’ AUTH_GITHUB_SECRET

πŸ”’ NextAuth Secret Generation

Generate a secure secret for session encryption:

# Using Node.js
node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"

# Or using OpenSSL
openssl rand -base64 32

Copy the generated string to NEXTAUTH_SECRET

βœ… Verify Setup

After adding all environment variables:

  1. Restart your development server:

    npm run dev
  2. Test authentication:

    • Visit http://localhost:3000
    • Click "Sign In"
    • Try Google OAuth login
    • Check if user data appears in Firebase Console

πŸ“‹ Available Scripts

# Development
npm run dev          # Start development server on http://localhost:3000
npm run build        # Build optimized production bundle
npm run start        # Start production server (after build)
npm run lint         # Run ESLint for code quality
npm run type-check   # Run TypeScript type checking

# Utilities
npm run postbuild    # Generate sitemap after build
npm run deploy:check # Run deployment checks
npm run deploy:cf    # Deploy to Cloudflare Pages (if configured)

Development Workflow

  1. Start Development: npm run dev
  2. Check Code Quality: npm run lint
  3. Type Safety: npm run type-check
  4. Build for Production: npm run build
  5. Test Production: npm run start

οΏ½ Admin Access Setup

Method 1: Email-Based Admin (Recommended)

Set admin email in your authentication logic:

  1. Register with your admin email
  2. Check AccountLayout.tsx - admin access is granted to:

Method 2: Role-Based Admin

  1. Register a new account
  2. Go to Firebase Console β†’ Firestore Database
  3. Find your user document in the users collection
  4. Add a field: role: "admin"
  5. Save and refresh your application

Admin Features

  • 🎯 Premium Feature: Full admin dashboard is available in the premium version
  • πŸ“Š Dashboard: Basic dashboard with upgrade prompt
  • πŸ”— Upgrade Link: Direct link to purchase premium features
  • βš™οΈ Settings: Standard account management

Admin URL: http://localhost:3000/account/admin

🌟 Key Features Highlights

Advanced Authentication

  • Multiple OAuth providers
  • Role-based dashboard routing
  • Session synchronization
  • Secure middleware protection

Comprehensive Admin Panel

  • Real-time analytics
  • Bulk operations for users and orders
  • Advanced filtering and search
  • Export capabilities

Enhanced UX

  • Skeleton loading states
  • Optimistic UI updates
  • Real-time notifications
  • Responsive design patterns

Performance Optimizations

  • Image optimization with Next.js
  • Code splitting and lazy loading
  • Static generation where possible
  • Efficient state management

🎨 Customization Guide

Branding & Styling

  1. Colors: Update tailwind.config.ts for brand colors
  2. Logo: Replace files in /public/ and /src/assets/
  3. Fonts: Modify /src/fonts/ directory
  4. Theme: Customize CSS variables in globals.css

Content Customization

  1. Homepage: Edit components in /src/components/pages/home/
  2. Navigation: Update /src/components/header/
  3. Footer: Modify /src/components/Footer.tsx
  4. Static Pages: Edit files in /src/app/(public)/

Feature Extensions

  1. Payment Integration: Add Stripe/PayPal in /src/lib/
  2. Email Service: Integrate with SendGrid, Mailgun, etc.
  3. Analytics: Add Google Analytics, Mixpanel, etc.
  4. Search: Implement Algolia, Elasticsearch, etc.

API Customization

  1. Endpoints: Modify /src/app/api/ routes
  2. Database: Extend Firestore collections
  3. Authentication: Add custom providers in auth.ts
  4. Middleware: Update /middleware.ts for custom logic

οΏ½ Deployment

Vercel (Recommended)

Deploy with Vercel

  1. Push to GitHub:

    git add .
    git commit -m "Initial commit"
    git push origin main
  2. Deploy to Vercel:

    • Go to Vercel Dashboard
    • Click "New Project"
    • Import your GitHub repository
    • Add environment variables
    • Deploy
  3. Update Environment:

    • Set NEXTAUTH_URL to your Vercel domain
    • Update OAuth redirect URIs

Other Platforms

  • Netlify: Connect GitHub and deploy
  • Railway: One-click deployment
  • Digital Ocean: App Platform
  • AWS: Amplify Hosting

Environment Variables for Production

Remember to update these in production:

NEXTAUTH_URL=https://your-domain.com
# Update OAuth redirect URIs in Google/GitHub console
# Use production Firebase project

οΏ½πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ“ž Support & Help

Getting Help

  1. πŸ“– Documentation: This README covers everything you need
  2. πŸ› Issues: Open a GitHub Issue
  3. πŸ’¬ Discussions: GitHub Discussions
  4. πŸ“§ Email: [email protected]

Premium Support

  • 🎯 Admin Dashboard: Buy Premium Version
  • πŸ› οΈ Custom Development: Available for hire
  • πŸ“š Training: One-on-one setup assistance
  • πŸ”§ Maintenance: Ongoing support packages

Community

  • ⭐ Star this repo if you find it helpful
  • 🍴 Fork & contribute improvements
  • πŸ“’ Share with other developers

πŸ™ Acknowledgments

  • Next.js Team - Amazing React framework
  • Firebase Team - Reliable backend services
  • Tailwind CSS - Beautiful utility-first CSS
  • NextAuth.js - Secure authentication
  • Vercel - Seamless deployment platform
  • Open Source Community - Inspiration and tools

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

⭐ Star this repository if it helped you!

Built with ❀️ by Noor Mohammad for the developer community

🎨 Modern UI/UX

  • Responsive Design (Mobile-first approach)
  • Professional Animations with Framer Motion
  • Loading Skeletons for better UX
  • Toast Notifications for user feedback
  • Dynamic Navigation with mobile optimization
  • Professional Color Scheme with consistent branding

πŸ“± Mobile Experience

  • Mobile Navigation with hamburger menu
  • Touch-Friendly interface
  • Optimized Performance for mobile devices
  • Progressive Web App ready

πŸš€ Getting Started

Prerequisites

  • Node.js 18.0 or later
  • npm or pnpm package manager
  • Firebase Account (for database and authentication)
  • Google Cloud Console account (for Google OAuth)
  • GitHub account (for GitHub OAuth)

Installation

  1. Clone the repository

    git clone https://github.com/noorjsdivs/shofy-commerce-app.git
    cd shofy-commerce-app
  2. Install dependencies

    npm install
    # or
    pnpm install
  3. Set up environment variables (see Environment Setup below)

  4. Run the development server

    npm run dev
    # or
    pnpm dev
  5. Open your browser Navigate to http://localhost:3000

πŸ”§ Environment Setup

Create a .env file in the root directory and add the following variables:

# NextAuth Configuration
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-secret-key-here

# Google OAuth Configuration
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret

# GitHub OAuth Configuration
GITHUB_ID=your-github-client-id
GITHUB_SECRET=your-github-client-secret

# Firebase Client Configuration
NEXT_PUBLIC_FIREBASE_API_KEY=your-firebase-api-key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your-firebase-project-id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your-sender-id
NEXT_PUBLIC_FIREBASE_APP_ID=your-app-id

# Firebase Admin SDK (for server-side operations)
FIREBASE_PROJECT_ID=your-firebase-project-id
FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nYOUR_PRIVATE_KEY_HERE\n-----END PRIVATE KEY-----\n"
FIREBASE_CLIENT_EMAIL=your-service-account@your-project.iam.gserviceaccount.com

# Stripe Configuration (Optional)
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=your-stripe-publishable-key
STRIPE_SECRET_KEY=your-stripe-secret-key

πŸ”‘ How to Obtain Environment Credentials

πŸ”₯ Firebase Setup

  1. Create a Firebase Project

    • Go to Firebase Console
    • Click "Create a project"
    • Enter project name (e.g., "shofy-ecommerce")
    • Enable Google Analytics (optional)
  2. Get Firebase Client Configuration

    • In Firebase Console, click "Add app" β†’ "Web"
    • Register your app with a nickname
    • Copy the configuration object values:
      const firebaseConfig = {
        apiKey: "your-api-key", // β†’ NEXT_PUBLIC_FIREBASE_API_KEY
        authDomain: "your-project.firebaseapp.com", // β†’ NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN
        projectId: "your-project-id", // β†’ NEXT_PUBLIC_FIREBASE_PROJECT_ID
        storageBucket: "your-project.appspot.com", // β†’ NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET
        messagingSenderId: "123456789", // β†’ NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID
        appId: "your-app-id", // β†’ NEXT_PUBLIC_FIREBASE_APP_ID
      };
  3. Set up Firestore Database

    • Go to "Firestore Database" in Firebase Console
    • Click "Create database"
    • Choose "Start in test mode" (for development)
    • Select a location
  4. Get Firebase Admin SDK

    • Go to Project Settings β†’ Service Accounts
    • Click "Generate new private key"
    • Download the JSON file
    • Extract values:
      • project_id β†’ FIREBASE_PROJECT_ID
      • private_key β†’ FIREBASE_PRIVATE_KEY (keep the newlines as \n)
      • client_email β†’ FIREBASE_CLIENT_EMAIL

πŸ” Google OAuth Setup

  1. Go to Google Cloud Console

  2. Enable Google+ API

    • Go to "APIs & Services" β†’ "Library"
    • Search for "Google+ API" and enable it
  3. Create OAuth 2.0 Credentials

    • Go to "APIs & Services" β†’ "Credentials"
    • Click "Create Credentials" β†’ "OAuth 2.0 Client IDs"
    • Choose "Web application"
    • Add authorized redirect URIs:
      • http://localhost:3000/api/auth/callback/google (development)
      • https://yourdomain.com/api/auth/callback/google (production)
    • Copy the Client ID and Client Secret

πŸ™ GitHub OAuth Setup

  1. Go to GitHub Developer Settings

  2. Configure OAuth App

    • Application name: Shofy E-Commerce
    • Homepage URL: http://localhost:3000 (development)
    • Authorization callback URL: http://localhost:3000/api/auth/callback/github
    • Click "Register application"
  3. Get Credentials

    • Copy the Client ID β†’ GITHUB_ID
    • Generate a new client secret β†’ GITHUB_SECRET

πŸ”’ NextAuth Secret

Generate a secure secret for NextAuth:

# Using openssl
openssl rand -base64 32

# Using Node.js
node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"

Copy the generated string to NEXTAUTH_SECRET

πŸ’³ Stripe Setup (Optional)

  1. Create Stripe Account

  2. Get API Keys

    • Go to "Developers" β†’ "API keys"
    • Copy "Publishable key" β†’ NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
    • Copy "Secret key" β†’ STRIPE_SECRET_KEY

πŸ“ Project Structure

shofy-commerce-app/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                    # Next.js 13+ App Router
β”‚   β”‚   β”œβ”€β”€ auth/              # Authentication pages
β”‚   β”‚   β”‚   β”œβ”€β”€ signin/        # Sign in page
β”‚   β”‚   β”‚   └── register/      # Registration page
β”‚   β”‚   β”œβ”€β”€ api/               # API routes
β”‚   β”‚   β”‚   └── auth/          # Authentication API
β”‚   β”‚   β”œβ”€β”€ cart/              # Shopping cart page
β”‚   β”‚   β”œβ”€β”€ offers/            # Special offers page
β”‚   β”‚   β”œβ”€β”€ products/          # Product pages
β”‚   β”‚   └── profile/           # User profile page
β”‚   β”œβ”€β”€ components/            # Reusable components
β”‚   β”‚   β”œβ”€β”€ auth/              # Authentication components
β”‚   β”‚   β”œβ”€β”€ cart/              # Cart components
β”‚   β”‚   β”œβ”€β”€ header/            # Header components
β”‚   β”‚   β”œβ”€β”€ pages/             # Page-specific components
β”‚   β”‚   └── ui/                # UI components
β”‚   β”œβ”€β”€ lib/                   # Utility libraries
β”‚   β”‚   β”œβ”€β”€ auth/              # Authentication configuration
β”‚   β”‚   └── firebase/          # Firebase configuration
β”‚   β”œβ”€β”€ redux/                 # State management
β”‚   β”œβ”€β”€ constants/             # Application constants
β”‚   └── assets/                # Static assets
β”œβ”€β”€ public/                    # Public assets
β”œβ”€β”€ .env                       # Environment variables
└── package.json               # Dependencies and scripts

πŸ› οΈ Technologies Used

Frontend

  • Next.js 15.4.6 - React framework with App Router
  • TypeScript - Type-safe JavaScript
  • Tailwind CSS - Utility-first CSS framework
  • Framer Motion - Animation library
  • React Icons - Icon library
  • React Hot Toast - Toast notifications

Authentication

  • NextAuth.js - Authentication framework
  • Firebase Auth - Authentication provider
  • bcryptjs - Password hashing

Database

  • Firebase Firestore - NoSQL document database
  • Firebase Storage - File storage

State Management

  • Redux Toolkit - Predictable state container
  • React Redux - React bindings for Redux

Development Tools

  • ESLint - Code linting
  • Prettier - Code formatting
  • TypeScript - Static type checking

🎯 Key Features Explained

πŸ” Authentication Flow

  1. Registration: Users create accounts with email/password or OAuth
  2. Verification: Email verification (optional)
  3. Login: Secure login with session management
  4. Protected Routes: Middleware protects authenticated pages
  5. User Profile: Complete profile management

πŸ›’ Shopping Experience

  1. Product Browsing: Advanced filtering and sorting
  2. Search: Real-time product search
  3. Cart Management: Add/remove items with quantity control
  4. Wishlist: Save favorite products
  5. Checkout: Secure payment processing (Stripe integration)

πŸ“± Responsive Design

  • Mobile-First: Optimized for mobile devices
  • Tablet Support: Proper layout for tablets
  • Desktop: Full-featured desktop experience
  • Cross-Browser: Compatible with all modern browsers

πŸš€ Deployment

Vercel Deployment (Recommended)

  1. Push to GitHub

    git add .
    git commit -m "Initial commit"
    git push origin main
  2. Deploy to Vercel

    • Go to Vercel Dashboard
    • Click "New Project"
    • Import your GitHub repository
    • Add environment variables
    • Deploy
  3. Update Environment Variables

    • Update NEXTAUTH_URL to your Vercel domain
    • Update OAuth redirect URIs to match your domain

Other Deployment Options

  • Netlify
  • Railway
  • Digital Ocean
  • AWS

πŸ”§ Scripts

# Development
npm run dev          # Start development server
npm run build        # Build for production
npm run start        # Start production server
npm run lint         # Run ESLint
npm run type-check   # Run TypeScript check

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/amazing-feature
  3. Commit your changes
    git commit -m "Add amazing feature"
  4. Push to the branch
    git push origin feature/amazing-feature
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Next.js Team for the amazing framework
  • Firebase Team for the backend services
  • Tailwind CSS for the utility-first CSS framework
  • DummyJSON for the product API
  • React Community for the excellent ecosystem

πŸ“ž Support

If you have any questions or need help, please:

  1. Check the documentation above
  2. Open an issue on GitHub
  3. Join our Discord (coming soon)
  4. Contact the maintainer: [email protected]

πŸŽ‰ Features Roadmap

  • [ ] Email Verification
  • [ ] Password Reset
  • [ ] Admin Dashboard
  • [ ] Order Management
  • [ ] Inventory Management
  • [ ] Product Reviews
  • [ ] Advanced Analytics
  • [ ] Multi-language Support
  • [ ] Dark Mode
  • [ ] PWA Features

Made with ❀️ by Noor Mohammad

⭐ Star this repository if you find it helpful!