P.O.T.S – People Of The Soil
Esprit School of Engineering – Class 4DS9 | Academic Year 2025–2026
ARDHI is an AI-powered agricultural management platform developed by P.O.T.S (People Of The Soil) as part of the Data Science Project at Esprit School of Engineering – Tunisia (4th Year Data Science Engineering Program, Academic Year 2025–2026).
The platform is built as a cooperative three-tier architecture:
- 🎯 Node.js backend for authentication, farm management, and request orchestration
- 🤖 Python FastAPI AI service for model inference and agronomy recommendations
- 📱 Flutter mobile app for farmers to interact with the system on mobile devices
The project follows the Team Data Science Process (TDSP) methodology to ensure a structured, reproducible, and scalable AI lifecycle within the AGRISMART initiative.
flowchart TD
Mobile[📱 Flutter Mobile App]
Backend[🎯 Node.js / Express Backend]
AI[🤖 Python FastAPI AI Service]
Storage[(📄 postgresql + model files)]
Mobile -->|HTTP / JWT| Backend
Mobile -->|HTTP fallback| AI
Backend -->|AI proxy calls| AI
Backend -->|JSON file storage| Storage
AI -->|model inference| Storage
Architecture Flow: The mobile app communicates primarily with the Node.js backend, which forwards AI-heavy requests to the Python service. Some flows include direct fallback calls from mobile to AI service for resilience.
| ID | Objective | Status | Implementation |
|---|---|---|---|
| BO1 | Fertilizer Optimization – Reduce excessive usage while improving productivity | ✅ Implemented | Nutrient-based recommendation engine |
| BO2 | Irrigation Scheduling – Optimize water usage based on soil, weather, crop stages | ✅ Implemented | Tabular neural model for planning |
| BO3 | Crop Disease Detection – Early detection from leaf images | ✅ Implemented | EfficientNet-B0 + PyTorch classifier |
| BO4 | Livestock Health Monitoring – Multi-species behavior and health tracking | ✅ Implemented | Real-time WebSocket + MJPEG streaming |
- DSO1: Fertilizer dose prediction using soil features (N, P, K, pH, EC) via tabular ML models
- DSO2: Irrigation need estimation using neural networks trained on region, crop, and climate data
- DSO3: Multi-class crop disease classification using EfficientNet-B0 fine-tuned with PyTorch
- DSO4: Multi-species livestock monitoring pipeline combining detection, confidence scoring, and real-time tracking
- Python – Core language for AI service
- FastAPI – REST API framework for model serving
- PyTorch – Deep learning framework (EfficientNet-B0 for disease detection)
- Scikit-learn / Joblib – Model serialization and tabular ML pipelines
- Custom tabular neural models – Irrigation planning architecture
- WebSocket + MJPEG – Real-time livestock monitoring and video streaming
- Node.js / Express – REST API, authentication, farm management, AI proxy
- JWT (JSON Web Tokens) – Stateless authentication
- Multer – Image upload handling and temporary storage
- Axios + FormData – Multipart request forwarding to AI service
- bcryptjs – Secure password hashing
- Flutter – Cross-platform mobile application (iOS / Android)
- SharedPreferences – Token and locale persistence
- Provider pattern – Centralized state management
- Multi-language support – Arabic (Tunisia), French, English
- JSON flat file (
backend/data/users.json) – User profiles and farm data - Serialized model artifacts – Joblib and PyTorch files under
ai_service/
ARDHI/
├── 🎯 backend/ # Node.js / Express API
│ ├── server.js # Entry point & app configuration
│ ├── routes/ # API routes (auth, farms, predict, irrigation, livestock)
│ │ ├── auth.js # Authentication endpoints
│ │ ├── farms.js # Farm management
│ │ ├── predict.js # Disease prediction proxy
│ │ ├── irrigation.js # Irrigation planning
│ │ └── livestock.js # Livestock analysis
│ ├── controllers/ # Business logic per domain
│ ├── services/ # AI proxy, farm intelligence, user store
│ ├── middleware/ # JWT auth, Multer upload
│ └── data/users.json # Flat file storage (no database required)
│
├── 🤖 ai_service/ # Python FastAPI AI service
│ ├── app.py # FastAPI entry point & route registration
│ ├── model_loader.py # EfficientNet-B0 disease model loader
│ ├── disease_info.py # Human-readable disease descriptions
│ ├── fertilizer_engine.py # Fertilizer recommendation logic
│ ├── irrigation_engine.py # Irrigation planning logic
│ ├── livestock_engine.py # Multi-species livestock analysis
│ ├── realtime_engine.py # WebSocket and MJPEG streaming
│ ├── fertelizer models/ # Serialized fertilizer model artifacts
│ ├── irrigation_model/ # Tabular neural model for irrigation
│ └── models/ # Livestock detection model files
│
└── 📱 mobile/ # Flutter application
└── lib/
├── main.dart # App entry point & configuration
├── state/app_state.dart # Global state management
├── screens/ # UI screens (auth, dashboard, result, etc.)
├── services/ # API services (auth_service, api_service)
├── theme/app_theme.dart # Visual identity & theming
└── l10n/app_strings.dart # Localization support
- Upload leaf images from mobile app
- EfficientNet-B0 classifies diseases with confidence scores
- Returns top predictions, localized descriptions, and treatment guidance
- Supports multiple crop types with human-readable disease information
- Input: region, crop type, prediction date, farm size
- Output: structured irrigation schedule with dosage and timing
- Powered by tabular neural model with preprocessing artifacts
- Region-aware recommendations with seasonal adjustments
- Input: soil nutrient profile (N, P, K, pH, EC, and more)
- Output: recommendation summary, nutrient deltas, dosage, and warnings
- Multiple fertilizer options with regional metadata
- Cost-effective optimization while maintaining crop health
- Static analysis: Multi-species or single-species detection from images
- Real-time monitoring: WebSocket streams with base64-encoded frames
- MJPEG streaming: Browser-compatible video display
- Outputs: Species count, comfort scoring, behavioral alerts, health recommendations
- Create, update, and manage multiple farms
- Automated soil profile analysis and crop intelligence
- Farm catalog with templates and derived agricultural insights
- Integration with all AI services for comprehensive farm optimization
- 📱 User Upload: Farmer captures and uploads leaf image via Flutter app
- 🎯 Backend Processing: Node.js receives image, stores temporarily via Multer
- 🤖 AI Analysis: Backend forwards image to FastAPI disease endpoint
- 🧠 Model Inference: EfficientNet-B0 processes image, returns prediction + confidence
- 📱 Result Display: Flutter renders detailed result screen with treatments
- 📝 Input Collection: User provides region, crop type, farm size via mobile
- 🎯 Request Processing: Backend or mobile sends request to AI service
- 🤖 Plan Generation: Tabular neural model generates irrigation schedule
- 📊 Result Rendering: UI displays schedule, dosage guidance, and warnings
- 🔐 Credentials: User signs up or logs in from mobile app
- ✅ Validation: Backend validates against
users.jsonstorage - 🎫 Token Generation: Signed JWT returned and stored in SharedPreferences
- 🔒 Authorized Requests: All subsequent requests include token in Authorization header
- Node.js ≥ 18.x
- Python ≥ 3.9
- Flutter SDK ≥ 3.x
- Git
1. Clone the Repository
git clone https://github.com/chamseddinedoulaEsprit/Esprit-PI-4DS9-2526-ARDHI.git
cd Esprit-PI-4DS9-2526-ARDHI2. Start the AI Service (Port 8000)
cd ai_service
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
uvicorn app:app --host 0.0.0.0 --port 8000 --reload3. Start the Backend (Port 3000)
cd backend
npm install
cp .env.example .env # Configure AI_SERVICE_URL and JWT_SECRET
node server.js4. Run the Mobile App
cd mobile
flutter pub get
flutter run| Service | Port | URL |
|---|---|---|
| Node.js Backend | 3000 |
http://localhost:3000 |
| FastAPI AI Service | 8000 |
http://localhost:8000 |
| Method | Route | Description | Auth Required |
|---|---|---|---|
GET |
/api/health |
Health check | ❌ |
POST |
/api/auth/signup |
Create new user account | ❌ |
POST |
/api/auth/login |
Login and receive JWT token | ❌ |
GET |
/api/auth/me |
Get authenticated user profile | ✅ |
PUT |
/api/auth/profile |
Update user profile fields | ✅ |
GET |
/api/farms |
List user's farms | ✅ |
POST |
/api/farms |
Create a new farm | ✅ |
PUT |
/api/farms/:farmId |
Update existing farm | ✅ |
POST |
/api/farms/:farmId/refresh |
Regenerate farm automation | ✅ |
POST |
/api/predict |
Disease prediction (image upload) | ✅ |
GET |
/api/irrigation/options |
Get irrigation input options | ✅ |
POST |
/api/irrigation/plan |
Generate irrigation plan | ✅ |
| Method | Route | Description |
|---|---|---|
GET |
/health |
AI service health check |
POST |
/predict |
Plant disease prediction from image |
POST |
/fertilizer/recommend |
Soil-based fertilizer recommendation |
POST |
/irrigation/plan |
Irrigation planning and scheduling |
POST |
/livestock/analyze |
Multi-species livestock analysis |
GET |
/livestock/realtime/status |
Real-time monitoring status |
GET |
/livestock/realtime/{species}/summary |
Species-specific monitoring summary |
POST |
/livestock/realtime/{species}/reset |
Reset tracking state |
WS |
/livestock/realtime/{species}/{session_id} |
WebSocket real-time stream |
GET |
/livestock/camera-stream/{species} |
MJPEG video stream |
The project strictly follows the Team Data Science Process structured lifecycle:
1. Business Understanding
- ✅ Defined clear BOs (BO1-BO4) aligned with AGRISMART initiative
- ✅ Established measurable DSOs with specific technical targets
- ✅ Identified stakeholder needs (farmers, agricultural advisors)
2. Data Acquisition & Understanding
- ✅ Collected diverse datasets: soil profiles, weather data, crop images, livestock videos
- ✅ Performed comprehensive EDA in Jupyter notebooks
- ✅ Validated data quality and preprocessing pipelines
3. Modeling
- ✅ Trained and evaluated multiple model architectures per business objective
- ✅ Implemented EfficientNet-B0 for disease classification
- ✅ Developed tabular neural networks for irrigation planning
- ✅ Created multi-species detection pipelines for livestock monitoring
4. Deployment
- ✅ Packaged models using Joblib and PyTorch serialization
- ✅ Deployed via FastAPI microservice architecture
- ✅ Integrated with Node.js backend and Flutter mobile application
- ✅ Implemented real-time monitoring capabilities
Class: 4DS9 | Academic Year: 2025–2026
| Name | Role | Responsibilities |
|---|---|---|
| Adam Marghli | Project Leader | Overall project coordination, stakeholder management |
| Chamseddine Doula | Project Manager | TDSP implementation, timeline management, deliverables |
| Chaima Ben Farhat | Solution Architect | System architecture, technology stack decisions |
| Najd Rahmani | Data Scientist | ML/DL model development, irrigation & fertilizer engines |
| Jihed Hamila | Data Scientist | Disease detection, livestock monitoring, model optimization |
| Fatma Ezzahra Charfi | Solution Architect | Mobile app architecture, API design, integration |
Institution: Esprit School of Engineering – Tunisia
Program: 4th Year Data Science Engineering (4DS9)
Academic Year: 2025–2026
Project Type: Data Science Project – AGRISMART Initiative
Methodology: Team Data Science Process (TDSP)
Important Architecture Decisions:
- No database server required: All user and farm data stored in
backend/data/users.jsonfor development agility - Lazy model loading: Heavy Python models loaded only when needed to optimize startup times
- Fallback architecture: Mobile app can communicate directly with AI service if backend is unavailable
- Multi-language support: Full localization for Arabic (Tunisia), French, and English
- Real-time capabilities: WebSocket and MJPEG streaming for livestock monitoring
Development Environment:
- Backend temporary uploads are automatically cleaned after processing
- Mobile app configured with fallback URLs for various development scenarios
- Cross-platform compatibility ensured for Android, iOS, and web deployment
This project is developed for academic purposes at Esprit School of Engineering under the supervision of the Data Science faculty. All rights reserved to the academic institution and the P.O.T.S development team.
We extend our sincere gratitude to:
- Esprit School of Engineering faculty for their continuous academic supervision
- Data Science Department for providing the TDSP framework and methodology guidance
- AGRISMART Initiative coordinators for the opportunity to contribute to agricultural innovation
- Our academic supervisors for their invaluable feedback throughout the development lifecycle
🌱 ARDHI – Cultivating the Future of Smart Agriculture 🌱
Developed with ❤️ by P.O.T.S – People Of The Soil