Skip to content

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

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages