CardCade is a React-based customer card management application with barcode scanning capabilities and location-based shop selection. The app allows users to store and manage customer loyalty cards with smart features for finding the closest relevant shop.
- 📱 Barcode Scanning: Scan customer cards using your device's camera
- 🎰 Magic Click: Click the logo to automatically select the closest shop based on your location
- 🗺️ Location-Based Selection: Uses hardcoded shop coordinates to find nearby shops and match them with your cards
- 🔥 Firebase Integration: Cloud storage for all your customer cards
- 📱 Responsive Design: Works on mobile and desktop devices
- 🎨 Material Design: Clean, modern UI with Material-UI components
The "Magic Click" feature uses your device's GPS location to:
- Get your current position
- Calculate distances to all shop locations stored with your cards
- Find the closest shop location
- Automatically select and display the card for the closest shop
- Fall back to random selection if no shop locations are available
- Node.js 20.19+ or 22.12+
- A Firebase project
-
Copy the example environment file:
cp .env.example .env
-
Configure your environment variables in
.env
:
VITE_FIREBASE_API_KEY=your_firebase_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=123456789
VITE_FIREBASE_APP_ID=1:123456789:web:abcdef123456
VITE_FIRESTORE_COLLECTION=customer_cards
VITE_APP_NAME=CardCade
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Build for production:
npm run build
-
Deploy to Firebase Hosting:
firebase deploy --only hosting
-
Add Cards: Click "Add Card" to scan or manually enter customer card information
- Shop Locations: Expand the "Shop Locations" section to add GPS coordinates for shop locations
- Multiple Locations: Add multiple locations for chains with multiple stores
- Coordinates: Find coordinates using Google Maps by clicking on a location
-
Magic Click: Click the CardCade logo to find the closest shop and display its card
-
View Cards: Browse all your stored cards in the responsive grid layout
-
Card Details: Click any card to view its full details and barcode
When adding a new card, you can specify one or more shop locations:
- Expand the "Shop Locations" accordion in the add card form
- Enter latitude and longitude coordinates for each shop location
- Add multiple locations for chains (e.g., different McDonald's locations)
- Use Google Maps to find coordinates:
- Search for the shop on Google Maps
- Click on the location to get coordinates
- Copy the coordinates to the form
Example coordinates:
- New York City: 40.7128, -74.0060
- Los Angeles: 34.0522, -118.2437
- London: 51.5074, -0.1278
- Frontend: React 18 + TypeScript + Vite
- UI Library: Material-UI (MUI)
- Backend: Firebase Firestore
- Barcode Scanning: Quagga2
- Location Services: Browser Geolocation API
- Deployment: Firebase Hosting
src/
├── components/
│ ├── AddCardForm.tsx # Card input form with barcode scanning and location management
│ └── CardList.tsx # Card display grid with modal
├── utils/
│ └── magicClick.ts # Location-based shop selection logic
├── types.ts # TypeScript type definitions including ShopLocation
├── firebase.ts # Firebase configuration
└── App.tsx # Main application component
Each customer card now includes shop locations:
interface CardContent {
id: string;
store_name: string;
code: string;
barcode_type: string;
shop_locations: ShopLocation[];
}
interface ShopLocation {
lat: number;
lng: number;
}
- Fork the repository
- Create a feature branch:
git checkout -b feature-name
- Commit your changes:
git commit -am 'Add feature'
- Push to the branch:
git push origin feature-name
- Submit a pull request
- Never commit your
.env
file to version control - Configure Firebase security rules appropriately
- Use HTTPS in production for geolocation access
- Be mindful of location privacy when sharing cards