Skip to content

Repository files navigation

🌿 KomposVision

Smart Composting & Waste Classification Assistant

KomposVision

Expo React Native TypeScript TensorFlow Lite FastAPI License: MIT

KomposVision is an offline-first mobile app that classifies waste in real time on the device and helps users track compost batches and learn sustainable practices. The final mobile app lives in komposvision_final/ and runs fully on-device β€” no network required.

πŸ† 1st Place β€” IYREF 2026 (Integrated Youth Renewable Energy Festival)

Features Β· Engineering Highlights Β· Architecture Β· Quick Start Β· Roadmap


πŸ“– Table of Contents


🎯 About the Project

KomposVision helps households and communities compost smarter by combining:

  • Real-time on-device computer vision that classifies waste as organic vs inorganic
  • Sorting guidance so only compostable material goes into the pile
  • Offline-first progress tracking for compost batches and activities
  • Guided learning via a materials guide and a local composting assistant

Everything in the mobile app runs on the device β€” inference, storage, and guidance all work with zero connectivity. An optional FastAPI backend exists for shared/online scenarios but is not required.


✨ Features

πŸ“· Real-time Waste Classification

Point the camera at waste and get live, on-device results:

  • Organic vs inorganic classification rendered directly over the camera feed
  • Per-object confidence, updated continuously as you move the camera
  • Runs entirely on-device with TensorFlow Lite β€” no network, no upload

πŸ—‚οΈ Offline-first by Design

  • All data persisted locally with WatermelonDB (SQLite over JSI)
  • Full functionality with zero connectivity

πŸ“ˆ Compost Progress Tracking

  • Save a scan as a compost batch
  • Log materials, activities, and progress over time
  • Review composition summaries and history

πŸ“š Materials Guide

  • Practical do/don't guidance on what to compost and how

πŸ’¬ Offline Chat Assistant

  • Rule-based composting Q&A that uses your local batch context β€” works offline

πŸ› οΈ Engineering Highlights

The scan screen is the technical centerpiece β€” a fully on-device, real-time inference pipeline:

  • 100% on-device inference. No frames or images ever leave the phone.
  • Worklet-based frame processing. Camera frames are processed in a worklet; the YOLO11 decode + Non-Maximum Suppression run inside the worklet, so raw TypedArray/ArrayBuffer tensors are never serialized across the JS bridge β€” only the final ≀20 plain detection objects cross to the JS thread via runOnJS.
  • Stable frame-callback identity. The TFLite model is held in a Synchronizable container so the frame callback keeps a stable identity when the model finishes loading β€” avoiding Android view re-attach (addViewAt) crashes.
  • GPU resize to 640Γ—640 RGB float32 via react-native-vision-camera-resizer before inference.
  • Offline-first persistence with WatermelonDB (reactive SQLite over JSI).
  • New Architecture + Hermes, NativeWind v4 styling, Expo Router file-based navigation.

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Expo React Native App (offline-first)           β”‚
β”‚           Tabs: Scan Β· Progress Β· Materials Β· Chat           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β–Ό                                            β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Real-time Vision (TFLite) β”‚            β”‚  Local Storage             β”‚
β”‚  on-device, in a worklet   β”‚            β”‚  WatermelonDB (SQLite/JSI) β”‚
β”‚                            β”‚            β”‚  batches Β· scans Β·         β”‚
β”‚  organic / inorganic       β”‚            β”‚  activities Β· materials Β·  β”‚
β”‚  live overlay              β”‚            β”‚  profiles                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚ capture snapshot
               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Result + Compost Advisor  β”‚  ──►  saved to WatermelonDB
β”‚  organic/inorganic summary β”‚
β”‚  + sorting guidance        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

              (optional β€” the app does not require it)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   KomposVision Online Backend β€” FastAPI + Supabase + Gemini   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Vision Pipeline

Camera frame (YUV)
   β”‚   react-native-vision-camera frame processor (worklet)
   β–Ό
Resize β†’ 640Γ—640 RGB float32          (vision-camera-resizer, GPU)
   β”‚
   β–Ό
TFLite YOLO11 runSync                 (react-native-fast-tflite)
   β”‚   output [1, 4 + numClasses, 8400]
   β–Ό
Decode + NMS  (inside the worklet; only ≀20 plain boxes cross to JS)
   β”‚
   β–Ό
Live overlay: organic / inorganic + confidence

🧰 Tech Stack

Layer Technology
Mobile Expo SDK 54, React Native 0.81, React 19, TypeScript 5.9
UI NativeWind (Tailwind), Expo Router, React Navigation
Vision (on-device) TensorFlow Lite Β· react-native-fast-tflite Β· react-native-vision-camera Β· YOLOv11 (organic/inorganic)
Concurrency react-native-worklets / worklets-core (frame processing + NMS)
Storage WatermelonDB (SQLite over JSI)
Backend (optional) FastAPI Β· Supabase Β· Gemini API

πŸ“‚ Project Structure

KomposVision/
β”œβ”€β”€ komposvision_final/               # Final mobile app (Expo)
β”‚   β”œβ”€β”€ app/                          # Screens & routes (Expo Router)
β”‚   β”œβ”€β”€ assets/                       # Images + TFLite models
β”‚   β”œβ”€β”€ components/                   # Reusable UI components
β”‚   β”œβ”€β”€ database/                     # WatermelonDB schema & models
β”‚   β”œβ”€β”€ services/                     # Vision + composting services
β”‚   └── utils/                        # Helpers & advisors
β”œβ”€β”€ KomposVision_Online_Backend/       # Optional FastAPI backend
└── komposvision-enterprise-frontend/  # Optional web dashboard

πŸš€ Quick Start

Prerequisites

  • Node.js v18+
  • Expo CLI
  • Android Studio or Xcode (real-time camera + TFLite require a native dev build)

1. Install Dependencies

cd komposvision_final
npm install

2. Run the App

npm run start

Camera + TFLite need a development build (they don't run in Expo Go):

npm run android

Android builds require JDK 17 (org.gradle.java.home in android/gradle.properties).


πŸ”§ Environment Variables

The mobile app runs fully offline and does not require environment variables.

If you use the optional backend, create KomposVision_Online_Backend/backend/.env with:

Variable Description
SUPABASE_URL Supabase project URL
SUPABASE_KEY Supabase service role key
GEMINI_API_KEY Gemini API key

πŸ“š API Documentation

The mobile app needs no API. When the optional backend is running, FastAPI docs are available at:

http://localhost:8000/docs
Method Endpoint Description
GET /health Service health check
POST /scan Analyze a waste image
POST /chat Composting Q&A assistant
GET /progress Compost progress summary
GET /materials Materials guide

πŸ—ΊοΈ Roadmap

Planned work, in honest order of maturity:

  • On-device C:N (carbon:nitrogen) segmentation β€” a YOLOv11-seg model is bundled in the app; pixel-level C/N composition and ratio estimation are planned but not yet trained/enabled. The app currently reports organic vs inorganic only.
  • Contaminant-class detection β€” distinguishing specific non-compostables (plastic, metal, glass) beyond the organic/inorganic split.
  • Image-from-gallery analysis β€” re-running inference on a chosen static image (today, analysis is real-time camera only).

πŸ§ͺ Running Tests

No automated tests are configured yet. Linting and type-checking:

cd komposvision_final
npm run lint
npx tsc --noEmit

🚒 Deployment

Mobile

cd komposvision_final
eas build -p android

Backend (optional)

cd KomposVision_Online_Backend
uvicorn backend.main:app --reload

🀝 Contributing

1. Fork & Branch

git checkout -b feat/your-feature-name

2. Development Workflow

cd komposvision_final
npm run start

3. Code Style

  • Keep components small and focused.
  • Prefer hooks for stateful logic.
  • Match the existing structure in components/, services/, and database/.

4. Commit Convention

Follow Conventional Commits:

feat: add compost batch reminders
fix: handle empty scan results
docs: update vision pipeline diagram

5. Open a Pull Request

  • Target the main branch
  • Describe what and why
  • Reference any related issues

πŸ‘₯ Team

KomposVision was built with ❀️ by:

Name Role
Manta Yuana Backend & Project Manager
Kadek Pindra Frontend & Integration
Nova Andini AI & Data Engineering
Dewa Surya Frontend & UI/UX Designer

πŸ“„ License

This project is licensed under the MIT License. See LICENSE for details.


Built for sustainable communities Β· KomposVision

About

KomposVision is an AI-assisted mobile application designed for precision composting using edge computing. It utilizes on-device computer vision to classify household waste into Carbon or Nitrogen sources and provides real-time recommendations for a balanced compost pile.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors