Skip to content

mu7ammad-3li/swiftcart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›’ SwiftCart

Modern E-Commerce Platform for Fast, Seamless Shopping

A feature-rich, scalable e-commerce solution built with cutting-edge web technologies. Shop with confidence with real-time inventory, secure authentication, and a beautiful, responsive interface.

License: MIT React TypeScript Vite Firebase

Live Demo Β· Report Bug Β· Request Feature


πŸ“‘ Table of Contents


✨ Features

🎯 Core Features

  • Product Catalog: Browse products with advanced filtering and search
  • Shopping Cart: Real-time cart updates with persistent storage
  • User Authentication: Secure Firebase authentication with email/password
  • Order Management: Complete order processing and history tracking
  • Payment Integration: Ready for Stripe/PayPal integration
  • Responsive Design: Mobile-first design that works on all devices

πŸ”’ Security & Performance

  • Firebase App Check: Bot and abuse protection
  • Form Validation: Zod schema validation with React Hook Form
  • Real-time Updates: Live inventory and order status updates
  • Optimized Loading: Code splitting and lazy loading
  • SEO Friendly: Optimized meta tags and semantic HTML
  • Fast Development: Vite for instant HMR and builds

πŸ›  Tech Stack

Frontend

React TypeScript Vite TailwindCSS

Backend & Services

Firebase React Query

UI Components

Radix UI shadcn/ui


πŸš€ Getting Started

Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js 18+ (Download)
  • npm or yarn
  • Firebase Account (Sign Up - Free Spark plan available)

Installation

  1. Clone the repository
git clone https://github.com/mu7ammad-3li/swiftcart.git
cd swiftcart
  1. Install dependencies
npm install
  1. Create environment file

Create a .env file in the root directory:

# Firebase Configuration
VITE_FIREBASE_API_KEY=your-api-key
VITE_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=your-project-id
VITE_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
VITE_FIREBASE_MESSAGING_SENDER_ID=your-sender-id
VITE_FIREBASE_APP_ID=your-app-id
VITE_FIREBASE_MEASUREMENT_ID=your-measurement-id

# App Check (Optional - for production)
VITE_FIREBASE_APP_CHECK_DEBUG_TOKEN=your-debug-token

Firebase Setup

  1. Create a Firebase Project

  2. Enable Authentication

    • Navigate to Authentication > Sign-in method
    • Enable Email/Password authentication
  3. Create Firestore Database

    • Navigate to Firestore Database
    • Create database in production mode
    • Set up security rules (see firestore.rules example)
  4. Enable Firebase Hosting (optional)

    • Navigate to Hosting
    • Click "Get started" and follow instructions
  5. Get your Firebase config

    • Project Settings > Your apps > Add web app
    • Copy the config values to your .env file

Example Firestore Security Rules:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /products/{product} {
      allow read: if true;
      allow write: if request.auth != null;
    }
    
    match /users/{userId} {
      allow read, write: if request.auth != null && request.auth.uid == userId;
    }
    
    match /orders/{order} {
      allow read, write: if request.auth != null;
    }
  }
}
  1. Run the development server
npm run dev

The application will be running at: http://localhost:5173

  1. Build for production
npm run build

πŸ“ Project Structure

swiftcart/
β”œβ”€β”€ πŸ“‚ src/                          # Source code
β”‚   β”œβ”€β”€ πŸ“‚ components/               # React components
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ ui/                  # shadcn/ui components
β”‚   β”‚   β”‚   β”œβ”€β”€ button.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ card.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ dialog.tsx
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ layout/              # Layout components
β”‚   β”‚   β”‚   β”œβ”€β”€ Header.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Footer.tsx
β”‚   β”‚   β”‚   └── Navigation.tsx
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ product/             # Product components
β”‚   β”‚   β”‚   β”œβ”€β”€ ProductCard.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ProductGrid.tsx
β”‚   β”‚   β”‚   └── ProductDetail.tsx
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ cart/                # Cart components
β”‚   β”‚   β”‚   β”œβ”€β”€ CartItem.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ CartSummary.tsx
β”‚   β”‚   β”‚   └── Checkout.tsx
β”‚   β”‚   └── πŸ“‚ auth/                # Authentication components
β”‚   β”‚       β”œβ”€β”€ LoginForm.tsx
β”‚   β”‚       β”œβ”€β”€ RegisterForm.tsx
β”‚   β”‚       └── ProtectedRoute.tsx
β”‚   β”œβ”€β”€ πŸ“‚ pages/                   # Page components
β”‚   β”‚   β”œβ”€β”€ Home.tsx
β”‚   β”‚   β”œβ”€β”€ Products.tsx
β”‚   β”‚   β”œβ”€β”€ ProductDetails.tsx
β”‚   β”‚   β”œβ”€β”€ Cart.tsx
β”‚   β”‚   β”œβ”€β”€ Checkout.tsx
β”‚   β”‚   └── Orders.tsx
β”‚   β”œβ”€β”€ πŸ“‚ lib/                     # Utilities and configurations
β”‚   β”‚   β”œβ”€β”€ firebase.ts             # Firebase initialization
β”‚   β”‚   β”œβ”€β”€ api.ts                  # API calls
β”‚   β”‚   └── utils.ts                # Helper functions
β”‚   β”œβ”€β”€ πŸ“‚ hooks/                   # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ useAuth.ts
β”‚   β”‚   β”œβ”€β”€ useCart.ts
β”‚   β”‚   └── useProducts.ts
β”‚   β”œβ”€β”€ πŸ“‚ types/                   # TypeScript type definitions
β”‚   β”‚   β”œβ”€β”€ product.ts
β”‚   β”‚   β”œβ”€β”€ user.ts
β”‚   β”‚   └── order.ts
β”‚   β”œβ”€β”€ πŸ“‚ contexts/                # React contexts
β”‚   β”‚   β”œβ”€β”€ AuthContext.tsx
β”‚   β”‚   └── CartContext.tsx
β”‚   β”œβ”€β”€ App.tsx                     # Main application component
β”‚   β”œβ”€β”€ main.tsx                    # Application entry point
β”‚   └── index.css                   # Global styles
β”œβ”€β”€ πŸ“‚ public/                      # Static assets
β”‚   β”œβ”€β”€ images/
β”‚   └── icons/
β”œβ”€β”€ .env                            # Environment variables (create this)
β”œβ”€β”€ .env.example                    # Environment template
β”œβ”€β”€ .gitignore                      # Git ignore rules
β”œβ”€β”€ firebase.json                   # Firebase configuration
β”œβ”€β”€ package.json                    # Dependencies and scripts
β”œβ”€β”€ vite.config.ts                  # Vite configuration
β”œβ”€β”€ tailwind.config.ts              # Tailwind CSS configuration
β”œβ”€β”€ tsconfig.json                   # TypeScript configuration
└── README.md                       # This file

πŸ“œ Available Scripts

# Start development server with hot reload
npm run dev

# Build for production
npm run build

# Preview production build locally
npm run preview

# Lint code with ESLint
npm run lint

# Deploy to Firebase Hosting
npm run deploy

🌐 Deployment

Deploy to Firebase Hosting

  1. Install Firebase CLI
npm install -g firebase-tools
  1. Login to Firebase
firebase login
  1. Initialize Firebase
firebase init hosting
  1. Deploy
npm run deploy

Deploy to Vercel

  1. Install Vercel CLI
npm install -g vercel
  1. Deploy
vercel

Deploy to Netlify

  1. Install Netlify CLI
npm install -g netlify-cli
  1. Deploy
netlify deploy --prod

🀝 Contributing

Contributions are what make the open-source community amazing! Any contributions you make are greatly appreciated.

  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

πŸ“ License

Distributed under the MIT License. See LICENSE for more information.


πŸ“§ Contact

Muhammad Ali

Project Link: https://github.com/mu7ammad-3li/swiftcart


πŸ™ Acknowledgments


Built with ❀️ by Muhammad Ali

⬆ Back to Top

About

E-commerce platform (React + TypeScript + Firebase)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages