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.
- Features
- Tech Stack
- Getting Started
- Project Structure
- Available Scripts
- Deployment
- Contributing
- License
- Contact
|
|
Before you begin, ensure you have the following installed:
- Clone the repository
git clone https://github.com/mu7ammad-3li/swiftcart.git
cd swiftcart- Install dependencies
npm install- 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-
Create a Firebase Project
- Go to Firebase Console
- Click "Add project" and follow the setup wizard
-
Enable Authentication
- Navigate to Authentication > Sign-in method
- Enable Email/Password authentication
-
Create Firestore Database
- Navigate to Firestore Database
- Create database in production mode
- Set up security rules (see
firestore.rulesexample)
-
Enable Firebase Hosting (optional)
- Navigate to Hosting
- Click "Get started" and follow instructions
-
Get your Firebase config
- Project Settings > Your apps > Add web app
- Copy the config values to your
.envfile
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;
}
}
}- Run the development server
npm run devThe application will be running at: http://localhost:5173
- Build for production
npm run buildswiftcart/
βββ π 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
# 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- Install Firebase CLI
npm install -g firebase-tools- Login to Firebase
firebase login- Initialize Firebase
firebase init hosting- Deploy
npm run deploy- Install Vercel CLI
npm install -g vercel- Deploy
vercel- Install Netlify CLI
npm install -g netlify-cli- Deploy
netlify deploy --prodContributions are what make the open-source community amazing! Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
Muhammad Ali
- GitHub: @mu7ammad-3li
- Email: muhammad.3lii2@gmail.com
- LinkedIn: linkedin.com/in/muhammad-3lii
Project Link: https://github.com/mu7ammad-3li/swiftcart
- React - UI library
- Vite - Build tool
- Firebase - Backend infrastructure
- shadcn/ui - UI components
- Tailwind CSS - Styling
- Radix UI - Headless UI components
- React Query - Data fetching and caching
- React Router - Routing
Built with β€οΈ by Muhammad Ali