Qreturn is a comprehensive Progressive Web App (PWA) that revolutionizes the lost and found experience by combining:
- π€ AI-powered image matching for automatic lost/found item detection
- π± QR code technology for quick item registration and tracking
- π Real-time location tracking with proximity notifications (10km radius)
- π¬ Firebase-powered chat for seamless communication between users
- π Push notifications for instant match alerts and updates
- π Offline-first architecture for uninterrupted service
Perfect for communities, universities, airports, and public spaces to help reunite people with their belongings.
View our complete design system on Figma:
π¨ Qreturn UI Design
- Secure Authentication: Powered by Clerk with email/social login
- Profile Management: User verification with NIC/ID upload
- Location Tracking: Automatic GPS tracking (updates every 50+ meters)
- Account Dashboard: View all posts, items, and activity history
- Lost Item Posts: Create detailed lost item reports with photos
- Found Item Posts: Report found items with image upload
- AI Image Matching: Automatic matching via external ML API
- QR Code Generation: Generate unique QR codes for personal items
- Protected QR Scanning: Scan and report found items instantly
- Category System: Organize by Electronics, Documents, Accessories, etc.
- District-based Search: Filter items by geographical location
- Visual Search: Upload image to find similar lost/found items
- Smart Filtering: Search by category, date, location, and keywords
- Map View: Interactive map showing lost/found items with GPS markers
- Proximity Alerts: Get notified when items are reported nearby (10km radius)
- Real-time Chat: Firebase-powered messaging between users
- In-app Notifications: Instant alerts for matches, messages, and updates
- Push Notifications: Stay updated even when app is closed
- Email Notifications: Fallback for critical updates
- Installable: Add to home screen on mobile/desktop
- Offline Support: Browse cached content without internet
- Service Workers: Smart caching for instant loading
- Push Notifications: Native-like notification experience
- Responsive Design: Seamless experience across all devices
- Post Reporting: Flag inappropriate or suspicious content
- Admin Dashboard: Moderate posts and manage user reports
- Account Verification: Optional ID verification for trusted users
- Contact Forms: Support and inquiry system
- Framework: Next.js 15 (App Router, React 19, Server Actions)
- Styling: Tailwind CSS with dark mode
- UI Components: Lucide React, Heroicons
- Animations: Framer Motion
- Maps: Google Maps React API
- QR Codes: qrcode.react
- Image Upload: Cloudinary
- PWA: next-pwa
- Runtime: Node.js with Next.js API Routes
- Database: MongoDB with Mongoose ODM
- Real-time: Firebase (Firestore, FCM)
- Authentication: Clerk
- Image Processing: browser-image-compression
- External ML API: Custom FastAPI server for AI image matching
- Package Manager: npm
- Build Tool: Turbopack (Next.js 15)
- Version Control: Git & GitHub
- Deployment: Vercel-ready
- Analytics: Vercel Analytics
- Webhooks: Svix for Clerk integration
Ensure you have the following installed:
- Node.js: v18 or higher
- npm: v9 or higher
- Git: Latest version
- MongoDB: Atlas account or local instance
- Firebase: Project with Firestore and FCM enabled
- Clerk: Account for authentication
-
Clone the repository:
git clone https://github.com/projectqreturn/Qreturn-Live.git cd Qreturn-Live -
Install dependencies:
npm install
-
Set up environment variables (see Environment Setup):
# Create .env.local file in root directory cp .env.example .env.local # Edit .env.local with your credentials
-
Configure Firebase for PWA:
npm run configure-firebase
-
Generate VAPID keys for push notifications:
npm run generate-vapid
-
Run the development server:
npm run dev
-
Open your browser: Navigate to http://localhost:3000
For PWA testing and production deployment:
# Build the application
npm run build
# Start production server
npm startNote: PWA features (install prompt, service workers, push notifications) require a production build.
Create a .env.local file in the root directory with the following variables:
# MongoDB Database
MONGODB_URL=mongodb+srv://username:[email protected]/
# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_xxxxxxxxxxxxx
CLERK_SECRET_KEY=sk_test_xxxxxxxxxxxxx
CLERK_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxx
# Firebase (Firestore & Cloud Messaging)
NEXT_PUBLIC_FIREBASE_API_KEY=AIzaSyxxxxxxxxxxxxxxxxxxxxxxxxx
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your-project-id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=123456789012
NEXT_PUBLIC_FIREBASE_APP_ID=1:123456789012:web:xxxxxxxxxxxxx
NEXT_PUBLIC_FIREBASE_VAPID_KEY=BKxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Cloudinary (Image Hosting)
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=123456789012345
CLOUDINARY_API_SECRET=xxxxxxxxxxxxxxxxxxxxx
# External Image API (AI Matching)
NEXT_PUBLIC_IMAGE_API_URL=http://18.136.211.184:8000
# Google Maps (Optional)
NEXT_PUBLIC_GOOGLE_MAPS_API_KEY=AIzaSyxxxxxxxxxxxxxxxxxxxxxxxxx
# Application URL (for webhooks & redirects)
NEXT_PUBLIC_APP_URL=http://localhost:3000
# VAPID Keys (for push notifications)
NEXT_PUBLIC_VAPID_PUBLIC_KEY=BPxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
VAPID_PRIVATE_KEY=xxxxxxxxxxxxxxxxxxxxx
VAPID_EMAIL=mailto:[email protected]- MongoDB: MongoDB Atlas - Free tier available
- Clerk: Clerk Dashboard - Free plan includes 5,000 MAU
- Firebase: Firebase Console - Enable Firestore & FCM
- Cloudinary: Cloudinary Console - Free tier: 25GB storage
- Google Maps: Google Cloud Console - Enable Maps JavaScript API
qreturn/
βββ public/
β βββ icons/ # PWA app icons (PNG & SVG)
β βββ QR/ # QR code assets
β βββ slider/ # Landing page images
β βββ manifest.json # PWA manifest
β βββ sw.js # Main service worker (auto-generated)
β βββ firebase-messaging-sw.js # FCM service worker
β
βββ src/
β βββ app/
β β βββ (login)/ # Authentication pages
β β β βββ sign-in/
β β β βββ sign-up/
β β β
β β βββ (mainapp)/ # Protected app routes
β β β βββ (posts)/ # Lost/found post pages
β β β β βββ lost/
β β β β βββ found/
β β β β βββ edit-lostpost/
β β β β βββ edit-foundpost/
β β β βββ (user)/ # User-specific pages
β β β βββ createpost/ # Create new posts
β β β βββ image-search/ # Visual search
β β β βββ map/ # Map view
β β β βββ profile/ # User profile
β β β βββ protectedqr/ # QR scanner
β β β βββ reports/ # User reports
β β β βββ layout.js # Protected layout
β β β
β β βββ (sub-content)/ # Public pages
β β β βββ about/
β β β βββ contact/
β β β βββ privacy/
β β β βββ terms-and-conditions/
β β β
β β βββ api/ # API routes
β β β βββ contact/ # Contact form
β β β βββ images/ # Image operations
β β β βββ myitems/ # User items CRUD
β β β βββ post/ # Post management
β β β β βββ lost/
β β β β βββ found/
β β β βββ push/ # Push notifications
β β β β βββ subscribe/
β β β β βββ unsubscribe/
β β β β βββ send/
β β β βββ report/ # Report system
β β β βββ user/ # User management
β β β β βββ location/
β β β βββ webhooks/ # External webhooks
β β β βββ clerk/
β β β
β β βββ lib/
β β β βββ actions/ # Server actions
β β β β βββ user.action.js
β β β β βββ lostPost.action.js
β β β β βββ foundPost.action.js
β β β β βββ myitems.action.js
β β β β βββ contact.action.js
β β β β
β β β βββ modals/ # Mongoose schemas
β β β β βββ user.modal.js
β β β β βββ lostPost.modal.js
β β β β βββ foundPost.modal.js
β β β β βββ myitems.modal.js
β β β β βββ chat.modal.js
β β β β βββ contact.modal.js
β β β β βββ reportPost.modal.js
β β β β
β β β βββ notification/ # Notification system
β β β β βββ notification.js
β β β β βββ examples.js
β β β β βββ useNotifications.js
β β β β
β β β βββ utils/ # Utility functions
β β β β βββ imageUpload.js
β β β β βββ imageDelete.js
β β β β
β β β βββ db.js # MongoDB connection
β β β βββ utils.js # Helper functions
β β β
β β βββ layout.js # Root layout
β β βββ page.jsx # Landing page
β β βββ globals.css # Global styles
β β
β βββ components/
β β βββ appnav/ # App navigation
β β βββ chat/ # Chat components
β β βββ createpost/ # Post creation
β β βββ footer/ # Footer
β β βββ landingpage/ # Landing page sections
β β βββ map/ # Map components
β β βββ notifications/ # Notification UI
β β βββ postcard/ # Post display cards
β β βββ profile/ # Profile components
β β βββ pwa/ # PWA-specific
β β β βββ InstallPWA.jsx
β β β βββ PWARegistration.jsx
β β β βββ PushNotificationButton.jsx
β β βββ LocationTracker.jsx # Auto location tracking
β β βββ LocationDebugger.jsx # GPS debug tool
β β
β βββ firebase/
β β βββ firebase.config.ts # Firebase configuration
β β
β βββ middleware.js # Clerk route protection
β
βββ scripts/
β βββ configure-firebase-sw.js # Firebase SW setup
β βββ fix-existing-chats.js # DB migration script
β
βββ .github/
β βββ copilot-instructions.md # AI coding guidelines
β
βββ next.config.mjs # Next.js + PWA config
βββ tailwind.config.mjs # Tailwind configuration
βββ package.json # Dependencies
βββ firebase.json # Firebase config
βββ firestore.rules # Firestore security rules
βββ firestore.indexes.json # Firestore indexes
- User signs up/signs in via Clerk
- Webhook creates/syncs user in MongoDB
- Profile stored in MongoDB with location data
- Protected routes enforced by
src/middleware.js
// Access authenticated user
import { useUser } from '@clerk/nextjs';
const { user } = useUser();
const userId = user.id; // Clerk user ID- User uploads images to Cloudinary
- First image sent to external ML API (
uploadMainImageToExternalApi) - API returns UUID-based
searchIdfor matching - Post saved to MongoDB with
search_Idfield - Background AI matching occurs (external service)
LocationTrackercomponent runs automatically in protected routes- Updates MongoDB every 50+ meters movement
- GPS stored as string:
"latitude,longitude" - Used for proximity notifications and map features
// Query nearby users
import { getNearbyUsers } from '@/app/lib/actions/user.action';
const nearbyUsers = await getNearbyUsers(centerGps, radiusKm, excludeUserId);Firebase Cloud Messaging for web push:
- Tokens stored in Firestore (
users/{clerkId}/tokens) - Notifications stored in Firestore (
notificationscollection) - Background handling via
firebase-messaging-sw.js
// Send notification
import { createNotification, NOTIFICATION_TYPES } from '@/app/lib/notification/notification';
await createNotification({
userId: 'clerk_user_id',
type: NOTIFICATION_TYPES.MATCH_FOUND,
title: 'Match Found!',
message: 'Someone found your lost wallet',
link: '/myitems',
sendPush: true
});MongoDB (via Mongoose):
- Users, posts, items, reports, contacts
- Structured data with relationships
- Auto-incrementing IDs via
mongoose-sequence
Firestore (Firebase):
- Notifications (real-time updates)
- Chat messages (real-time messaging)
- FCM tokens (push subscription management)
- Generate unique QR codes for personal items
- Scan QR codes to report found items
- Protected scanning (authentication required)
- Automatic owner notification via push/email
All API routes use Clerk authentication. Protected routes require valid JWT token.
# Create lost post
POST /api/post/lost
Body: { title, date, phone, Category, District, gps, description, email, photo[], clerkUserId }
# Get all lost posts
GET /api/post/lost
# Update lost post
PUT /api/post/lost?id={postId}
# Delete lost post
DELETE /api/post/lost?id={postId}
# Same endpoints for found posts
POST/GET/PUT/DELETE /api/post/found# Get user profile
GET /api/user?clerkId={userId}
# Update user location
POST /api/user/location
Body: { clerkId, gps }
# Get nearby users
GET /api/user/location?gps={lat,lng}&radius={km}# Subscribe to push
POST /api/push/subscribe
Body: { subscription, userId }
# Unsubscribe from push
POST /api/push/unsubscribe
Body: { endpoint }
# Send push notification
POST /api/push/send
Body: { userId, title, body, url, data }# Report a post
POST /api/report
Body: { postId, postType, reason, description, reporterEmail }
# Get all reports (admin)
GET /api/report
# Update report status
PUT /api/report?id={reportId}
Body: { status }Users can install Qreturn as a standalone app:
- Mobile: "Add to Home Screen" prompt
- Desktop: Install button in address bar
- Custom Prompt: Appears 3 seconds after first visit
Main Service Worker (sw.js):
- Caches static assets (images, CSS, JS)
- Network-first strategy for API calls
- Cache-first for images and static resources
- Offline fallback page
Firebase Messaging SW (firebase-messaging-sw.js):
- Handles background push notifications
- Displays native notifications
- Routes notification clicks to app
- Browse cached posts and items
- View previously loaded content
- Queue actions for sync when online
- Automatic retry for failed requests
// API calls: Network-first (15s timeout)
// Images: Cache-first (60 days)
// Static assets: Cache-first (1 year)-
Connect GitHub repository to Vercel
-
Configure environment variables in Vercel dashboard
-
Deploy:
# Vercel automatically detects Next.js # Just push to main branch git push origin main
-
Custom Domain (optional):
- Add domain in Vercel dashboard
- Update DNS records
- SSL automatically provisioned
Ensure all variables from .env.local are added to Vercel:
- Project Settings β Environment Variables
- Add all variables (categorize as Production/Preview/Development)
- β Verify PWA manifest loads correctly
- β Test service worker registration
- β Confirm push notifications work
- β Check MongoDB connection pooling
- β Validate Clerk webhooks (use Vercel URL)
- β Test image upload to Cloudinary
- β Verify external AI API accessibility
- β Test Firebase FCM delivery
- β Check Google Maps API restrictions
# Start development server
npm run dev
# Test in browser
open http://localhost:3000# Build for production
npm run build
# Start production server
npm start
# Test PWA features
open http://localhost:3000Testing PWA Install:
- Open DevTools β Application β Service Workers
- Check "Offline" to test offline mode
- Use Lighthouse audit for PWA score
Visit test pages:
/push-test- Basic push notification testing/notification-test- Advanced notification features/notifications-demo- Complete demo
We welcome contributions! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes
- Test thoroughly
- Commit with conventional commits:
git commit -m "feat: add amazing feature" - Push to your fork:
git push origin feature/amazing-feature
- Open a Pull Request
feat:New featurefix:Bug fixdocs:Documentation changesstyle:Code style changes (formatting)refactor:Code refactoringtest:Test additions or changeschore:Build process or tooling changes
- Use Tailwind CSS for styling
- Follow React best practices
- Use TypeScript for type safety (where applicable)
- Write meaningful component names
- Add comments for complex logic
- Keep components small and focused
- PWA Setup Guide - Comprehensive PWA implementation
- Push Notification Guide - Firebase FCM setup
- Location Notifications - Proximity alert system
- PWA Implementation Summary - Quick reference
- Copilot Instructions - AI coding guidelines
1. Service Worker Not Registering
# Clear browser cache and storage
# Rebuild the app
npm run build
npm start2. Push Notifications Not Working
- Verify VAPID keys are correct
- Check Firebase config in
firebase-messaging-sw.js - Ensure HTTPS (required for web push)
- Grant notification permissions in browser
3. MongoDB Connection Issues
- Check
MONGODB_URLin.env.local - Verify IP whitelist in MongoDB Atlas
- Test connection string format
4. Image Upload Failing
- Verify Cloudinary credentials
- Check image size limits
- Ensure external API is accessible
5. Location Tracking Not Working
- Allow location permissions in browser
- Check HTTPS (required for geolocation API)
- Test on physical device (more accurate)
LocationDebuggercomponent - Visualize GPS data- Browser DevTools β Application β Service Workers
- Firebase Console β Cloud Messaging β Reports
- MongoDB Compass - Database GUI
This project is licensed under the MIT License - see the LICENSE file for details.
Qreturn is developed and maintained by the Project Qreturn team.
- GitHub: projectqreturn
- Repository: Qreturn-Live
- Next.js - The React framework
- Clerk - Authentication platform
- Firebase - Real-time backend
- MongoDB - Database
- Cloudinary - Image hosting
- Vercel - Deployment platform
- Tailwind CSS - Styling framework
For support, questions, or feature requests:
- π§ Email: [email protected]
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
Made with β€οΈ by the Qreturn Team
β Star us on GitHub if you find this project helpful!