A modern web application that gamifies campus cleanup efforts by allowing users to capture before/after photos, verify cleanups using image difference algorithms, and compete on a leaderboard.
- Google Authentication - Secure login with Google OAuth
- Image Capture & Verification - Upload before/after photos with AI-powered verification using pixelmatch
- Points System - Earn points for verified cleanups
- Campus Leaderboard - Compete with other users on campus
- Interactive Map - View all cleanup locations on campus (placeholder for Mapbox integration)
- Profile & Badges - Track your progress and unlock achievements
- Modern UI - Beautiful, eco-inspired design with smooth animations using Framer Motion
- Frontend: React 18 + Vite
- Styling: TailwindCSS
- Animations: Framer Motion
- Routing: React Router v6
- Backend: Firebase (Authentication, Firestore, Storage)
- Image Verification: pixelmatch library
trashtag-ar/
├── public/ # Static assets
│ └── placeholder/ # Placeholder images for badges, map, etc.
├── src/
│ ├── components/ # Reusable components
│ │ ├── auth/ # Authentication components
│ │ ├── layout/ # Layout components (Navbar, etc.)
│ │ └── ui/ # UI components (Button, Card, Badge)
│ ├── contexts/ # React Context providers
│ │ ├── AuthContext.jsx
│ │ └── UserContext.jsx
│ ├── pages/ # Page components
│ │ ├── Home.jsx
│ │ ├── Capture.jsx
│ │ ├── Leaderboard.jsx
│ │ ├── Map.jsx
│ │ └── Profile.jsx
│ ├── services/ # Business logic & API calls
│ │ ├── cleanupService.js
│ │ └── imageVerification.js
│ ├── config/ # Configuration files
│ │ └── firebase.js
│ ├── App.jsx # Main app component
│ ├── main.jsx # Entry point
│ └── index.css # Global styles
├── package.json
├── vite.config.js
├── tailwind.config.js
└── README.md
- Node.js (v18 or higher)
- npm or yarn
- Firebase account
cd trashtag-ar
npm install-
Create a Firebase Project
- Go to Firebase Console
- Click "Add project" and follow the setup wizard
- Enable Google Analytics (optional)
-
Enable Authentication
- In Firebase Console, go to Authentication > Sign-in method
- Enable Google as a sign-in provider
- Add your project's authorized domains
-
Create Firestore Database
- Go to Firestore Database in Firebase Console
- Click "Create database"
- Start in test mode for development (remember to set up security rules for production)
- Choose a location for your database
-
Set up Storage
- Go to Storage in Firebase Console
- Click "Get started"
- Start in test mode for development
- Choose the same location as your Firestore database
-
Get Firebase Configuration
- Go to Project Settings (gear icon) > General
- Scroll down to "Your apps" section
- Click the web icon (
</>) to add a web app - Copy the Firebase configuration object
-
Configure Firebase in the App
- Open
src/config/firebase.js - Replace the placeholder values with your Firebase config:
- Open
const firebaseConfig = {
apiKey: "YOUR_API_KEY",
authDomain: "YOUR_AUTH_DOMAIN",
projectId: "YOUR_PROJECT_ID",
storageBucket: "YOUR_STORAGE_BUCKET",
messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
appId: "YOUR_APP_ID",
};Go to Firestore Database > Rules and update with:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Users can read all user data, but only update their own
match /users/{userId} {
allow read: if true;
allow write: if request.auth != null && request.auth.uid == userId;
}
// Cleanups can be read by all, created by authenticated users
match /cleanups/{cleanupId} {
allow read: if true;
allow create: if request.auth != null;
allow update, delete: if request.auth != null &&
request.resource.data.userId == request.auth.uid;
}
}
}Go to Storage > Rules and update with:
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /cleanups/{userId}/{allPaths=**} {
allow read: if true;
allow write: if request.auth != null && request.auth.uid == userId;
}
}
}npm run devThe app will be available at http://localhost:3000
- Firebase CLI installed (
npm install -g firebase-tools) - Firebase project created and configured
- Environment variables set in
.envfile
-
Login to Firebase
firebase login
-
Initialize Firebase Hosting (if not already done)
firebase init hosting
- Select your Firebase project (
trashtag-ar) - Public directory:
dist - Configure as single-page app: Yes
- Set up automatic builds: No
- Select your Firebase project (
-
Build the Production Version
npm run build
This creates an optimized production build in the
distfolder. -
Deploy to Firebase Hosting
firebase deploy --only hosting
-
Your app will be live at:
https://trashtag-ar.web.appor
https://trashtag-ar.firebaseapp.com
For production deployment, you'll need to set environment variables in Firebase Hosting:
-
Option 1: Build-time environment variables (recommended)
- Keep your
.envfile local (already in.gitignore) - Firebase will use the
.envfile during build if you deploy through CI/CD - Or set them in your deployment script
- Keep your
-
Option 2: Use Firebase Functions (for server-side variables)
- If you need runtime environment variables, consider Firebase Functions
- Go to Firebase Console > Hosting
- Click "Add custom domain"
- Follow the instructions to verify your domain
- Update DNS records as instructed
You can set up automatic deployments with GitHub Actions:
- Create
.github/workflows/deploy.yml:
name: Deploy to Firebase Hosting
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- run: npm ci
- run: npm run build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT }}'
channelId: live
projectId: trashtag-ar- Add
FIREBASE_SERVICE_ACCOUNTsecret to your GitHub repository
{
uid: string,
displayName: string,
email: string,
photoURL: string,
points: number,
cleanups: number,
badges: array,
createdAt: timestamp
}{
userId: string,
userName: string,
userPhoto: string,
location: string,
beforeImageURL: string,
afterImageURL: string,
points: number,
verified: boolean,
timestamp: timestamp
}- Colors: Green-based palette (
primary-*colors in Tailwind config) - Typography: Inter font family
- Border Radius: Rounded corners (xl, 2xl, 3xl)
- Animations: Framer Motion for smooth transitions
- Mapbox integration for interactive campus map
- Badge icon assets
- More sophisticated image verification (ML-based)
- Social sharing features
- Team/group challenges
- Campus-specific customization
- Mobile app (React Native)
- Push notifications
The app is fully responsive and works on both desktop and mobile devices.
- Ensure images are in supported formats (JPG, PNG)
- Check browser console for errors
- Verify that pixelmatch is properly installed
- Verify Firebase config is correct
- Check that Google sign-in is enabled in Firebase Console
- Ensure authorized domains are configured
- Check Firestore security rules
- Verify user is authenticated before accessing protected data
This project is created for educational purposes.
This is a campus-specific project. For contributions, please contact the project maintainers.
Built with ❤️ for a cleaner campus 🌱