Skip to content

aashir-athar/forest-sentry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ForestSentry app icon — a stylised pine tree on a deep forest disc

🌲 ForestSentry

On-device forest monitoring for the rangers who actually walk the trails.

Stars License: MIT Last commit Top language Issues

Expo SDK 54 React Native TypeScript Supabase TensorFlow Lite Platforms

Features · Getting Started · Usage · Report Bug · Request Feature


ForestSentry is an offline-first React Native app for forest rangers and conservation researchers to tag trees, classify leaf health on-device with TensorFlow Lite, log illegal-logging incidents, and monitor protected zones with PostGIS. Built with WWF Pakistan for remote forests like Nathia Gali — where signal disappears but the case file still has to hold up. Open-source, Expo SDK 54, TypeScript strict, MIT.

🚧 Active development — V1 scaffold is feature-complete (tree registry, on-device classifier, incident reporting, zone polygons, offline sync, active-learning loop). Field data collection and production model training are in progress. See the Roadmap.


✨ Features

Feature Description
📍 20-second tree registry GPS auto-captures; species, girth, and height in a single form. Photo optional.
🍃 On-device leaf-health AI Bundled PlantVillage MobileNet (39-class → 4-bucket verdict) via react-native-fast-tflite. Deterministic HSV fallback keeps the flow working without the native module.
🔁 Active-learning loop Operators confirm or correct every verdict; corrections feed a Supabase pipeline that retrains MobileNetV2 and ships improved models OTA — no app-store release.
🚨 Incident reporting Observation / minor / serious / critical severity, with photo + GPS + notes. Queues offline.
🗺️ PostGIS zone monitoring Draw polygons on the map; real-time inside/outside detection for protected zones.
📈 Trend projection Linear regression + EMA over inspection history, rendered with Skia.
📤 Dataset export CSV for spreadsheets, GeoJSON for QGIS — one tap.
🧭 Offline-first by design SQLite is the source of truth; the sync engine drains to Supabase the moment signal returns.
Field-grade UX High-visibility sun mode, system/light/dark themes, skeleton loading, full a11y (role + label + hint, reduced-motion aware).

🛠️ Tech Stack

Category Technology
Framework Expo SDK 54 (New Architecture), React Native 0.81
Language TypeScript (strict + noUncheckedIndexedAccess)
Navigation expo-router (file-based, typed routes)
UI / Motion react-native-reanimated 4, @shopify/flash-list v2, @shopify/react-native-skia, expo-image
AI inference react-native-fast-tflite + jpeg-js (JPEG → RGB tensor)
Training TensorFlow 2.16 / Keras, MobileNetV2 transfer learning, int8 TFLite (off-device, Colab)
Local data expo-sqlite (WAL), @tanstack/react-query + AsyncStorage persister
State / Forms zustand, react-hook-form + zod
Maps react-native-maps (native MapView + polygons)
Backend Supabase — Postgres + PostGIS + Storage, RLS-enforced
Auth @supabase/supabase-js email OTP (6/8-digit code, no deep links)

🚀 Getting Started

Prerequisites

  • Node.js >= 20 (22 recommended)
  • Git
  • Xcode 16 + iOS Simulator, or Android Studio + a Pixel emulator
  • A Supabase project (free tier is fine)

Installation

git clone https://github.com/aashir-athar/forest-sentry.git
cd forest-sentry/mobile
npm install

Configure

cp .env.example .env
# fill in EXPO_PUBLIC_SUPABASE_URL and EXPO_PUBLIC_SUPABASE_ANON_KEY

Run

npx expo start

For full Supabase setup, EAS builds, and store submission, see zero-to-deploy.md.


📖 Usage

All scripts run inside mobile/.

npm run start      # Boot the Expo dev server
npm run ios        # Open the iOS simulator
npm run android    # Open the Android emulator
npm run web        # Web preview (for inspection)
npm run lint       # Run the Expo ESLint config
npx tsc --noEmit   # Strict TypeScript pass
Active-learning loop: classify, correct, retrain, ship OTA
  1. Settings → Training contribution → ON (opt-in, off by default).
  2. Tag a tree and open Inspect a leaf → take a photo.
  3. The on-device classifier predicts a verdict (healthy / stressed / diseased / pest-damaged).
  4. Confirm it, or tap a different pill to correct it — the diff is the training signal.
  5. Local SQLite records predicted_label, corrected_label, and model_version; the sync engine pushes it to public.training_samples_leaf when signal returns.
  6. Retrain MobileNetV2 with backend/training/train_leaf_health.py, then promote the new model:
select public.wwf_model_promote('leaf-health-v1.1.0');

Every device downloads the new .tflite on next launch via expo-file-system. The bundled placeholder remains the offline-first cold-install fallback.

Swap in your own WWF-trained classifier

Overwrite mobile/assets/models/leaf-health.tflite with your .tflite, then update the modelClasses array and BUCKETS table in mobile/src/features/inspections/labels.ts to match your class order and bucket assignments. The classifier reads the model's declared input shape and dtype at load time — no other code changes required.


🗺️ Roadmap

  • V1 — Tree registry, on-device classifier, incident reporting, zone polygons, offline sync
  • V1 — Supabase backend with RLS, PostGIS, role helpers
  • V1 — CSV / GeoJSON export, trend projection, high-visibility sun mode
  • V1 — Active-learning loop: correction UI, training opt-in, model_versions registry, OTA downloads, Colab training script
  • V1.1 — Logging-detection model trainer (once a field corpus exists)
  • V1.1 — Vision Camera frame-processor TFLite (live leaf scan, no shutter)
  • V1.2 — Multi-language UI (Urdu, Pashto)
  • V2 — Predictive tree-health time series + incident-hotspot anomaly models
  • V2 — WatermelonDB and cluster rendering for very large datasets

🤝 Contributing

Contributions are very welcome — there's a good first issue label for newcomers, and the codebase is intentionally readable.

  1. Fork the repo
  2. Create a branch (git checkout -b feat/your-thing)
  3. Commit using Conventional Commits (feat:, fix:, docs:)
  4. Push and open a PR against main

See CONTRIBUTING.md for details. If you're a botanist or forest scientist, the highest-impact contribution is a real .tflite leaf-health model — see mobile/assets/models/README.md.


📄 License

Distributed under the MIT License. See LICENSE for details.


👤 Author

Aashir Athar

GitHub LinkedIn X


If ForestSentry helps your conservation work, consider leaving a ⭐ — it helps other rangers and researchers find it.

Keywords: react native offline-first app · expo sdk 54 starter · tensorflow lite leaf classifier mobile · on-device plant disease classifier · plantvillage mobilenet react native · active learning loop react native · supabase postgis react native · conservation field app open source · WWF forest monitoring tool · expo-router file-based navigation · react-native-fast-tflite example · on-device ML conservation · GPS tree registry · illegal logging incident reporting


Built by aashir-athar · MIT Licensed

About

Offline-first React Native app for forest rangers: on-device leaf-health AI with an active-learning loop, GPS tree registry, illegal-logging reports, PostGIS zones. Expo SDK 54, TypeScript.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors