Next-Generation AI-Powered Waste Segregation System
A full-stack Computer Vision platform that classifies waste in real-time and provides instant, localized disposal guidance based on BBMP (Bengaluru) waste management guidelines.
- Live Deployment
- System Architecture
- RequestβResponse Lifecycle
- Component Pipeline
- Disposal Guidelines
- Performance Metrics
- Technical Stack
- Getting Started
- Engineering Highlights
- Authentication & User Management
- User Dashboard
- Database Architecture
- Complete Database Schema
- Row Level Security
- Complete SmartSort Data Flow
- Application Routes
- Environment Configuration
- Current Application Capabilities
- Current Runtime Versions
- Team
- Impact
| Service | Platform | URL |
|---|---|---|
| π¨ Frontend | Vercel | smart-sort-lac.vercel.app |
| β‘ Backend API | Render | REST /predict endpoint |
SmartSort follows a Decoupled Three-Tier Architecture to ensure scalability, separation of concerns, and high availability. Each tier is independently deployable and scalable.
graph TD
subgraph CLIENT["π₯οΈ Client Tier β Vercel"]
A["π€ User\nPhone Camera"] -->|"Capture frame"| B["⬑ Next.js 15\nApp Router"]
B -->|"Resize 224Γ224\nNormalize [0,1]"| C{{"API Request"}}
end
subgraph SERVER["βοΈ API & Inference Tier β Render"]
C -->|"POST /predict"| D["β‘ FastAPI Backend"]
D -->|"Tensor preparation"| E["π§ MobileNetV2\nInference Engine"]
E -->|"Softmax Β· 12 classes"| F{{"Confidence > 0.70?"}}
F -->|"YES"| G["β
Identify Class\n+ BBMP Mapping"]
F -->|"NO"| H["β Return 'Unknown'"]
end
G -->|"JSON response"| B
H -->|"JSON response"| B
B -->|"Display result"| A
style CLIENT fill:#0f2027,stroke:#00cfff,color:#e2e8f0
style SERVER fill:#0f2027,stroke:#f59e0b,color:#e2e8f0
style E fill:#2d1b69,stroke:#a78bfa,color:#e2e8f0
style D fill:#1a1a00,stroke:#f59e0b,color:#e2e8f0
style B fill:#001a2e,stroke:#00cfff,color:#e2e8f0
style G fill:#002200,stroke:#00ff9d,color:#e2e8f0
style H fill:#2a0000,stroke:#ef4444,color:#e2e8f0
- Framework: Next.js 15 (App Router)
- Camera Handling: MediaDevices API + React-Webcam
- Preprocessing: Resizes and normalizes images to 224Γ224 client-side before transmission
- UI: Tailwind CSS with real-time feedback and scan history
- State Management: Prediction results and scan history persisted in React state
- Framework: FastAPI (Python 3.10) via Uvicorn
- Accepts
multipart/form-dataimage uploads - Normalizes pixel tensors to
[0, 1] - Handles CORS securely for cross-origin frontend requests
- Acts as REST bridge between the UI and the ML inference engine
- Model: MobileNetV2 (Transfer Learning β Functional API)
- Confidence Guard: 0.70 threshold prevents false-positive classifications
- Optimized for real-world variable lighting conditions
Full end-to-end flow from camera capture to disposal guidance display:
sequenceDiagram
autonumber
actor U as π€ User
participant FE as ⬑ Next.js 15<br/>(Vercel)
participant BE as β‘ FastAPI<br/>(Render)
participant ML as π§ MobileNetV2<br/>(Inference Engine)
Note over U,ML: ββ SmartSort AI Β· RequestβResponse Lifecycle ββ
U->>FE: Capture waste image via phone camera
Note right of U: MediaDevices API / React-Webcam
FE->>FE: Client-side preprocessing
Note right of FE: Resize β 224Γ224 px<br/>Normalize pixel values [0, 1]<br/>Reduces network payload
FE->>BE: POST /predict (multipart/form-data)
Note right of FE: Async HTTP request<br/>Preprocessed image bytes
BE->>BE: Decode image β NumPy tensor
Note right of BE: Shape: (1, 224, 224, 3)<br/>Normalize to [0, 1]
BE->>ML: Forward pass β tensor input
Note right of BE: Prepared float32 tensor
ML-->>BE: Probability distribution (12 classes)
Note right of ML: Softmax output across<br/>Battery Β· Biological Β· Plastic Β· Glass<br/>Paper Β· Metal Β· Cardboard Β· Clothes<br/>Shoes Β· Trash Β· Brown-Glass Β· White-Glass
BE->>BE: Confidence guard (threshold = 0.70)
Note right of BE: score > 0.70 β identify class<br/>score β€ 0.70 β return "Unknown"
BE->>BE: Map result β BBMP disposal instruction
Note right of BE: e.g. Plastic β "Blue Dry Waste Bin"<br/>Biological β "Green Compost Bin"<br/>Battery β "e-waste collection centre"
BE-->>FE: JSON response
Note right of BE: { class, confidence, instruction }
FE-->>U: Render result + disposal guidance
Note right of FE: Class label Β· Confidence % Β· Recycling tip
graph LR
subgraph INPUT["π₯ Input Module"]
I1["Image Acquisition\nMediaDevices API"]
I2["Client Preprocessing\n224Γ224 Β· Normalize"]
end
subgraph CORE["βοΈ Core Pipeline"]
C1["FastAPI REST Layer\nPOST /predict"]
C2["Tensor Converter\nNumPy Β· float32"]
C3["MobileNetV2 Engine\nTransfer Learning"]
C4["Confidence Guard\nThreshold = 0.70"]
end
subgraph OUTPUT["π€ Output Module"]
O1["BBMP Mapper\n12 category rules"]
O2["JSON Formatter\nclass Β· confidence Β· instruction"]
O3["UI Renderer\nNext.js State Update"]
end
I1 --> I2 --> C1 --> C2 --> C3 --> C4 --> O1 --> O2 --> O3
style INPUT fill:#001a2e,stroke:#00cfff,color:#e2e8f0
style CORE fill:#1a0f00,stroke:#f59e0b,color:#e2e8f0
style OUTPUT fill:#001a00,stroke:#00ff9d,color:#e2e8f0
SmartSort doesn't just classify waste β it maps every prediction to Bengaluru's BBMP segregation rules, encouraging correct disposal at the source.
| Category | Item Types | Disposal Instruction |
|---|---|---|
| π Hazardous | Battery | Take to designated e-waste collection centers. |
| π± Organic | Biological | Place in the Green Compost Bin. |
| β»οΈ Recyclable | Plastic, Glass, Metal, Cardboard | Rinse and place in the Dry Waste (Blue) Bin. |
| π Textile | Clothes, Shoes | Donate if usable, else use textile recycling drop-off. |
| ποΈ General | Trash | Dispose of in the Landfill (Red) Bin. |
| Metric | Value |
|---|---|
| β Validation Accuracy | 91% |
| ποΈ Training Accuracy | 97% |
| π§ Model Architecture | MobileNetV2 |
| π¦ Total Classes | 12 |
| π Input Dimensions | 224 Γ 224 Γ 3 |
| π‘οΈ Confidence Threshold | 0.70 |
| # | Class | # | Class |
|---|---|---|---|
| 1 | π Battery | 7 | βοΈ Metal |
| 2 | π§« Biological | 8 | π Paper |
| 3 | π€ Brown-Glass | 9 | π§΄ Plastic |
| 4 | π¦ Cardboard | 10 | π Shoes |
| 5 | π Clothes | 11 | ποΈ Trash |
| 6 | π« Glass | 12 | β¬ White-Glass |
| Tool | Purpose |
|---|---|
| Next.js 15 (App Router) | UI framework & routing |
| Tailwind CSS | Utility-first responsive styling |
| React-Webcam | Camera access & frame capture |
| Tool | Purpose |
|---|---|
| FastAPI | REST API framework |
| Uvicorn | ASGI production server |
| Python 3.10 | Runtime |
| Tool | Purpose |
|---|---|
| TensorFlow 2.x | Deep learning framework |
| Keras | High-level model API |
| MobileNetV2 | Transfer learning base model |
| NumPy | Tensor operations |
| Pillow | Image decoding & preprocessing |
| Tool | Purpose |
|---|---|
| GitHub | Version control & CI/CD |
| Vercel | Frontend hosting (CDN + edge) |
| Render | Backend hosting (auto-deploy) |
- Python 3.10+
- Node.js 18+
- Git
git clone https://github.com/Yusufali2004/smart-sort.git
cd smart-sortcd backend
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
uvicorn main:app --reloadBackend runs at: http://localhost:8000
API docs available at: http://localhost:8000/docs
Create a .env.local file inside the frontend/ directory:
NEXT_PUBLIC_API_URL=http://localhost:8000Then run:
cd frontend
npm install
npm run devFrontend runs at: http://localhost:3000
| Feature | Description |
|---|---|
| π‘οΈ Confidence Threshold | 0.70 guard prevents incorrect or ambiguous classifications from reaching the user |
| β‘ Client-Side Preprocessing | 224Γ224 resize & normalization on the edge reduces backend load and latency |
| π₯ Cold-Start Optimization | Warm-up ping strategy ensures the Render backend is ready on first request |
| π Decoupled Deployment | Frontend and backend scale independently with zero coupling |
| πΊοΈ BBMP Mapping | Every class maps to a real Bengaluru disposal rule β not just a label |
SmartSort uses Supabase Authentication to provide secure, user-specific access to the platform.
- π§ Email/password authentication
- π User registration with full name
- π Secure login and logout
- π‘οΈ Protected scanner and dashboard routes
- π€ User profile storage
- π Supabase Row Level Security (RLS)
- π Every waste record is associated with the authenticated user's UUID
User
β
βββ Sign Up
β β
β βββ Supabase Auth
β β
β βββ User ID
β
βββ Login
β β
β βββ Supabase Session
β
βββ Authenticated Application
β
βββ SmartSort Scanner
β
βββ Personal Dashboard
The frontend obtains the authenticated user through the Supabase client and uses the user's UUID when creating waste records.
SmartSort provides a personalized dashboard for every authenticated user.
The dashboard retrieves only the waste records belonging to the currently authenticated user.
| Feature | Description |
|---|---|
| π Total Scans | Total number of waste classifications performed |
| β»οΈ Recyclable Items | Number of potentially recyclable classifications |
| π§ Average Confidence | Average AI classification confidence |
| π± COβ Impact | Estimated cumulative carbon impact |
| π Waste Distribution | Category-wise breakdown of classified waste |
| βοΈ Recorded Weight | Total recorded waste weight |
| π’ Total Quantity | Total quantity of recorded waste |
| π Recent Scans | Latest user classifications |
| π Quick Scan | Direct navigation back to the scanner |
Authenticated User
β
βΌ
Supabase Auth
β
βΌ
User UUID
β
βΌ
waste_records
β
β RLS:
β auth.uid() = user_id
βΌ
User-specific records
β
βΌ
Dashboard Analytics
β
βββ Total Scans
βββ Recyclable Count
βββ Average Confidence
βββ COβ Impact
βββ Waste Distribution
βββ Recent Activity
SmartSort uses PostgreSQL through Supabase for authentication-related data, user profiles, waste classifications, disposal information, and environmental impact calculations.
| Table | Purpose |
|---|---|
profiles |
Stores application-level user profile information |
waste_records |
Stores authenticated users' AI waste classifications |
waste_categories |
Stores waste category definitions and properties |
disposal_guides |
Stores disposal instructions for different materials |
emission_factors |
Stores carbon/emission factors used for environmental calculations |
Supabase Auth
β
β user.id
βΌ
profiles
β
β
βββββββββββββββββ
β
βΌ
waste_records
β
ββββββββββββΌβββββββββββ
βΌ βΌ βΌ
waste_categories disposal_guides emission_factors
Stores application-level information associated with an authenticated Supabase user.
| Column | Type | Nullable | Default |
|---|---|---|---|
id |
UUID | NO | β |
full_name |
TEXT | YES | β |
created_at |
TIMESTAMPTZ | YES | β |
Defines supported waste categories and their disposal characteristics.
| Column | Type | Nullable |
|---|---|---|
id |
UUID | NO |
name |
TEXT | NO |
material |
TEXT | YES |
recyclable |
BOOLEAN | NO |
compostable |
BOOLEAN | NO |
default_disposal_method |
TEXT | YES |
created_at |
TIMESTAMPTZ | NO |
Stores disposal instructions associated with materials.
| Column | Type | Nullable |
|---|---|---|
id |
UUID | NO |
material |
TEXT | NO |
disposal_method |
TEXT | NO |
instructions |
TEXT | NO |
created_at |
TIMESTAMPTZ | NO |
Stores environmental impact factors used for COβe calculations.
| Column | Type | Nullable |
|---|---|---|
id |
UUID | NO |
material |
TEXT | NO |
co2e_per_kg |
NUMERIC | NO |
unit |
TEXT | NO |
source |
TEXT | YES |
recycling_factor |
NUMERIC | YES |
created_at |
TIMESTAMPTZ | NO |
Stores the result of each user's waste classification.
| Column | Type | Nullable | Default |
|---|---|---|---|
id |
UUID | NO | gen_random_uuid() |
user_id |
UUID | NO | β |
ai_category |
TEXT | YES | β |
ai_confidence |
NUMERIC | YES | β |
final_category |
TEXT | NO | β |
material |
TEXT | YES | β |
quantity |
INTEGER | NO | 1 |
weight_grams |
NUMERIC | YES | β |
weight_source |
TEXT | NO | 'manual' |
disposal_method |
TEXT | YES | β |
carbon_impact_co2e |
NUMERIC | YES | β |
created_at |
TIMESTAMPTZ | NO | now() |
waste_records Constraints
- Primary key:
waste_records_pkeyβid - Foreign key:
waste_records_user_id_fkeyβ authenticated user - Check constraint:
weight_source - Required fields enforced through
NOT NULLconstraints
SmartSort uses PostgreSQL Row Level Security to ensure that users can access only their own waste records.
| Policy | Operation | Rule |
|---|---|---|
| Users can view their own waste records | SELECT | auth.uid() = user_id |
| Users can insert their own waste records | INSERT | auth.uid() = user_id |
| Users can update their own waste records | UPDATE | auth.uid() = user_id |
| Users can delete their own waste records | DELETE | auth.uid() = user_id |
This prevents one authenticated user from accessing another user's scan history through the client application.
Read-only Reference Data
Authenticated users can read:
waste_categoriesdisposal_guidesemission_factors
The application now extends beyond simple image classification into a complete authenticated waste-management workflow.
ββββββββββββββββββββ
β User β
ββββββββββ¬ββββββββββ
β
βΌ
ββββββββββββββββββββ
β Supabase Auth β
β Login / Signup β
ββββββββββ¬ββββββββββ
β
β User UUID
βΌ
ββββββββββββββββββββ
β SmartSort β
β Scanner β
ββββββββββ¬ββββββββββ
β
β Camera Image
βΌ
ββββββββββββββββββββ
β FastAPI Backend β
β POST /predict β
ββββββββββ¬ββββββββββ
β
βΌ
ββββββββββββββββββββ
β MobileNetV2 β
β ML Inference β
ββββββββββ¬ββββββββββ
β
βΌ
ββββββββββββββββββββ
β Prediction + β
β Confidence β
ββββββββββ¬ββββββββββ
β
βΌ
ββββββββββββββββββββ
β Supabase β
β waste_records β
ββββββββββ¬ββββββββββ
β
β RLS
βΌ
ββββββββββββββββββββ
β User Dashboard β
ββββββββββββββββββββ
β
ββββββββββββββββ¬βββββββββββββββ
βΌ βΌ βΌ
Analytics Distribution History
β β β
ββββββββββββββββΌβββββββββββββββ
βΌ
User Insights
| Route | Purpose | Authentication |
|---|---|---|
/ |
AI waste scanner | Required |
/login |
User login | Public |
/signup |
User registration | Public |
/dashboard |
Personal waste analytics | Required |
Frontend
Create frontend/.env.local:
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=your_supabase_publishable_key
NEXT_PUBLIC_API_URL=http://localhost:8000For production, NEXT_PUBLIC_API_URL should point to the deployed Render backend.
Never commit private Supabase service-role keys or other server-side secrets to the repository.
SmartSort currently supports the following end-to-end functionality:
- β User registration
- β User login
- β User logout
- β Protected application access
- β Camera-based waste capture
- β AI-powered waste classification
- β 12 waste classes
- β Confidence-based unknown filtering
- β Disposal guidance
- β Persistent user-specific scan records
- β Supabase PostgreSQL database
- β Row Level Security
- β Personalized dashboard
- β Waste distribution analytics
- β Recyclable item tracking
- β AI confidence analytics
- β Recorded quantity and weight
- β COβ impact tracking
- β Recent scan history
- β Render backend deployment
- β Vercel frontend deployment
Note: The System Architecture and Technical Stack sections above reflect the original project versions (Next.js 15 / Python 3.10). The current implementation has since been developed and tested with the versions below.
| Component | Version |
|---|---|
| Next.js | 16.1.6 |
| React | 19.2.3 |
| FastAPI | 0.129.0 |
| Python | 3.12 |
| TensorFlow | 2.20.0 |
| Keras | 3.13.2 |
| Supabase JS | 2.112.3 |
| Tailwind CSS | 4.x |
Team Lead
Team Members
Department of Computer Science & Engineering, HKBKCE-VTU
SmartSort directly contributes to:
- β»οΈ Proper waste segregation at source β reducing contamination of recyclables
- ποΈ Reduced landfill dependency β diverting recyclables and compostables away from dumps
- π Improved recycling efficiency β by giving actionable, bin-specific guidance
- π€ AI-driven urban sustainability β aligning with BBMP's Smart City initiatives