Metadata-Version: 2.1
Name: Agrothon
Version: 1.2.5
Summary: A Farm Monitoring Bot
Home-page: https://github.com/viswanathbalusu/agrothon
Author: viswanathbalusu
Author-email: ckvbalusu@gmail.com
License: GPL3.0
Platform: any
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: License :: OSI Approved :: GNU General Public License (GPL)
Classifier: Operating System :: POSIX :: Linux
Classifier: Development Status :: 5 - Production/Stable
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: pyrogram (==1.2.9)
Requires-Dist: tgcrypto (==1.2.2)
Requires-Dist: motor (==2.4.0)
Requires-Dist: fastapi[all] (==0.64.0)
Requires-Dist: requests (==2.25.1)
Requires-Dist: python-dotenv (==0.17.0)
Requires-Dist: aiohttp (==3.7.4.post0)
Requires-Dist: python-telegram-bot (==13.5)
Requires-Dist: pandas (==1.2.4)
Requires-Dist: numpy (==1.19.5)
Requires-Dist: tensorflow (==2.4.1)
Requires-Dist: prettytable (==2.1.0)
Requires-Dist: opencv-python (==4.5.1.48)
Requires-Dist: pillow (==8.2.0)
Requires-Dist: seaborn (==0.11.1)
Requires-Dist: Keras (==2.4.3)
Requires-Dist: scikit-learn (==0.22.2.post1)
Requires-Dist: telegraph (==1.4.1)
Requires-Dist: psutil (==5.8.0)

<div align="center">
<h1>Agrothon</h1>
<h3>A Farm Monitoring Bot</h3>
<a href="https://pypi.org/project/Agrothon"><img alt="PyPI" src="https://img.shields.io/pypi/v/Agrothon?style=for-the-badge"></a>
<img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/Agrothon?style=for-the-badge">
<img alt="PyPI - Wheel" src="https://img.shields.io/pypi/wheel/Agrothon?style=for-the-badge">
<img alt="PyPI - Implementation" src="https://img.shields.io/pypi/implementation/Agrothon?style=for-the-badge">
<img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dm/Agrothon?style=for-the-badge">
<a href="https://github.com/viswanathbalusu/Agrothon/blob/main/LICENSE"><img alt="GitHub license" src="https://img.shields.io/github/license/ViswanathBalusu/agrothon?style=for-the-badge"></a>
<a href="https://github.com/ViswanathBalusu/agrothon/issues"><img alt="GitHub issues" src="https://img.shields.io/github/issues/ViswanathBalusu/agrothon?style=for-the-badge"></a>
<a href="https://github.com/ViswanathBalusu/agrothon/network"><img alt="GitHub forks" src="https://img.shields.io/github/forks/ViswanathBalusu/agrothon?style=for-the-badge"></a>
<a href="https://github.com/ViswanathBalusu/agrothon/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/ViswanathBalusu/agrothon?style=for-the-badge"></a>

</div>

## Introduction
- This project has three parts
   - The [Agrothon-Client](https://github.com/viswanathbalusu/Agrothon-Client) Module which will be running in Raspberry Pi
   - API Server
   - Telegram Bot

- API Server handles Everything, All the routes are shown below

  ![API Docs](.github/Apiserver.png?raw=true)
- Telegram bot is just a frontend for the whole Project

  ![Telegram Bot](.github/telegrambot.png)
- [Agrothon-Client](https://github.com/viswanathbalusu/Agrothon-Client) Sends Sensor data, Intruder images to the API Server which will be analysed there and Stored in the Database

## Installation
- Via **pip** 
  - First fill the variables in `agrothon-sample.env` and rename it to `agrothon.env`
  - you can extend all tha variables from [Base Config](agrothon/BaseConfig.py)
  - Get the latest [Release](https://github.com/viswanathbalusu/Agrothon/releases/latest/download/Agrothon-Data.tar.gz) of data directory and untar in it the same directory where you placed `agrothon.env`

      ```
      tar -xzf Agrothon-Data.tar.gz
      ```
  - Then Create a Virtual Environment (Optional but Recommended) and then install Agrothon with

      ```
      pip install Agrothon
      ```
  - There are two commands in Agrothon
    - `agroserver` - Which actually starts the Uvicorn Server on a Unix Domain Socket at `/usr/agrothon.sock`, So you should use a Reverse proxy (Preferably Caddy)
    - `agrothon` - Which starts the telegram bot

- Via **Docker**
   - Download [Docker compose](./docker-compose.yml) and Map the ports according to your use
      - ```wget -q https://viswanathbalusu.github.io/Agrothon/docker-compose.yml```
   - Download [agrothon.env](./agrothon-sample.env) and Fill the Variables (can be extended from [Base Config](agrothon/BaseConfig.py))
      - ```wget -q https://viswanathbalusu.github.io/Agrothon/agrothon-sample.env -O agrothon.env```
   - Finally do `docker-compose up` it will pull the image from container registry and run the services 

## Variables in `agrothon.env`

| Variable | Value | Example | Required | Description |
| :---: | :---: | :---: | :---: | :---: |
| - | - | Bot Configuration | - | - |
| TELEGRAM_APP_ID | Telegram API APP ID | 1234567 | True | Can be obtained from [Telegram](https://my.telegram.org/auth) |
| TELEGRAM_API_HASH | Telegram API Hash | 022d29afxxxxxxxxf825980a7974ec42 | True | Can be obtained from [Telegram](https://my.telegram.org/auth) |
| BOT_TOKEN | Telegram Bot Token | 123456:abcdefghij | True | Can be obtained from [Bot Father](https://t.me/botfather)
| API_BASE_URL | Api base Host URL | https://mysite.com/ | True | Must be host Without port (i.e Port 80/443* only) |
| ALERT_CHANNEL_ID | Alert channel ID | -100123456789 | True | Intruder Alerts will be posted to this channel |
| STATE | name of the state | Andhra Pradesh | True | Must be a state in India 🤔|
| DISTRICT | name of the district | East Godavari | True | name of your district |
| DEF_LANG | Default Language | english | False | Can be choosen from `english`, `telugu`, `tamil`, `hindi` (Default is `english`)|
| DEF_CITY | Default City | Vijayawada | True | City from which weather should be fetched |
| - | - | Server Configuration | - | - |
| OPEN_WEATHER_API | Open weather API Key| d6778a1acdd67c4xxxxxxe500e81987d | True | API to get the weather data of a particular region, Get this from [OpenWeather](https://openweathermap.org/api)|
| API_KEY | An API Key for your Server | Agrothon | True | This is like a Password for your API Server, So choose Wisely (Alphanumeric only) |
| DB_URL | MongoDB URL | mongodb+srv://xxx:xxx@hmmm.mongodb.net | True | Database to Store All the data, get this from [MongoDB](https://mongodb.com) |

  `* if there are Other ports too the Bot will Work but it may not be able to post images`

## Note
- We are using heavy modules like tensorflow and Yolov3, so make sure you have atleast 2.5GB RAM free to get this running

