A production-ready Next.js web application for currency validation and bill scanning, powered by Google Gemini AI and Firebase. Built with TypeScript, Tailwind CSS, and a professional green/blue financial theme.
- π± Mobile-Responsive Design - Works seamlessly on all devices
- π· Camera Scanner - Scan bills using your device's camera with mobile-optimized experience
- β
Dual AI Validation - Get instant results using TWO AI models:
- π§ Gemini AI (via AI Studio) - Detailed security feature analysis
- π€ Bill Classifier (Custom Vertex AI) - Real/Fake classification
- π Firebase Authentication - Secure Google Sign-In integration
- π Scan History - Keep track of all your previous scans in Firestore
- π¨ Professional UI - Beautiful green/blue financial theme with smooth transitions
- π Google Analytics 4 - Track page views, validation attempts, and user engagement
- β‘ Performance Monitoring - Firebase Performance Monitoring integration
- π Secure Storage - Images stored in Firebase Storage with security rules
- π± Offline Support - Service worker for offline functionality
- π― Toast Notifications - Real-time feedback with react-hot-toast
- πΌοΈ Image Compression - Automatic image compression before upload
- βοΈ Cloud Run Ready - Fully containerized for serverless deployment
This project demonstrates:
- Google AI Studio Integration - Uses Gemini Vision API for currency validation
- Cloud Run Deployment - Serverless containerized deployment
- Applet Architecture - Self-contained API functions
- Rapid Prototyping - From idea to production using AI Studio
See docs/AI_STUDIO_INTEGRATION.md for details on how we used AI Studio to "vibe code" this application.
- Node.js 18+ installed
- npm or yarn package manager
- Google AI Studio account (for Gemini API key)
- Firebase project (for hosting, Firestore, Storage, Auth, Analytics, Performance)
- Go to Google AI Studio
- Sign in with your Google account
- Click "Create API Key"
- Copy the API key (you'll need it for environment variables)
- Go to Firebase Console
- Click "Add project" or select an existing project
- Follow the setup wizard:
- Enter project name
- Enable Google Analytics (optional but recommended)
- Select or create an Analytics account
- In Firebase Console, go to Authentication β Sign-in method
- Enable Google sign-in provider
- Add your domain to authorized domains if needed
- Go to Firestore Database
- Click "Create database"
- Start in production mode (we'll add security rules)
- Choose your preferred location
- Go to Storage
- Click "Get started"
- Start in production mode (we'll add security rules)
- Use the default bucket location
- Analytics is automatically enabled when you create a Firebase project
- Make note of your Measurement ID (G-XXXXXXXXXX)
- Go to Performance in Firebase Console
- Click "Get started" (if not already enabled)
- Follow the setup instructions
- In Firebase Console, go to Project Settings (gear icon)
- Scroll down to "Your apps"
- Click the Web icon (
</>) to add a web app - Register app with a nickname (e.g., "CashGuard Web")
- Copy the Firebase configuration object
You'll need these values:
apiKeyauthDomainprojectIdstorageBucketmessagingSenderIdappIdmeasurementId(from Analytics settings)
npm installCreate a .env.local file in the root directory:
# Firebase Configuration
NEXT_PUBLIC_FIREBASE_API_KEY=your_api_key_here
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_project_id.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_project_id.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=G-XXXXXXXXXX
# Gemini API Key (Server-side only)
GEMINI_API_KEY=your_gemini_api_key_herefirebase deploy --only firestore:rulesfirebase deploy --only storage:rulesnpm run devOpen http://localhost:3000 in your browser.
Cloud Run provides fully managed serverless container deployment:
Quick Start:
# 1. Setup (one-time)
./scripts/setup-cloudrun.sh
# 2. Deploy
./scripts/deploy-cloudrun.shFeatures:
- β Scales automatically (0 to N instances)
- β Pay only for what you use ($0 when idle)
- β Built-in HTTPS and CDN
- β Integrates with Google AI Studio
- β Meets hackathon requirements
Full Guide: See CLOUDRUN_QUICKSTART.md or docs/CLOUD_RUN_DEPLOYMENT.md
auth/unauthorized-domain error, see FIX_FIREBASE_AUTH.md for a quick fix.
Vercel provides seamless Next.js deployment with API routes:
- Push your code to GitHub
- Go to Vercel
- Import your repository
- Add environment variables in Vercel dashboard
- Deploy!
For Firebase Hosting with API routes, you need Firebase Functions:
npm install -g firebase-toolsfirebase loginfirebase initSelect:
- β Hosting
- β Functions
- β Firestore
- β Storage
npm run buildFor Firebase Functions, set environment variables:
firebase functions:config:set gemini.api_key="your_api_key_here"Or use .env file in functions/ directory.
firebase deployNote: For production, consider using Firebase Functions to handle API routes, or deploy Next.js to Vercel and configure Firebase services separately.
You can also deploy Next.js as a standalone server to any Node.js hosting:
npm run build
npm startCashAuth/
βββ app/ # Next.js app directory
β βββ admin/ # Admin dashboard pages
β βββ api/ # API routes
β β βββ admin/ # Admin API endpoints
β β βββ validate/ # Gemini validation endpoint
β βββ scanner/ # Scanner page
β βββ results/ # Results page
β βββ history/ # History page
β βββ settings/ # Settings page
β βββ layout.tsx # Root layout
βββ components/ # React components
β βββ Auth.tsx # Authentication component
β βββ Header.tsx # Header component
β βββ AnalyticsProvider.tsx # Analytics wrapper
β βββ EducationModal.tsx # Educational content modal
β βββ SafeImage.tsx # Safe image loading component
βββ lib/ # Utility libraries
β βββ firebase.ts # Firebase initialization
β βββ firebase-admin.ts # Firebase Admin SDK
β βββ collections.js # Firestore collections
β βββ performance.ts # Performance monitoring
β βββ imageCompression.ts # Image compression
β βββ imageUtils.ts # Image utilities
β βββ toast.tsx # Toast notifications
βββ docs/ # Project documentation
β βββ API_KEYS_SETUP.md # API keys setup guide
β βββ FIREBASE_SETUP.md # Firebase configuration
β βββ FIREBASE_STORAGE_FIX.md # Storage troubleshooting
β βββ GEMINI.md # Gemini AI integration details
β βββ SETUP_CHECKLIST.md # Setup checklist
β βββ VERIFY_SCAN_HISTORY.md # Scan history verification
βββ scripts/ # Node.js utility scripts
β βββ seed-firestore.js # Database seeding
β βββ verify-scan-history.js # History verification
βββ tools/ # Python tools for ML/AI
β βββ create_vertex_import_file.py # Vertex AI data prep
β βββ prepare_coco_dataset.py # COCO dataset prep
β βββ README.md # Tools documentation
βββ public/ # Static assets
β βββ demo/ # Demo images
β βββ education/ # Educational SVG assets
β βββ sw.js # Service worker
βββ firebase.json # Firebase configuration
βββ firestore.rules # Firestore security rules
βββ storage.rules # Storage security rules
βββ firestore.indexes.json # Firestore indexes
βββ README.md # This file
- Firebase Authentication: Required for all operations
- Firestore Rules: Users can only access their own scans
- Storage Rules: Users can only upload/access images in their own folder
- Rate Limiting: API endpoint has rate limiting (10 requests/minute)
- Image Validation: Validates image format and size before processing
page_view- Page navigationvalidation_attempt- Validation attempts (success/failure)validation_success- Successful validationsvalidation_failure- Failed validations with error detailsuser_engagement- User interaction events
- Image validation performance
- API response times
- Page load metrics
Validates a currency bill image using Google Gemini AI.
Request:
{
"imageBase64": "data:image/jpeg;base64,..."
}Response:
{
"success": true,
"result": {
"denomination": "$20",
"currency": "USD",
"validity": "Valid",
"confidence": 85,
"features": ["Watermark detected", "Security thread verified"],
"notes": "Additional observations"
}
}Rate Limiting: 10 requests per minute per IP address
- Next.js 14 (App Router) - React framework
- React 18 - UI library
- TypeScript - Type safety
- Tailwind CSS - Styling
- Firebase - Backend services
- Authentication (Google Sign-In)
- Firestore (Database)
- Storage (Image storage)
- Analytics (User tracking)
- Performance Monitoring
- Google Gemini AI - Currency validation
- react-hot-toast - Notifications
- browser-image-compression - Image compression
- Lucide React - Icons
- The app requires authentication to use scanner features
- Images are automatically compressed before upload to reduce storage costs
- All scans are stored in Firestore with user-specific access
- Service worker provides basic offline functionality
- Performance monitoring tracks validation API calls
- Ensure HTTPS (required for camera access)
- Check browser permissions
- Try a different browser
- Verify environment variables are set correctly
- Check Firebase console for service status
- Ensure security rules are deployed
- Verify
GEMINI_API_KEYis set correctly - Check API quota limits in Google AI Studio
- Ensure image format is valid (JPEG, PNG, WebP)
This project is built for hackathon demonstration purposes.
- Powered by Google Gemini AI
- Built with Firebase
- Icons by Lucide