Deployment: https://re-mat.vercel.app
Electronic waste is one of the fastest-growing waste streams globally. India alone generates 3.2 million tonnes of e-waste annually, with alarming consequences:
- 95% of e-waste is handled by the informal sector without proper safety measures
- Only 10-15% of e-waste is properly recycled
- Toxic materials like lead, mercury, and cadmium contaminate soil and water
- Zero visibility into where citizens can dispose of e-waste responsibly
- No incentive system to encourage proper disposal
- Lack of Awareness: Citizens don't know where to dispose of e-waste safely
- No Accessibility: Recycling bins are scarce and hard to locate
- Zero Motivation: No rewards or recognition for responsible disposal
- Manual Processes: Recyclers rely on inefficient, labor-intensive sorting
- Fragmented System: No unified platform connecting citizens, bins, and administrators
ReMat is an AI-powered e-waste recycling platform that gamifies responsible disposal while connecting citizens, smart bins, and administrators in a seamless ecosystem.
- Deep learning model classifies 11 types of e-waste from photos
- 224Γ224 ResNet-style image preprocessing for accuracy
- Confidence-based point allocation rewards quality submissions
- Real-time detection via
/user/detect-wasteendpoint - Manual override option when AI misclassifies
- Note: In the deployment version, the
.tfliteformat of the model has been used for inference, as the.kerasformat is too heavy for the free tier onrender.com. If running locally, it is recommended to use the.kerasformat which can be downloaded from the Kaggle page under ML Model. The model is to be placed underbackend/Modelsand the code inwaste_temp.pyused for running it.
# Real production inference - TensorFlow Keras / TfLite model
img = image.load_img(image_path, target_size=(224, 224))
img_array = image.img_to_array(img)
img_array = preprocess_input(np.expand_dims(img_array, axis=0))
predictions = model.predict(img_array)
# Returns: [Battery, Keyboard, Microwave, Mobile, Mouse, PCB, ...]- Confidence-based rewards: High confidence (β₯75%) =
base_points Γ confidence - Medium confidence (40-75%):
base_points Γ 0.6 - User override triggers manual review with fixed points
- Real-time leaderboard with pagination
- Transaction history tracking every deposit
- Rewards system encourages continued participation
- PostGIS-powered location storage using
POINTgeometry (SRID 4326) - Find nearby bins with
ST_Distancecalculations - Fill-level monitoring: Auto-alerts when bins reach 90% capacity
- Bin status tracking:
activeβfullβmaintenance - Public kiosk screens at each bin with live fill levels and QR codes
- OSRM integration for optimized pickup routes
- Nearest-neighbor algorithm orders stops efficiently
- Real-time driving route geometry visualization
- Multi-bin selection for efficient collection
- Haversine distance calculations for accurate planning
# Real production query - PostGIS geospatial search
SELECT id, name, capacity, fill_level,
ST_Y(location::geometry) AS lat,
ST_X(location::geometry) AS lng,
ST_Distance(location::geography,
ST_MakePoint($lng, $lat)::geography
) AS distance_meters
FROM bins
WHERE status = 'active'
ORDER BY distance_meters ASC
LIMIT 10;Frontend
- React 19 + TypeScript - Modern type-safe UI with latest React features
- Vite 7 - Lightning-fast builds and hot module replacement
- React Router 7 - Protected routes with role-based access control
- Tailwind CSS 4 - Utility-first styling with dark mode support
- Framer Motion & GSAP - Smooth, production-quality animations
- Leaflet / React-Leaflet - Interactive maps for bin locations
- html5-qrcode - QR scanning for bin identification
- react-qr-code - QR code generation for kiosk displays
Backend
- FastAPI - High-performance async REST API
- SQLAlchemy 2 - Modern ORM with async support
- PostgreSQL + PostGIS - Geospatial database for location queries
- GeoAlchemy2 - Geospatial column types and queries
- TensorFlow / Keras - Deep learning for e-waste classification
- Pydantic - Request/response validation with type hints
Authentication & Services
- Firebase Auth - Email/password + Google social login
- Firebase Admin SDK - JWT verification on backend
- Supabase Storage - Pickup request image hosting
- OSRM - Open-source routing machine for route optimization
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β React Frontend (TypeScript) β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β Users β β Admins β β Bins β β Auth β β
β βDashboard β βDashboard β β Kiosk β βLogin/Reg β β
β ββββββ¬ββββββ ββββββ¬ββββββ ββββββ¬ββββββ ββββββ¬ββββββ β
β βββββββββββββββ΄βββββββββββββββ΄ββββββββββββββ β
βββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββΌβββββββββββββββ
β FastAPI REST API β
β (JWT Auth Middleware) β
ββββββββββββββββ¬βββββββββββββββ
β
βββββββββββββββββββΌββββββββββββββββββ
β β β
βββββββΌββββββ ββββββββββΌβββββββββ ββββββΌββββββ
βPostgreSQL β β TensorFlow β β Firebase β
β PostGIS β β Keras Model β β Auth β
β Geography β β (E-waste Class) β β JWT β
βββββββββββββ βββββββββββββββββββ ββββββββββββ
β β β
β ββββββββββΌβββββββββ β
βββββββββΊβ Supabase ββββββββββ
β Storage β
β (Pickup Images) β
βββββββββββββββββββ
Our TensorFlow Keras model is the heart of the platform:
# Backend inference pipeline
class WasteDetector:
def __init__(self, model_path: str):
self.model = load_model(model_path)
self.classes = ['Battery', 'Keyboard', 'Microwave', 'Mobile',
'Mouse', 'PCB', 'Player', 'Printer', 'Television',
'Washing Machine', 'Laptop']
def detect(self, image_path: str):
img = image.load_img(image_path, target_size=(224, 224))
img_array = preprocess_input(np.expand_dims(
image.img_to_array(img), axis=0
))
predictions = self.model.predict(img_array)[0]
return {
'waste_type': self.classes[np.argmax(predictions)],
'confidence': float(np.max(predictions)),
'all_predictions': dict(zip(self.classes, predictions))
}Why?
- Eliminates manual waste sorting overhead
- Scales to thousands of deposits per day
- Improves with more training data over time
- Provides educational value to users
Points adapt to detection accuracy:
def calculate_points(waste_type: str, confidence: float,
user_override: bool) -> int:
base_points = POINTS_MAP[waste_type]
if user_override:
return MANUAL_OVERRIDE_POINTS[waste_type]
elif confidence >= 0.75:
return int(base_points * confidence)
elif confidence >= 0.40:
return int(base_points * 0.6)
else:
return MANUAL_OVERRIDE_POINTS[waste_type]Why?
- Rewards high-quality submissions
- Prevents gaming the system with unclear photos
- Maintains trust through manual override fallback
- Balances automation with human judgment
Geography columns enable powerful spatial queries:
# SQLAlchemy model with GeoAlchemy2
class Bin(Base):
__tablename__ = 'bins'
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid4)
name = Column(String, nullable=False)
location = Column(Geography(geometry_type='POINT', srid=4326))
capacity = Column(Integer, default=100)
fill_level = Column(Integer, default=0)
status = Column(Enum(BinStatus), default=BinStatus.ACTIVE)
# Query: Find bins within radius
nearby_bins = db.query(Bin).filter(
func.ST_DWithin(
Bin.location,
func.ST_MakePoint(lng, lat),
radius_meters,
True # Use geography for spherical calculations
)
).all()Why?
- Accurate distance calculations on Earth's surface
- Efficient spatial indexing for fast lookups
- Industry-standard approach used by Uber, DoorDash, etc.
- Enables future features like service area polygons
Single unified platform serves different user types:
# JWT verification + role extraction
async def verify_firebase_token(
authorization: str = Header(...),
db: Session = Depends(get_db)
):
token = authorization.replace('Bearer ', '')
decoded = firebase_admin.auth.verify_id_token(token)
user = db.query(User).filter(User.uid == decoded['uid']).first()
if not user:
raise HTTPException(status_code=404, detail="User not found")
return user # Contains role: 'user' or 'admin'Frontend Protected Routes:
// Different dashboards based on role
<Route path="/user/*" element={
<ProtectedRoute allowedRoles={['user']}>
<UserLayout />
</ProtectedRoute>
} />
<Route path="/admin/*" element={
<ProtectedRoute allowedRoles={['admin']}>
<AdminLayout />
</ProtectedRoute>
} />Why?
- Single authentication system for all users
- Clear separation of concerns
- Secure role-based access control
- Easy to add new roles (e.g., 'collector', 'verifier')
- Node.js 18+, Python 3.10+, PostgreSQL 14+ with PostGIS
- Firebase account, Supabase account (optional)
# Clone repository
git clone <repository-url>
cd ReMat
# Backend setup
cd backend
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
mkdir -p uploads/waste_images
# Configure environment
# 1. Firebase Admin: either add backend/serviceAccountKey.json (keep in .gitignore)
# OR set FIREBASE_SERVICE_ACCOUNT_JSON in backend/.env to the full JSON string (for production/CI)
# 2. Create backend/.env with database and API credentials
# Start backend
uvicorn main:app --reload --host 0.0.0.0 --port 8000
# Frontend setup (new terminal)
cd frontend
npm install
# Configure frontend/.env with Firebase config
npm run devCREATE DATABASE remat;
\c remat
CREATE EXTENSION postgis;email: admin@remat.com
passoword: rematadmin
Here is the training of the ML model used: Kaggle
- Authentication: Email/password or Google sign-in via Firebase
- Smart Recycling: Scan bin QR β capture photo β AI classifies β earn points
- Pickup Requests: Schedule large item collection with photo, location, and time
- Gamification: Real-time leaderboard, points tracking, and rewards
- Transaction History: Complete audit trail of all deposits
- Profile Management: View stats, recent activity, and account settings
- Bin Management: Add, edit, delete bins with location, capacity, and status
- Fill Monitoring: Real-time alerts when bins reach 90% capacity
- Pickup Queue: Review, accept, or reject user pickup requests
- Route Optimization: Generate efficient collection routes with OSRM
- Analytics Dashboard: Overview of system health and performance
- Points Control: Set reward amounts when accepting pickup requests
- Public Display: Show bin name, fill level, capacity at
/bin/:binId - QR Code: Generate scannable code for users to start recycling
- Live Updates: Real-time fill level visualization
- Status Indicators: Visual feedback on bin operational status
- 11-class e-waste classifier trained on custom dataset
- ResNet-style preprocessing for optimal accuracy
- Confidence thresholds prevent false positives
- Model versioning ready for continuous improvement
- Training pipeline documented in Kaggle notebook
- PostGIS geography type for accurate Earth-surface calculations
- Spatial indexing enables sub-100ms nearby queries
- OSRM integration for real-world driving routes
- Haversine distance for initial proximity sorting
- Future-ready for service area polygons and geofencing
- FastAPI async handlers for concurrent requests
- Connection pooling optimizes database access
- Lazy loading for images and heavy resources
- Progressive image upload with Supabase CDN
- Optimistic UI updates for instant feedback
- ACID transactions for critical operations (points, deposits)
- Foreign key constraints maintain referential integrity
- Enum types for validated status fields
- UUID primary keys prevent collision in distributed systems
- Cascading deletes keep data consistent
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/signup |
Register user (Firebase token + name) |
| POST | /auth/login |
Login (Firebase token) |
| GET | /auth/me |
Current user profile |
| DELETE | /auth/me |
Delete account |
| Method | Endpoint | Description |
|---|---|---|
| GET | /user/me |
User by ID (query param) |
| POST | /user/detect-waste |
Upload image β AI classification |
| PUT | /user/recycle/{binid} |
Confirm deposit and earn points |
| GET | /user/transactions/{user_id} |
Paginated transaction history |
| GET | /user/leaderboard |
Top users by points |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/bins/ |
List all bins with coordinates |
| GET | /api/bins/{bin_id} |
Bin details by ID |
| GET | /api/bins/nearby |
Find bins near lat/lng |
| POST | /api/bins/ |
Create bin (admin only) |
| PUT | /api/bins/{bin_id} |
Update bin |
| DELETE | /api/bins/{bin_id} |
Delete bin |
| Method | Endpoint | Description |
|---|---|---|
| GET | /user/pickup-requests |
My requests |
| POST | /user/pickup-requests |
Create request (multipart) |
| PATCH | /user/pickup-requests/{id}/location |
Update location |
| DELETE | /user/pickup-requests/{id} |
Delete (open only) |
| GET | /admin/pickup-requests |
All requests (admin) |
| PATCH | /admin/pickup-requests/{id}/accept |
Accept with points |
| PATCH | /admin/pickup-requests/{id}/reject |
Reject request |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/route/optimize |
Generate optimized route |
| Method | Endpoint | Description |
|---|---|---|
| GET | /bin/panel/{bin_id} |
Public bin display data |
| POST | /bin/panel/{bin_id}/confirm |
Kiosk deposit confirmation |
All protected routes require: Authorization: Bearer <Firebase ID token>
Architecture:
- Base: ResNet-style CNN architecture
- Input: 224Γ224 RGB images
- Output: 11 classes with softmax probabilities
- Preprocessing:
keras.applications.resnet.preprocess_input
Classes:
- Battery
- Keyboard
- Microwave
- Mobile
- Mouse
- PCB (Printed Circuit Board)
- Player (Media player)
- Printer
- Television
- Washing Machine
- Laptop
Training:
- Dataset: Custom e-waste image collection
- Augmentation: Rotation, flip, zoom, brightness
- Validation split: 20%
- Early stopping + model checkpointing
- Full training notebook: ReMat on Kaggle
Production Inference:
# Load model once at startup
model = load_model('backend/Models/ewaste_final.keras')
# Inference per request
img = image.load_img(path, target_size=(224, 224))
img_array = preprocess_input(
np.expand_dims(image.img_to_array(img), axis=0)
)
predictions = model.predict(img_array)[0]
result = {
'class': classes[np.argmax(predictions)],
'confidence': float(np.max(predictions)),
'all_probabilities': dict(zip(classes, predictions))
}We welcome contributions!
- Fork the repo
- Create feature branch:
git checkout -b feature/AmazingFeature - Commit changes:
git commit -m 'Add AmazingFeature' - Push to branch:
git push origin feature/AmazingFeature - Open Pull Request
- Email: remat.project123@gmail.com
Made with β€οΈ for a greener planet
Every device recycled counts. Every action matters. Together, we can tackle e-waste responsibly.
β Star us on GitHub if you believe in our mission!
