GSoC Coding Phase 1 in one glimpse

Microfarm For Everybody | WeField e.V. | coala e.V.

Hello everyone! This blog will give you all a short summary of all the achievements we have achieved till date and of the milestones for the GSoC Coding Phase 1. Here is the link to the project’s codebase on GitLab. The programming stack we have used so far are Django, Rest Framework, Celery, Celery-beat, Django All-auth. Still a lot more to achieve and we will surely achieve them!!

Milestones of Phase 1:

Listed below were the milestones for our project before the coding phase 1 and we were successfully able to complete them within the allotted time.

  • Project setup
  • Setting up a user login system
  • Implement database and schemas
  • Implement script to calculate the crop map and compost required
  • Implement weather and forecast API and script to check if watering is required or not?
  • Implement watering tasks
  • Implement daily tasks

1. Project Setup

  1. We discussed and created the Business Model Canvas to understand the project precisely.
  2. Structured the codebase such that other models like agroforestry, etc., can be easily mounted.
  3. Used `black` formatter to maintain the code standards and set up Gitlab CI for linting with the same.
  4. Related Merge Requests/Issues: business-model-canvas, project-setup, ci-linting

Challenges and new things learned:

  • Importance of Business Canvas Model
  • How to structure a project?

3. User Authentication System

  1. Added JWT (JSON Web Token) based auth system because the backend is meant to be separate from the frontend.
  2. Implemented social authentication — Google, Facebook, and Twitter for easy login
  3. Related Merge Requests/Issues: user-login-system

Challenges and new things learned:

  • JWT based auth system
  • Social-auth implementation

4. Schemas for Database

  1. We felt the need for a wireframe of our application to design the schemas. Thus created wireframe.
  2. With a clear picture of the application, we implemented the schemas.
  3. Related Merge Requests/Issues: wireframe, schemas

Challenges and new things learned:

  • Wireframing
  • Creating the relational schemas

5. Cropmap & Compost Required script

When we create the market garden object, having crop-map parameters and save it, the script takes the parameters and returns the optimum dimensions and compost required, and fills the database.

Challenges and new things learned:

  • Doing the math that will satisfy all the conditions of the crop-map
  1. First, we decide the arrangement of the bed i.e. along the length or width so that we are using maximum space leaving no unused space. So for that, we calculate parameters for both the arrangement.
Arrangement of Beds

2. After we have parameters, we calculate the number of sections obtained and the area used. The arrangement which has at least minimum sections decided and the maximum area is the best arrangement.

3. Thus we then return the best parameters and compost requirements on the basis of our calculated area used and parameters.

6. Weather and Forecast API

  1. The implemented script that checks the weather and all the conditions mentioned in the database for watering is required or not?
  2. Using Openweather APIs free credits using a student account
  3. Related Merge Requests/Issues: weather-forecast-api

These APIs are required for the watering task. Let’s understand it with an example. Suppose we are watering our garden every evening at 6 pm. But in the monsoon season when there is rain, we don’t water right! So, with this Weather API, we check every hour the rain conditions and with Forecast API, we can check if it is going to rain in few hours or not? Thus, we can make real-life decisions for the watering tasks. We are using Current Weather data and Hourly Weather Forecast APIs for weather and forecast for the rain!

Challenges and new things learned:

  • Deciding the watering rules

7. Implement Watering Tasks

  • Watering task is the task to water the market garden.
  • For the watering task, we need to check rain for every hour and update our database field of “last watered at”.
  • Check every 6 pm about the weather and forecast and decide watering is required or not?
  • Implemented using celery. Implemented periodic jobs of “hourly weather check” and “check to watering required” at every 6 pm of the respective timezone of the user.
  • Timezone is fetching through a free API service namely TimezoneDB using geographic co-ordinates i.e., latitudes and longitudes provided by the user.
  • Related Merge Requests/Issues: watering-tasks

Challenges and new things learned:

8. Implement Daily Chores

It is the list of tasks to be done by users on daily basis. For e.g., opening and closing the polytunnel, etc. The schemas were already set up while creating the schemas.

Thus, we completed coding phase - 1 successfully. With a lot of discussions, reviews and brainstorming, we managed to shape the project as it was planned. Still more improvements and work going on!!

Thank you for reading the blog until here!! Subscribe and stay tuned for more details, project features, and updates!!

Student Developer @WeField @coala | Cloud Enthusiast | Open-Source Contributor | NIT Surat