-
-
Landing Page w/ options to sign up/log in
-
Authentication Page (Sign Up Form)
-
Page-view of Dashboard. User Level, Points, Streaks, Leaderboards (User), Recycle-a-thons.
-
Page-view of Dashboard. Contains college-based leaderboard.
-
Recycle Image UI. User takes a picture using camera; image is scanned with Gemini API.
-
Unsuccessful Recycle. View if Gemini determines object to not be recyclable.
-
Successful Recycle. Gemini provides tips for preparation of the object prior to recycle and where to recycle it.
-
Point addition from Recycle (increased if user is completing a challenge).
-
Impact from Recycle. Estimate by Gemini API of mass of CO2 emissions reduced as a result of recycle.
-
Summary of Recycle. Shows, points, impact, and current leaderboard.
-
Full view of dashboard, with ongoing community challenge.
-
View of people tab. User can challenge any person to a direct, person-to-person, 1-hour recycle challenge.
EcoSnap - HackPrinceton Fall 2025
Inspiration
Recycling participation on college campuses is dismally low despite our generation being the most environmentally conscious in history. The problem isn't awareness—it's motivation. Recycling feels like a silent, thankless chore with no feedback, no recognition, and no sense of impact.
EcoSnap transforms recycling into an exciting, social, rewarding experience using AI-powered computer vision and comprehensive gamification. We're making sustainability feel like leveling up in your favorite game, not homework.
What it does
AI-Powered Computer Vision: Your Personal Recycling Expert
Snap a photo of any item and get instant, intelligent feedback:
- Google Gemini 2.5 Flash Vision API performs multimodal analysis in ~2 seconds
- Advanced computer vision pipeline extracts:
- Material composition (plastic types: PET, HDPE, PP; metals; paper grades; glass; composites)
- Object classification through neural network-based image understanding
- Visual feature extraction (texture, color, reflectivity, labels)
- Size estimation and contamination detection
- Actionable feedback: preparation instructions ("rinse clean," "remove cap"), drop-off locations, recyclability verdict
- Environmental impact: CO2 reduction (grams), trees saved, energy conserved, points—all calculated from AI-analyzed material type and size
Complete Gamification System
- Points: 25-3,150+ per recycle based on AI-calculated environmental impact and item size
- 100 Levels: Exponential progression system requiring balanced advancement across points, items recycled, AND CO2 reduced—prevents gaming
- Daily Streaks: Consecutive-day tracking with visual weekly calendars
- Challenges: 1-hour head-to-head battles and universal challenges with real-time countdowns
- Leaderboards: User rankings (sortable by points, items, CO2, level, streak) and school-vs-school competition
- Success celebrations: Confetti animations, multi-step reveals showing points earned, CO2 impact, streak achievements, and leaderboard updates
Real Environmental Impact Tracking
Real-time visualization of CO2 reduction (kg), total items recycled, trees saved, and energy conserved. Your score actually matters—watch your genuine environmental contribution compound over time.
How we built it
Frontend: Next.js 16 + React 19
- App Router with JWT-based protected routes
- Tailwind CSS for responsive design
- MediaDevices API for camera capture with front/rear toggle
- Client-side image preprocessing (Canvas API): 1280x720 target resolution, 0.85 JPEG quality, automatic orientation correction
Backend: Node.js + Express.js
- RESTful API with MongoDB + Mongoose ODM
- JWT authentication with UserSession model
- MongoDB TTL indexes for automatic session cleanup
Computer Vision & AI Integration
This is the technical heart of EcoSnap. We chose Gemini 2.5 Flash Vision for superior speed-to-accuracy and structured output reliability.
Multimodal AI Architecture:
- Prompt engineering: Crafted detailed prompts combining visual analysis instructions with JSON schema requirements—dozens of iterations to achieve consistency
- Temperature tuning (0.4): Balanced creativity with deterministic classifications
- Structured output schemas: Enforced JSON format for reliable parsing
Computer Vision Analysis:
- Object detection and segmentation: Identifies recyclables in cluttered scenes
- Material classification: Analyzes texture, color, reflectivity, shape patterns to determine PET plastic, HDPE, aluminum, cardboard, etc.
- Size and quantity estimation: Comparative visual analysis for impact calculation
- Contamination detection: Flags food residue, liquids, mixed materials
Semantic Understanding:
- Natural language generation: Human-readable recycling instructions
- Context-aware preparation steps: Material-specific handling guidance
- Environmental impact calculation: CO2, trees, energy—all AI-calculated from visual analysis
- Dynamic points algorithm: Impact level × size × quantity, with anti-gaming safeguards (quantity capped at 10, can't recycle same item repeatedly)
Infrastructure:
- Cloudinary for image hosting and CDN delivery
- MongoDB Atlas for production database
- Base64 encoding for reliable binary transfer
Challenges we ran into
1. Prompt Engineering for Structured Vision Output
Getting Gemini's vision model to return parseable JSON instead of conversational text was harder than expected.
Problems:
- Early responses were descriptive prose: "This appears to be a plastic bottle that could potentially be recycled..."
- Model sometimes wrapped JSON in markdown fences or added commentary
- Missing/null values for metrics broke frontend
- Needed guaranteed numeric impact claims for gamification
Solutions:
- Engineered 34-line prompt explicitly demanding JSON-only output with no markdown
- Built robust parsing: strip markdown fences, extract JSON between first
{and last}, try-catch with fallbacks - Defensive metric extraction with multiple fallback paths for
treesSaved,energyHours,co2KgReduced
Result: fast responses with 95%+ valid JSON containing all required fields.
2. Three-Metric Leveling Balance
Preventing players from gaming the system by recycling 1000 bottle caps required multi-dimensional leveling.
Problems:
- Points-only leveling → users spam low-impact items
- Quantity-based → doesn't reward high-impact recycling (electronics)
- Need to balance points, item count, AND CO2 reduction
Solutions:
- System requires all three metrics (points, items, CO2) to advance
- Exponential growth curve (1.3x multiplier per level) keeps early levels achievable, late levels challenging
- Diminishing returns: full credit for first 10 items, then 0.5x for each additional
- Size multipliers (small: 1x, medium: 1.8x, large: 3.5x) + impact tiers create 9 distinct point brackets
Result: Level 1→2 takes ~5 items, level 10→11 takes ~90 items, but users must balance what they recycle, not just how much.
3. Date-Based Streak Logic & Camera Stream Management
Streak challenges: Users recycling at 11:59 PM vs 12:01 AM should both count; preventing double-counting; handling timezone differences.
Solutions: ISO date strings (YYYY-MM-DD) normalize timezones; stored array of unique recycling dates (streakDates) prevents double-counting; logic handles yesterday/gap/same-day cases
Camera challenges: MediaStream requires cleanup; switching front/back cameras; canvas mirroring for front camera.
Solutions: Proper stream cleanup in useEffect unmount; auto-restart stream on camera toggle; canvas transformation for front camera mirroring; URL.revokeObjectURL prevents blob leaks
4. Parallel Async Operations
Coordinating multiple async operations without sequential slowdown.
Problem: Uploading to Cloudinary + Gemini classification sequentially = 6-7s total
Solution: Promise.all for parallel user fetch + Cloudinary upload; sessionStorage to pass data between Next.js pages; single transaction for user updates
Result: fast average recycle flow from capture to confirmation.
What we learned
- Multimodal prompt engineering is an art: Vision models are probabilistic, not deterministic. Getting consistent JSON output from visual inputs required explicit schemas and dozens of iterations.
- Confidence thresholds build trust: Transparency when AI is uncertain creates better user experience than overconfident wrong answers.
- Social competition drives engagement: Leaderboards became the most engaging feature—humans are competitive, lean into it.
- Instant feedback creates addiction: Multi-step success screen reveals (points → CO2 → streak → leaderboard) build anticipation then deliver dopamine hits.
- Streaks create unbreakable habits: Daily streak mechanics build FOMO—users who hit 7 days don't want to break it.
What's next
Near-Term Enhancements:
- Enhanced Challenges: Material-specific challenges, team goals, weekly challenge cycles
- Achievements: Milestone badges (100 items, 10kg CO2), rare achievements, profile showcase
- Push Notifications: Daily reminders, streak protection alerts, challenge notifications
- Advanced Analytics: Personal impact graphs, monthly reports, future projections
Long-Term Vision:
- Partnerships: Convert points to dining dollars, exclusive discounts, campus sustainability office integration
- Advanced CV Features: Multi-object detection (YOLO/Mask R-CNN), contamination detection, barcode/OCR recognition, AR preview
- Global Expansion: Multi-university network, national leaderboards, inter-school competitions
Why EcoSnap Matters
We combined cutting-edge computer vision AI, game design psychology, and environmental impact tracking to make recycling genuinely exciting. Imagine thousands of students across hundreds of universities competing to be the greenest school—recycling rates could double because we made it feel like winning, not sacrifice.

Log in or sign up for Devpost to join the conversation.