Agrologer is a sophisticated agricultural monitoring and analysis system designed to leverage IoT devices and machine learning to provide real-time insights and recommendations for farmers. The project consists of multiple components including a mobile app, main server, socket server, ML models server, and device server.
You can download the latest version of the Agrologer app by clicking the button above or using the following link:
Agrologer aims to provide a comprehensive solution for agricultural management by integrating sensor data, machine learning predictions, and user interaction through a mobile app. The system is designed to be scalable, efficient, and user-friendly, ensuring that farmers can make data-driven decisions to optimize their crop yield and resource usage.
The Agrologer system is composed of several interconnected components as illustrated in the system design diagram below.
- User (Mobile App): Interface for farmers to interact with the system.
- Main Server: Handles core application logic and communication.
- Socket Server: Manages real-time data communication between devices.
- ML Models Server: Performs machine learning predictions and analysis.
- Device Server: Collects and processes data from various sensors.
- Redis: In-memory data structure store for fast data access.
- PostgreSQL: Database for persistent storage of system data.
The project is organized as follows:
NASA_SPACE_APP_AGROLOGER/
├── client/ # React Native app (mobile)
├── modelServer/ # Python ML models server
├── server/ # Node.js Express server (main)
├── socket/ # Node.js WebSocket server
├── Agrolzyer.ino # IoT device code
├── README.md # Project documentation
└── SystemDesign.png # System architecture diagram
Each component of the Agrologer system relies on environment variables to manage configuration settings. Below are the required .env
files for each part of the system:
NODE_ENV=development
PORT=8001
CLIENT_SECRET=your_client_secret
REMOTE_CLIENT_APP=your_remote_client_app
DB_USER=your_database_user
DB_PASS=your_database_password
DB_NAME=your_database_name
DB_HOST=your_database_host
SERVER_EMAIL=your_server_email@example.com
MAIL_PASS=your_email_password
MAIL_HOST=smtp.your_email_provider.com
AUTHORITY_EMAIL=authority_email@example.com
TWILIO_ACCOUNT_SID=your_twilio_account_sid
TWILIO_AUTH_TOKEN=your_twilio_auth_token
TWILIO_SERVICE_SID=your_twilio_service_sid
REDIS_URL=your_redis_url
SECRET_KEY=your_secret_key
DATABASE_URL=your_database_url
FLASK_ENV=development
CLIENT_SECRET=your_client_secret
EXPO_PUBLIC_SERVER_URI=your_server_uri
EXPO_PUBLIC_GMAP_API_KEY=google_console_google_map_api_key
Note: Ensure that the
.env
files are properly configured with the actual values for each variable before running the servers.
To run the Node.js Express server:
-
Open a terminal and navigate to the
server/
directory. -
Install the necessary dependencies:
npm install
-
Start the server:
npm start
This will launch the Express server, typically accessible at http://localhost:8001
.
To run the machine learning models server:
-
Open a terminal and navigate to the
modelServer/
directory. -
Activate your Python virtual environment (if you haven’t created one, you can do so with
python -m venv venv
):-
On Linux/macOS:
source venv/bin/activate
-
On Windows:
.\venv\Scripts\activate
-
-
Install the required Python packages:
pip install -r requirements.txt
-
Start the server:
python app.py
The Python server will be accessible at http://localhost:5001
.
To run the mobile app using Expo:
-
Open a terminal and navigate to the
client/
directory. -
Install the necessary dependencies:
npm install
-
Ensure you have Expo CLI installed globally:
npm install -g expo-cli
-
Start the Expo server:
expo start
This will open the Expo Developer Tools in your browser. You can run the app on a physical device via the Expo Go app or use an emulator.
To start the Socket server:
-
Open a terminal and navigate to the
socket/
directory. -
Install dependencies:
npm install
-
Start the server:
npm start
This will start the WebSocket server, typically accessible at ws://localhost:3000
.
To set up PostgreSQL with pgAdmin4 for Agrologer:
-
Install PostgreSQL and pgAdmin4:
- Download and install PostgreSQL from the official website.
- Download and install pgAdmin4 from the pgAdmin website.
-
Create a PostgreSQL Database:
- Open pgAdmin4 and connect to your local PostgreSQL server.
- Right-click on the "Databases" node and select "Create" → "Database".
- Name the database (e.g.,
agrologer_db
).
-
Set up a Database User:
- Under the "Login/Group Roles" node, create a new user (e.g.,
agrologer_user
). - Assign a password and ensure the user has the necessary privileges (e.g.,
CREATE
,CONNECT
,SELECT
, etc.).
- Under the "Login/Group Roles" node, create a new user (e.g.,
-
Configure Connection in
.env
:-
Update your
server/.env
file with the following variables based on your PostgreSQL setup:DB_USER=agrologer_user DB_PASS=your_password DB_NAME=agrologer_db DB_HOST=localhost
-
-
Migrate Database:
- If you are using an ORM like Sequelize or TypeORM, ensure that you run migrations to set up your database schema.
By following these steps, you can successfully run each part of the Agrologer system on your local machine and set up PostgreSQL with pgAdmin4 for database management.