On-device forest monitoring for the rangers who actually walk the trails.
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.
| 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). |
| 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) |
- Node.js >= 20 (22 recommended)
- Git
- Xcode 16 + iOS Simulator, or Android Studio + a Pixel emulator
- A Supabase project (free tier is fine)
git clone https://github.com/aashir-athar/forest-sentry.git
cd forest-sentry/mobile
npm installcp .env.example .env
# fill in EXPO_PUBLIC_SUPABASE_URL and EXPO_PUBLIC_SUPABASE_ANON_KEYnpx expo startFor full Supabase setup, EAS builds, and store submission, see
zero-to-deploy.md.
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 passActive-learning loop: classify, correct, retrain, ship OTA
- Settings β Training contribution β ON (opt-in, off by default).
- Tag a tree and open Inspect a leaf β take a photo.
- The on-device classifier predicts a verdict (
healthy/stressed/diseased/pest-damaged). - Confirm it, or tap a different pill to correct it β the diff is the training signal.
- Local SQLite records
predicted_label,corrected_label, andmodel_version; the sync engine pushes it topublic.training_samples_leafwhen signal returns. - 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.
- 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_versionsregistry, 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
Contributions are very welcome β there's a good first issue label for newcomers, and the codebase is intentionally readable.
- Fork the repo
- Create a branch (
git checkout -b feat/your-thing) - Commit using Conventional Commits (
feat:,fix:,docs:) - 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.
Distributed under the MIT License. See LICENSE for details.
Aashir Athar
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