AgroLink is a comprehensive mobile application designed to assist farmers and agricultural stakeholders. It features mapping, weather updates, payment integration, notifications, messaging, and AI-driven agricultural advice.
- Frontend: React Native with Expo, NativeWind (Tailwind CSS)
- Backend: Node.js, Express, Socket.io
- Database/Services: Firebase Admin, Google Maps/Geoapify (assumed based on maps), Paystack (Payments)
- Node.js (LTS recommended)
- Expo CLI
- Expo Go app installed on your physical mobile device (available on App Store and Google Play).
-
Install Root/Frontend Dependencies:
npm install
-
Install Backend Dependencies:
cd backend npm install cd ..
The app communicates with a local backend. For the app to reach the backend on a physical device, you likely need to update the API URL.
- Open
services/api.ts. - Update the
BASE_URLto use your computer's local IP address instead oflocalhostor10.0.2.2if you are running on a physical device over Wi-Fi or USB (without reverse forwarding).Tip: You can find your IP using// Example const BASE_URL = 'http://192.168.1.X:3000/api';
ipconfig(Windows) orifconfig(Mac/Linux).
You need to run both the backend server and the frontend application.
Open a terminal and run:
cd backend
npm start
# OR for development with auto-restart:
npm run devThe server usually runs on port 3000.
Open a new terminal in the project root and run:
npx expo startThis will start the Metro Bundler.
- Ensure your phone and computer are connected to the same Wi-Fi network.
- Run
npx expo start. - Scan the QR code displayed in the terminal:
- Android: Use the Expo Go app.
- iOS: Use the Camera app.
If you have connection issues or prefer a wired connection:
- Enable USB Debugging on your Android device (Settings > Developer Options > USB Debugging).
- Connect your device to the computer via USB.
- You can run the app using the Expo Go app over USB, or build a development build.
Using Expo Go over USB:
- Connect device.
- Run:
npx expo start --localhost
- In the terminal, press
ato open on Android. Expo should detect the connected device.
Troubleshooting USB Backend Connection:
If running on a physical device via USB, localhost refers to the phone itself. To access your computer's localhost:
- Solution 1: Use your computer's local IP in
services/api.ts(e.g.,http://192.168.x.x:3000/api). - Solution 2 (ADB Reverse): Route the port from your phone to your computer.
Now,
adb reverse tcp:3000 tcp:3000
http://localhost:3000on the phone will forward to your computer.
- /app: Main application screens and routing (Expo Router).
- /backend: Node.js/Express server and logic.
- /components: Reusable UI components.
- /services: API service interactions (Location, Notification, etc.).
- /utils: Helper functions and configurations.