Uploaded by Parth Gandhi

A DESIGN PROJECT REPORT

advertisement
KRISHI SADHAN
PLATFORM FOR FARMERS
FOR RENTING EQUIPMENTS
A DESIGN PROJECT REPORT
Submitted by
MD DILSHAD
(730920104066)
PARTH GANDHI
(730920104079)
RAUSHAN KUMAR
(730920104093)
VISHAL KUMAR
(730920104127)
in partial fulfilment for the award of the degree
of
BACHELOR OF ENGINEERING
in
COMPUTER SCIENCE AND ENGINEERING
EXCEL ENGINEERING COLLEGE (AUTONOMOUS)
KOMARAPALAYAM-637303
ANNA UNIVERSITY::CHENNAI 600 025
NOVEMBER 2023
EXCEL ENGINEERING COLLEGE (AUTONOMOUS)
KOMARAPALAYAM-637 303
ANNA UNIVERSITY: CHENNAI-600 025
BONAFIDE CERTIFICATE
Certified that this project report “KRISHI SADHAN - PLATFORM FOR
FARMERS FOR RENTING EQUIPMENTS” is the bonafide work of “MD
DILSHAD [730920104066], PARTH GANDHI [730920104079], RAUSHAN
KUMAR [730920104093], VISHAL KUMAR [730920104127]” who
carried out the design project work under my supervision.
SIGNATURE
SIGNATURE
Dr. P. C. SENTHIL MAHESH M.E., Ph.D.,
MR. S. PRAVEEN KUMAR M.Tech.,
HEAD OF THE DEPARTMENT
SUPERVISOR
Professor,
Assistant Professor,
Department of CSE,
Department of CSE,
Excel Engineering College,
Excel Engineering College,
Komarapalayam-637 303
Komarapalayam-637 303
Submitted for the Design Project Examination held on ………………….
Internal Examiner
External Examiner
ACKNOWLEDGEMENT
Behind every achievement lies an unfathomable sea of gratitude to those who
actuated it, without them it would never have into existence. To them, we lay word of
gratitude imprinted within ourself.
We wish our heartfelt thanks to respected Founder and Chairman of Excel Group
of Institutions Prof. Dr. A. K. NATESAN, M.Com., M.B.A., M.Phil., Ph.D., FTA and
Vice Chairman Dr. N. MATHAN KARTHICK M.B.B.S., M.H.Sc (Diabetology) for
allowing us to have the extensive use of the college facilities to do our design project
effectively.
We express our sincere gratitude and heartfelt thanks to the respected Principal
Dr. K. BOMMANNARAJA M.E., Ph.D., for his encouragement and support to
complete the design project.
We would like to express our profound interest and sincere gratitude to the Head
of the department Dr. P. C. SENTHIL MAHESH M.E., Ph.D., Department of
Computer Science and Engineering for his encouragement and support to complete the
design project.
We are privileged to express our deep sense of gratitude to our Project Supervisor
Mr. S. PRAVEEN KUMAR M.Tech., Assistant Professor, Department of Computer
Science and Engineering, who gave guidance and support throughout our work and
made this as a successful design project.
We would like to express our sincere gratitude and heartfelt thanks to our Project
Coordinator Mrs. J. OBURADHA M.E., Assistant Professor, Department of Computer
Science and Engineering for her continuous help over the period and creative ideas for
this phase of our design project work.
Finally, I thank the almighty, all my Staff Members, Parents, Friends and wellWishers for the moral support throughout the design project.
ABSTRACT
KRISHI-SADHAN, a MERN Stack Web Application designed to
revolutionize agriculture by addressing the intricate challenges faced by farmers.
This transformative platform facilitates the seamless exchange and short-term
rental of agricultural equipment, fostering a collaborative ecosystem among
farmers. Leveraging React.js, Node.js, Express.js, and MongoDB, the system
offers an intuitive and responsive interface, ensuring accessibility for users across
diverse technological landscapes. The core objectives of Krishi-Sadhan encompass
simplifying equipment exchange, enabling short-term rentals, fostering community
collaboration, and empowering farmers through modern technology. The project's
user-friendly interface goes beyond mere transactions, creating a dynamic
marketplace where farmers can share knowledge, optimize resources, and
contribute to sustainable agricultural practices. As Krishi-Sadhan embarks on its
journey, the potential for positive change within the agricultural community is
evident. By providing a comprehensive and secure platform, the project aims to
empower farmers, promote efficient resource utilization, and contribute to the
creation of a more connected and informed farming community. Krishi-Sadhan is
not just a technological endeavour, it symbolizes a vision for a more sustainable
and empowered future in agriculture, sowing the seeds of innovation for a resilient
agricultural ecosystem.
iii
TABLE OF CONTENTS
CHAPTER NO.
1.
2.
3.
TITLE
PAGE NO.
ABSTRACT
iii
LIST OF FIGURES
iv
LIST OF ABBREVIATIONS
v
INTRODUCTION
9
1.1
PROBLEM STATEMENT
9
1.2
OBJECTIVE
9
1.3
SUMMARY
10
LITERATURE SURVEY
11
2.1
IMPACT OF FARM MECHANIZATION
11
2.2
FUTURE OF FARM MECHANIZATION
12
SYSTEM REQUIREMENTS
14
3,1
INTRODUCTION
14
3.2
SOFTWARE AND HARDWARE
15
REQUIREMENTS
3.3
SUMMARY
16
4.
RESULTS AND DISCUSSIONS
18
4.1
REACT JS
18
4.2
REACT HOOKS
19
4.3
REDUX
20
4.3.1 REDUCERS
23
4.3.2 REDUX STORE
24
4.4
AXIOS
24
4.5
APPLICATION PROGRAMMING
INTERFACE
25
NODE JS
26
4.6.1 FEATURES OF NODE JS
28
4.7
EXPRESS JS
29
4.8
MONGODB AND MONGOOSE
30
4.9
POSTMAN
34
4.10
DEVELOPMENT ENVIRONMENT
4.6
5.
SETUP
35
4.11
VERSION CONTROL SYSTEM
35
4.12
VISUAL STUDIO CODE
36
4.13
JSON WEB TOKEN
36
CONCLUSION AND FUTURE WORK
38
5.1
CONCLUSION
38
5.2
FUTURE WORK
39
REFERENCES
JOURNAL
41
42
LIST OF FIGURES
FIGURE
NO
TITLE
PAGE NO
4.1
App module
18
4.2
A simple React component
19
4.3
A simple React hook component
20
4.4
A simple redux component
22
4.5
Redux State management
23
4.6
A simple Axios component
24
4.7
A simple web server
27
4.8
Example of a server build with Express.
30
4.9
MongoDB cluster
33
4.10
JWT to access the application server
37
iv
LIST OF ABBREVIATIONS
1.
API
:
Application Programming Interface
2.
ASYNC
:
Asynchronous
3.
DB
:
Database
4.
HTTP
:
Hypertext Transfer Protocol
5.
JS
:
JavaScript
6.
JSON
:
JavaScript Object Notation
7.
MVC
:
Model View Controller
8.
UI
:
User Interface
9.
VS
:
Visual Studio
v
CHAPTER 1
INTRODUCTION
1.1 PROBLEM STATEMENT
In contemporary agriculture, farmers face challenges in accessing and affording
modern equipment. Small-scale farmers often possess surplus machinery, while others
require specific equipment for short durations. Existing platforms lack a dedicated
solution for the exchange and short-term rental of agricultural equipment, hindering
resource optimization. This gap limits collaboration and knowledge sharing within the
farming community. The absence of a streamlined and secure platform hampers the
efficient exchange of agricultural equipment, hindering sustainable practices. "KrishiSadhan" addresses this issue by providing a user-friendly, secure, and collaborative
space for farmers to seamlessly exchange and rent agricultural equipment.
1.2 OBJECTIVES
• Simplify Equipment Exchange: Streamline the process for farmers to exchange
surplus agricultural equipment seamlessly.
• Enable Short-Term Rentals: Facilitate short-term rentals of specific machinery,
addressing financial constraints for farmers in need.
• Foster a Collaborative Community: Create a dynamic marketplace that
encourages farmers to collaborate, share knowledge, and optimize resources.
• Technological Empowerment: Utilize the MERN stack to provide a user-friendly
and responsive interface, ensuring accessibility for farmers with varying
technological backgrounds.
9
• Enhance Agricultural Efficiency: Contribute to a more sustainable and efficient
farming ecosystem by addressing gaps in equipment accessibility and fostering
collaborative practices.
• Promote Resource Optimization: Encourage farmers to optimize resources by
exchanging and renting equipment, promoting a more efficient use of agricultural
assets.
• Connect and Empower: Leverage technology to connect farmers, empowering
them with the tools and resources needed for a thriving agricultural community.
1.3 SUMMARY
Krishi-Sadhan, a MERN stack application, redefines agriculture by facilitating
farmers in equipment exchange and rental. Utilizing React.js, Node.js, and
MongoDB, the platform enables seamless interaction. Robust features include user
authentication, easy equipment listings, and a powerful search system for
efficient exchanges. The messaging system facilitates communication between
farmers for equipment rentals, fostering collaborative farming practices. KrishiSadhan is not just a technical solution; it's a commitment to empower farmers,
creating a dynamic marketplace that simplifies the process of exchanging and renting
agricultural equipment. It envisions a more connected and efficient farming
community, contributing to sustainable agricultural practices.
10
CHAPTER 2
LITERATURE SURVEY
In India, agricultural backwardness still exists in the 21st century. Many states fall in
this category except some States, like Punjab, Haryana, and Karnataka have maximum
adoption of farm mechanization in comparison to other states of India. This paper aims
to review the perspective of farm mechanization in India since independence. Farm
mechanization is divided into two parts. The first part is to use machines and advanced
mechanical tools in farm practices (Machine mechanization). The other is the usage of
High Yield Variety seeds, chemical fertilizers, and
pesticides (Chemical
mechanization). In the 20th century, with the inception of the tractor, agricultural
modernization had been initiated. Many tractors driven equipment have been innovated
since then, for example, Rotavator, disk harrow, cultivator, and others. Subsequently,
agricultural scientists and researchers have put forward chemical fertilizers and
pesticides for better yield. Karl Marx and his followers argued that, like manufacturing,
the economies of scale associated with agriculture with more mechanized agricultural
practice (Binswanger and Rosenzweig 1986). This review paper thus intends to
highlight the development of farm mechanization in totality. The paper is divided into
four themes, to study the mechanization in agriculture and its impact on production and
productivity”.
• Various initiatives by Government for Farm Mechanization
• Impact of Farm mechanization – The mechanical way
• Effect of Farm mechanization – The chemical way
• Future of farm mechanization
2.1 IMPACT OF FARM MECHANIZATION
In the last century, mechanical tools developed for farming gained popularity. Tractors
are one of the most critical developments in this section. After Independence, India
11
needs an accelerated method to make the economy self-sufficient in food grains. An
increase in production with the desired pace was not possible in the traditional way of
farming, mechanization was the only solution. Policy-makers were well aware of this
fact and many schemes of the government and focused the cooperative societies on farm
mechanization since the ’50s. Punjab leads the agricultural development in India, and
the adoption of farm mechanization took place at a higher rate. The need of the farmers
led to the development of machinery, i.e., agriculture became more mechanized and
increased productivity (Gyanendra 2000). During the ‘90s, the adoption of new
technology revolved mainly around the concept of increasing productivity per unit time,
and this lead to an increase in dependency for power (energy input). The farmers, mostly
in Punjab, adopted mechanization and started intensive use of machinery like tractors
and allied implements. Use of tractors for convenient operation related to plowing,
harvesting was the need of the hour along with the use of HYVs. The use of tractor was
one of the essential farm practices.
Nevertheless, some of the studies, like Sapre (1969) and Binswanger (1978) revealed
that it leads to the displacement of workers. In contrast, farmers reported reduction in
cost related to weeding, ploughing, and transportation with tractors, other equipment
and machines like power tillers, combine harvesters etc. These are the frontline of farm
mechanization, and government provides assistance for purchase of machinery. There
are two different views in the usage of tractors, the antagonist claimed that use of tractors
would displace the labour force and on the other hand protagonist state that use of
tractors would increase the practice of diversification and intensive cropping which
would not only displace labour but also shift laboured it is helpful to create more
employment (Dixit and Bhardwaj 1990). The other reason for mechanization is the
socio-economic aspect, which has two sets of ground reality. One of the socio-economic
issues states that it will increase farm efficiency and productivity through the laborsaving technique (Murali, and Balakrishnan 2012). The other view is that technology
helps to reduce the drudgery of women, who are burdened disproportionately as
compared to men on farms (Kishtwaria, and Rana 2012).
12
2.2 FUTURE OF FARM MECHANIZATION IN INDIA
The early introduction and hands-on acceptance of farm mechanization by large
farmers, as a response to rising labor costs, mark the difference in productivity (Foster
and Rosenzweig, 2010). Today, the farm size is significant and has a direct relationship
with mechanization. Farms throughout in India are predominantly small. Indian
agriculture comprises of 83.3 percent of small and marginal farmers. As per Agricultural
Census 2018, there were about 145 million agricultural holdings in India in 2015-16.
Around 125 million were small and marginal farmers. The Average size has declined
from 2.3 ha. (1970-71) to 1.41 ha. (2015-16). Thus, there were significant land
inequalities in India, which persist till date. So, it is better to utilize it as a strength.
Therefore, the future of sustainable agricultural growth in India mainly would depend
on marginal and small farmers.8 One of the studies by Lipton (2006) recognized the role
of small farms in development and poverty reduction. The global experience of growth
and poverty reduction shows that GDP growth originating in agriculture is at least twice
as effective in reducing poverty as GDP growth originating outside agriculture (WDR,
2008).9 Small holdings play an essential role in raising agricultural development and
poverty reduction. The first step should be the identification of hindrance in the
adoption of farm mechanization, especially for small and marginal farmers. Some of
them are land size, affordability to mechanization, absence of access to the credit
market, and lack of low capacity machines, and equipment.
13
CHAPTER 3
SYSTEM REQUIREMENTS
3.1 INTRODUCTION
Requirement analysis is an essential part of product development. It plays an
important role in determining the feasibility of an application. Requirement analysis
defines the software and hardware necessities that are required to develop the product
or application. Requirement analysis mainly consists of software requirements,
hardware requirements and functional requirements.
Software requirements: This mainly refers to the needs that solve the end user problems
using the software. The activities involved in determining the software requirements
are:
1. Elicitation: This refers to gathering of information from the end users and customers.
2. Analysis: Analysis refers to logically understanding the customer needs and reaching
a more precise understanding of the customer requirements.
3. Specification: Specification involves storing the requirements in the form of use
cases, user stories, functional requirements and visual analysis.
4. Validation: Validation involves verifying the requirements that has been specifies.
5. Management: During the course of development, requirements constantly change
and these requirements have to be tested and updated accordingly.
Hardware requirements: Hardware requirements are the physical aspects that are needed
for an application. All the software must be integrated with hardware in order to complete
the development process. The hardware requirements that are taken into account are:
1. Processor Cores and Threads
2. GPU Processing Power
14
3. Memory
4. Secondary Storage
5. Network Connectivity
3.2 HARDWARE AND SOFTWARE REQUIREMENTS
Server:
Multi-core processor (e.g., quad-core or higher) for optimal performance.
Minimum 8 GB RAM (16 GB or more recommended) to handle concurrent requests
efficiently.
Adequate storage space for application files, logs, and database storage.
Database Server:
Sufficient CPU and RAM resources to handle database queries and transactions.
Allocate appropriate disk space for MongoDB data storage.
Client Devices:
Standard personal computers, laptops, tablets, or mobile devices with modern web
browsers for accessing the Krishi-Sadhan application.
Software Requirements:
Operating System:
Server: Windows or Linux-based OS (e.g., Ubuntu, CentOS) for Node.js and Express.js
deployment.
Development Machines: Windows, macOS, or Linux for developers working on the
codebase.
Node.js and npm:
15
Install the latest stable version of Node.js and npm on the server and development
machines.
Express.js:
Utilize the Express.js framework for building the backend server.
React.js:
Develop the frontend using React.js library.
MongoDB:
Set up the MongoDB database server to store user data and equipment listings.
Mongoose:
Install Mongoose as an ODM (Object Data Modelling) library for MongoDB and
Node.js.
Web Browser:
Support for the latest versions of popular web browsers such as Google Chrome,
Mozilla Firefox, Safari, and Microsoft Edge.
Additional Tools:
Version control system (e.g., Git) for collaborative development.
Code editor (e.g., Visual Studio Code, Sublime Text) for coding.
3.3 SUMMARY
Requirement analysis is an essential part of product development. It plays an important
role in determining the feasibility of an application. By analyzing the different
requirements for a system, a concrete plan of action can be designed. The software and
hardware requirements can limit the system if not carefully listed down.
16
They have to be compatible with each other to complete integration of the system to
deliver the final product. These requirements are a quantitative measure of the system.
The user demand is met by breaking down the high-level tasks to requirements, which
help in the task of system designing providing clear goals. The functional and nonfunctional requirements help measure the system operations. The functional
requirements describe the operations that a system has to perform. These can include
tasks such as pre-processing, data extraction and evaluation. The non-functional
requirements perform the task of measuring of how well the system executes these
operations. It assesses the system based on how reliable, accurate and user friendly it is.
Requirement analysis is hence an important task before the start of any project.
17
CHAPTER 4
SYSTEM DESIGN
As briefly discussed above MERN stack consists of four independent frameworks and
libraries, MongoDB, ExpressJS, ReactJS and NodeJS which supports MVC architecture
to make the development process flow smoothly. MongoDB plays a role for database
management, while NodeJS and Express are used for building routes and APIs in the
backend and ReactJS is used in the frontend. The connection between them is made
(The Modern Application Stack – Part 1: Introducing The MERN Stack | MongoDB
Blog, 2020). Each of the technology is used to develop an application and each
technology will be explained in deep in the coming chapters.
Figure 4.1 App module.
4.1 REACT JS
React is one of the most widely used open-source, declarative, efficient, and componentbased JavaScript libraries that helps to build interactive UI where all the components
are reusable and can be applied for multiple projects. It was developed by Facebook's
engineer and is continuously handled and updated by Facebook and the users around
18
the globe. React is mainly concerned with re-rendering data of the DOM. It requires
additional libraries for the management, route handling and API interaction.
Comparing with another front-end framework i.e. Angular, React uses views that make
code more predictable and easier to debug. It also helps to update DOM efficiently and
render the right components when the data changes.
Figure 4.2 A simple React component.
The above snippet Figure 6 implement a render() method that takes input data and
renders the display. A div tag with the content of plain text "Hello, John" will appear in
a DOM-element with the id "mydiv". The above code uses an HTML like syntax called
JSX which is a syntax extension to JavaScript. Input data that is passed into the
component can be accessed by render () via this.props() (Elboim, 2017).
React components are small, reusable pieces of code. They return a React element to be
rendered to the page. It is also a normal JavaScript function that takes input or props
which is mean to be properties. Components can return other components, arrays,
strings, and numbers and, can be either functional or class-based, with or without states.
19
Normally, functional components do not have any states in them while stateful
components can holds states and pass on properties to the child-components. Class
components can have lifecycle methods and hence they can make changes to the UI and
data. There is a rule that is applied for writing component names. The component name
should always start with a capital letter (Elboim, 2017).
4.2 REACT HOOKS
Hooks were introduced to React in version 16.8 that enable the execution of custom
code in a base code. Reacts Hooks are special functions that allow to “hook into” its
core features. It provides an alternative to write class-based components by allowing to
handle state management from functional components.
Even though component-oriented architecture allows reusing views in the application,
one of the biggest issues a developer meets us how to use the logic located in the
required component state between other components. Where there are components with
similar state logic, but no good solutions to reuse the logic, the code in the constructor
and life cycle methods can be duplicated. To fix this developer usually use high-order
components and render props (Introducing Hooks – React, 2020).
Hooks are aiming to solve the issues allowing writing functional components which
have access to state, context, lifecycle methods, refs etc. without writing React Classes
(Introducing Hooks – React, 2020). An example of React hooks can be observed in
Figure 5.
20
Figure 4.3 A simple React hook componenet.
In the above code, the class Component is replaced with a functional component, the
local state is removed and instead the new “useState” function is used. Hooks are used
in functional component to use state, useState() hook is used, while to replace life cycle
methods like componentDidMount() or componentDidUpdate(), useEffect() hook is
used.
4.3 REDUX
As the data is stored in states among components in React, handling big scale
application data becomes difficult and gets complicated. These states can include server
responses and data, as well as locally created data. UI state is also increasing in
complexity, so as we need to manage active routes, selected tabs, spinners, pagination
controls and so on. To tackle all the big complications Redux is applied (Redux, 2020).
Redux is composed of 3 core principles; state to store necessary data, action to dispatch
changes made to the state and a reducer to make changes. When a user creates an event,
21
actions are dispatched to the central store. Actions are the only information that the store
receives from the user. This makes reducers fire a method on the previous state
depending upon the action received from the store. It also decides the fate of the old
state.
App's state is mainly described as a plain object. For example, the state of people is
presented below.
Figure 4.4 A simple redux component.
As states in redux are changing, an action is dispatched containing the payload and
reducer takes the role of making the changes to our state. All the state in an application
is stored in Redux as a single object. Reducers take an action and decide what method
to be implemented or deleted depending upon the action that is being dispatched. This
is the only way the new state gets produced every time (Redux, 2020).
Since, the data is stored as states among components in React, handling big scale
application data becomes difficult. So to tackle that ambiguity, Redux was made. Redux
manages the states in JavaScript applications. Even though React has brought their own
state management tools in the form of hooks, Redux being old practise and stable one
22
at that, this tool was chosen for this project. It can also be used for other JavaScript
frameworks and libraries, like Angular and Vue. It is itself extremely lightweight at
memory size 2KB with all the dependencies, so it doesn’t quite increase the total
applications asset size. It was inspired by Facebook’s Flux and Elm to simplify the MVC
structure, specifically the Model and View relationship when the application size is
scaled higher. It is modelled on functional programming concept. Redux allows us to
store all the states in one store and components can fetch them when required. Like other
frameworks, react comes with internal state management system as well. It is not fully
stable during the creating of this project as well as it is also good at only handling smaller
scale application with smaller number of states across smaller components. With larger
applications state management is better with Redux. When an app has components that
share states or data, a separate handler or store for state to live in would be a great idea.
Hence Redux implements that logic in providing states among components without
linearly depending on the hierarchy. Generally, state has to live in the parent component
in React for children to fetch, so ideally sibling components can’t access the states
among them. From parents to child it has to be passed on as props while Redux allows
direct access to the central store, from where you can fetch all the current states.
Figure 4.5 Redux State management
23
4.3.1 Reducers in Redux
Reducers govern how the state of an application is changed upon an action is dispatched
containing a payload. All the application state is stored in Redux as a single object.
Reducers takes an action and decide what method is to be fired depending upon the
action that was dispatched. Hence a new state is produced every time. Just like
array.reduce in javascript, reducers take one object and one call back and return one
object or array at the end, hence its called reducer. Same object or state passed through
reducers callback yields the same new state every time because no additional callback
is applied since they are usually passed as action conditions. Instead of mutating the old
state a new state is created by the reducers plain functions.
4.3.2 Redux Store
A store is an immutable object tree in Redux. A store is a state container which holds
the application's state. Redux can have only a single store in your application.
Whenever a store is created in Redux, you need to specify the reducer. Let us see how
we can create a store using the createStore method from Redux.
The Redux store is the equivalent of a state tree. The only way the state tree is updated
is by dispatching an Action which passes an object to the Reducer and returns a new
state. By ensuring data is manipulated in this fashion, the logic of the application
becomes easier to manage and reason with especially when a large number of UI
elements are changing (often the case in large web application). Furthermore, the
application is more predictable and debugging is a matter of logging the state tree which
is considered the single source of truth in a unidirectional data flow architecture. If the
application is not behaving the way it is expected to behave, the logged state tree most
likely will be incorrect (can be caused by an erorr in the Reducer logic).
24
4.4 Axios
Figure 4.6 A simple Axios component.
In the above figure Axios library is used. Axios is a very popular JavaScript library you
can use to perform HTTP requests, that works in both Browser and Node. js platforms.
It supports all modern browsers, including support for IE8 and higher. It is promisebased, and this lets us write async/await code to perform XHR requests very easily. The
link passed by the user will update automatically the user will not need to refresh the
page again and again.
Axios is a famous JS library that allows performing HTTP requests in both computers
via NodeJS and directly on browsers. It is supported by majority of browsers and is a
better alternative for reacts own Fetch API. Axios is promise based library which
enables performing asynchronous XHR requests.
Axios over native Fetch API comes with a lot of perks, some are listed below
1. Axios supports older browsers without the need of polyfill unlike fetch.
2. It has a way to abort a request as well set response timeout
3. Has a in-built CSRF protection and includes upload progress
4. Allows JSON data transformation and most importantly works with node
25
4.5 Application Programming Interface (API)
While web browsers are powerful and allow ever more complex tasks to be executed on
the client, certain types of tasks must be handled by the server for security or efficiency
reasons. In this case the client will call an endpoint (similar to calling a method in a
program) which is exposed by the server. This is called a request and can include various
request parameters and a payload. The server which is listening to requests on its
endpoints, will then respond by performing the requested tasks and return a response
object.
4.6 NODE JS
Node.js is the currently most popular open-source web server environment that allows
JavaScript code to be able to run outside of web browsers. It creates a dynamic web
page by helping JavaScript to write command-line tools and server-side scripting before
the page is sent to the user's web browser (Express/Node introduction, 2020). Node.js
is suitable for the foundation of a web library or framework because it has an HTTP a
first-class citizen in Node.js, designed with streaming and low latency. It uses a Google
Chromes v8 engine to execute the JavaScript. NodeJS, in general, makes developing
cross-platform, server-side and networking applications much easier (Chettri, 2016).
Node has earned a good reputation in the tech industry in a short period. It plays a big
role in the technology stack of high-profile companies who depend on its unique
benefits. Microsoft Azure users are provided with end-to-end JavaScript experience for
the development of a whole new class of real-time applications. The locking and
concurrency issues of eBay were freed by Node’s multi-threaded asynchronous I/O. The
entire mobile software of LinkedIn is completely built-in Node (Martonca, 2015).
26
PayPal after shifting to Node from Java for their existing projects saw significant
improvements over Java. The re-written app using Node was delivered in half the time
with less manpower and fewer lines of code. Hence, PayPal saw their development and
product performance increase dramatically after switching to Node from Java
(Anderson, 2014). One great advantage of NodeJS is the event-driven architecture
which allows program code to be executed asynchronously. The most common tasks for
servers include answering queries, storing data in a database, reading files from hard
drive, and establishing connections to other network components. All these actions are
grouped together under the category I/O. In a programming language like C and Java,
I/O is executed synchronously. This means that tasks are performed one at a time and
moves to the next task after completion of the first task. However, Node uses an
asynchronous I/O, with which read and write operations can be delegated directly to the
operating system or database. This makes possible for many I/O tasks to be carried out
parallel to one another, without any blockage. In some cases, this can prove to be a great
advantage when it comes to the speed of the NodeJS and JavaScript-based applications.
NodeJS also provides tools and functions like NPM and “require”, that help to manage
third party libraries like Mongoose and Express to make the development faster and
efficient. NPM is the default package manager which comes with the Node
environment. Such tools help to load inbuilt node modules into the applications (Chettri,
2016).
27
Figure 4.7 A simple web server.
In the above code, a request is made to the server. When the code runs, the message
“Server is running on port 3001” is displayed in the console. When visiting the browser
address http://localhost:3001: “Hello World” message is displayed (Full stack part3 |,
2020).
Node.js makes use of event driven, non-blocking I/O model to execute requests. Nonblocking, I/O model makes node asynchronous. The flow of the programs is defined by
the events taking place. JavaScript uses single threaded event-loop, multi-threaded
processes can’t be executed. Hence, node has to execute multiple threads in parallel
without waiting on every event. Below is an example of what blocking vs nonblocking
I/O model looks like. Node also provides tools and functions like NPM (node package
manager) and require, which help managing third party libraries like Mongoose and
Express to make development faster and efficient. NPM is the default package manager
which comes bundled with the Node environment. These tools also help load inbuilt
node modules into respective applications. Node modules are blocks of codes that can
28
be used where needed but when not loaded do not impact the application codes.
Developers can also build their own modules for personal use and for the community.
4.6.1 Features of Node.js
1. Extremely fast: Node.js is built on Google Chrome's V8 JavaScript Engine, so its
library is very fast in code execution.
2. I/O is Asynchronous and Event Driven: All APIs of Node.js library are asynchronous
i.e. non-blocking. So, a Node.js based server never waits for an API to return data. The
server moves to the next API after calling it and a notification mechanism of Events of
Node.js helps the server to get a response from the previous API call. It is also a reason
that it is very fast.
3. Single threaded: Node.js follows a single threaded model with event looping
4. Highly Scalable: Node.js is highly scalable because event mechanism helps the server
to respond in a non-blocking way.
5. No buffering: Node.js cuts down the overall processing time while uploading audio
and video files. Node.js applications never buffer any data. These applications simply
output the data in chunks.
6. Open source: Node.js has an open source community which has produced many
excellent modules to add additional capabilities to Node.js application.
4.7 EXPRESS JS
Express is a Node.js web application framework that boosts the features of web, mobile
API applications, and APIs. Many libraries have been developed to ease sever side
development with Node, by far the most popular intended library for this purpose is
29
express. The third-party middlewares are installed to extend the functionality of the
express application and add features as required (Fullstack part3 , 2020).
In Express middleware is executed from top to bottom in the request-response cycle.
Each middleware has access to the request and the response object as well as a next
function which are passed from one middleware to another. The middleware takes the
request, executes the code inside, changes the request and response objects and calls the
next function which activates the next middleware in the queue. An express application
can have access to the application-level middleware, router-level middleware, errorhandling middleware, built-in middleware, and third-party middleware. In applicationlevel middleware app.use() and app.method() functions are used where ‘method’ is an
HTTP verb that is being executed. The router-level middleware is bound to an instance
of the express router. Error-handling middleware is around the object and takes four
arguments, error, request, response, and next objects. “Express.static” and
“express.json” files are served statically and parse the incoming request to JSON
respectively in built-in middleware. Different functionality of the express application
can be extended either by logging in the information about the incoming request or
parsing the cookies (Fullstack part3, 2020).
Furthermore, routers in express divide the application into several mini express
applications and combine to form an express application. The express server is
composed of an HTTP verb (GET, POST, PUT, DELETE). The same server creation
from the above code (Figure 7) can also be done with express. In express callback
functions are specified to the routing where callback functions can be used as arguments.
Callback functions are called by using the next() method to move on to another callback
function.
30
Figure 4.8 Example of a server build with Express.
This report demonstrates more about express in the development phase for adding
different functionalities like building the routes APIs, use of all the HTTP verbs and for
user authentication.
4.8 Mongo DB and Mongoose
Mongo DB
MongoDB is an open-source, cross-platform database that encompasses a wide variety
of different database technologies designed to fit into modern applications. MongoDB
uses JSON like files schemas, meaning data are stored as documents or collections
which can be strings, numbers, floats and even arrays and objects. MongoDB is also
known as NoSQL database; it allows the insertion of data without interrupting the
service and provides the real-time application changes. Due to the vast complexity in
web development and usage, the relational database cannot cope with the scale and
agility challenges of modern applications. When comparing relational database to
NoSQL, the NoSQL database has better performance and is more scalable. In this thesis,
there is the use of the NoSQL database, which is MongoDB for the fast development,
code integration and for less database administrator time (MongoDB System Properties,
2020).
31
Despite having so many advantages, MongoDB also has some drawbacks, as MongoDB
stores key names for each value pairs due to no functionality of joins there is data
redundancy which results in unnecessary consumption of memory. There is a limit for
document size not to exceed 16MB. Also, the nesting of documents is not allowed to
have more than 100 levels. However, the ability to store any kind of data without
structuring any rule, governing the relation can be a strength at times. Applications can
be built using any platforms and provide the preferred data-structure (MongoDB System
Properties, 2020).
Among other big MongoDB features, auto sharding data to horizontal scaling and
replication of data among multiple servers for higher reach are the most developer
friendly assets. All the data are stored as documents, therefore horizontal scaling allows
data as documents to be stored at many different servers and locations, efficiency will
be the optimum than having a single machine handle all the valuable user information.
More machines means more space to support data growth and most importantly to
maintain efficient read-write operations. Which also allows storing higher scaled
information, when the start-up starts taking pace. Similarly, replication of the data
prevents the chances of data-loss since the data is stored in multiple servers. When one
server fails, the data still could be fetched from the replica. Highly efficient and higher
scaled storable information achieved via auto-sharding and server data replications
keeps MongoDB edges away than other relational database counterparts like MySQL
and Oracle databases.
Everything has drawbacks, of course MongoDB has few, one being the inability of
processing multiple operation as one transaction like other relational databases.
Therefore, if any operation causes an error the whole transaction fails. It also lacks joint
operations features like MySQL which in turn makes it weak against data with multiple
relationships among them. When making changes, multiple documents has to be
updated. Changes in multiple data clusters in different documents should be tied to a
32
single transaction to make sure all the collections are updated. Hence MongoDB being
a non-transactional database, processes like such could be few of its weaknesses, it has
hard times at such. However, the ability to store any kind of free form data structure
without any rule governing the relation can be a strength at times, applications can be
built at any platforms and they can have any sort of data-structure they prefer. For the
handling of such ambiguous ungoverned data structure, Mongoose was created by
MongoDB. Mongoose is an Object Data Modelling (ODM) library for MongoDB and
Node.js. It provides schemas to model application data which therefore cleans up the
ambiguity of databases. Mongoose as a library contains built-in type casting, validation,
query building, business logic hooks and more. Therefore, it aids in handling the
relationships between the data, provides schema validation, and is used to translate
between objects in code and the representation of those objects in MongoDB. Mongoose
removes the need of writing difficult data validations, business logics and casting
broiler-plates in the documents. Moreover, it provides additional sets of features on top
of MongoDB, for instance it can help manage the connections to MongoDB database.
It can be helpful just even to perform basic operations like read, write, and save data.
By providing schema level validation rules, it also allows only valid data to be saved in
MongoDB.
Key Components of MongoDB Architecture
1. _id – This is a 24-digit unique identifier field required in every MongoDB document
in the collection. The _id field is like the document's primary key. If the user creates a
new document without an _id field, MongoDB will automatically create the field.
2. Collection - Collection is a group of MongoDB documents. It is the equivalent of an
RDBMS table. A collection exists within a single database. Collections do not enforce
a schema. Typically, all documents in a collection are of similar or related purpose.
33
3. Document - A document is a set of key-value pairs. Documents have dynamic
schema. Dynamic schema means that documents in the same collection do not need to
have the same set of fields or structure, and common fields in a collection's documents
may hold different types of data.
4. Database - Database is a physical container for collections. Each database gets its
own set of files on the file system. A single MongoDB server typically has multiple
databases.
5. Field - A name-value pair in a document. A document has zero or more fields. Fields
are analogous to columns in relational databases.
Figure 4.9 MongoDB cluster.
Mongoose
Mongoose is a query language to communicate between the server and the database and
performs reading, writing, updating and deleting operations of the data. It is an Object
Data Modelling (ODM) library for MongoDB and NodeJS which provides schemas to
34
model application data which therefore cleans up the ambiguity of databases. It enforces
a standard structure to all the documents in a collection using schema. It also validates
the stored data in the documents as well as allow only valid data to be saved in the
database. Overall Mongoose provides all the features to the MongoDB including query
building functions and business logic in the data (Mongoose ODM v5.9.12, 2020).
4.9 Postman
Postman is a software development tool. It enables people to test calls to APIs. Postman
users enter data. The data is sent to a special web server address. Typically, information
is returned, which Postman presents to the user. Postman is an interactive and automatic
tool for verifying the APIs of your project. Postman is a Google Chrome app for
interacting with HTTP APIs. It presents you with a friendly GUI for constructing
requests and reading responses. It works on the backend, and makes sure that each API
is working as intended.
In Postman, we create a request, and Postman looks at the response to make sure it has
the element we want in it. As it is an automation tool, it drastically improves testing
time and quality of the project. It helps in the early detection of bugs that might sprout
at later stages and cause more damage to the system.
Postman is the way to streamline the process of API testing. All APIs that we create and
deploy first rigorously go through Postman so that any major or show stopper bugs are
identified on time and fewer bugs leak through to later stages.
4.10 Development Environment Setup
It is always important to choose the right tools and a suitable environment to perform
any kind of task. A combination of such tools and environment increases the efficiency
35
of work, increases productivity, and saves a lot of time. Choosing a comfortable stack
is also one of the keys to succeed in the development process and make it easier. The
application was entirely developed in MacBook Pro 2018 with macOS Catalina 10.15.3
as the operating system. Besides, several third parties’ tools and software were used to
make the development process easier and get an expected result. Visual Studio Code
was used as a code editor for this project. VS Code is an open-source project
spearheaded by Microsoft, which was first released in 2015. Since then it has become
one of the most popular code editors among the developers. VS Code is a great package
starting from setup, adopting UI for showing the content of files, customizable settings,
debugging a NodeJS web app to the deploying of the web application to the cloud (Code,
2020).
4.11 Version Control System (VCS)
Version control is a component of software configuration management, that keeps a
record of changes to a document or set of documents over time so the specific versions
can be recalled later. Changes are identified by a number or letter code, which is termed
as “revision number”, “revision level”, or simply “revision”. For instance, an initial set
of files is “revision 1”. When the change is made, the resulting set is “revision 2” and
so on. “Each version is associated with a timestamp and the person making the change.
Revision can be compared, restored, and with some types of files, merged” (Blischak,
Davenport and Wilson, 2016). Version control makes a group or team working together
on a project easier to collaborate. There are many different version control systems
available which are Git, Subversion, Team Foundation Version Control and so on. Git
one of the most common version control systems and was chosen for the project as this
is a distributed version control system which emphasizes on speed, data integrity and
support for distributed non-linear workflows (Blischak, Davenport and Wilson, 2016).
The advantage of Git is that it provides backups by the nature of its design. Whereas
other VCSs have a ‘single source of truth’, every Git repository stores the entire
36
repository. Typically, developers have a working copy of a repository which is stored
locally on their computers, as well as one repository stored in a Git cloud provider such
as GitHub, GitLab or BitBucket.
4.12 Visual Studio Code (VS Code)
VS Code is a popular source code editor by Microsoft. It can be used with many
languages but since it is based on Electron, one of the Node.js frameworks, MERN
development is easy and efficient. It is free for developers use and is open source under
MIT license. Built-in terminal support makes it much easier for web-development.
4.13 JSON Web Tokens (JWT)
JWT is a JSON web object which helps creating a safe data communication between
two parties which in application’s context are the application’s server and the end-user.
The token is composed of a header, a payload and a signature. Header provides
information how signature is to be computed. Payload is the data stored in the token,
like the user information. The payload is encrypted or hashed to produce a signature. It
is used for the authentication of users in the application. Below is the way JWT attaches
with the application to provide security and privacy to the contents.
37
Figure 4.10 JWT to access the application server.
38
CHAPTER 5
CONCLUSION AND FUTURE WORK
5.1 Conclusion
In conclusion, Krishi-Sadhan represents a pivotal leap towards transforming the
agricultural landscape through innovative technology. This MERN stack application,
meticulously designed and implemented, addresses the pressing challenges faced by
farmers, offering a dynamic platform for the exchange and rental of agricultural
equipment.
The project's core objectives of simplifying equipment exchange, enabling short-term
rentals, fostering community collaboration, and empowering farmers through
technology have been met with a comprehensive system design. The utilization of
React.js, Node.js, Express.js, and MongoDB reflects a commitment to modern, efficient,
and scalable development practices.
The envisioned impact goes beyond transactions, aiming to create a collaborative
ecosystem where farmers can seamlessly share knowledge, optimize resources, and
contribute to sustainable agricultural practices. The user-friendly interface ensures
accessibility for farmers across diverse technological backgrounds.
As Krishi-Sadhan embarks on its journey, the potential for positive change within the
agricultural community is evident. By leveraging technology, the platform seeks to
empower farmers, promote efficient resource utilization, and create a more connected
and informed farming community.
5.2 Future Work
The following outlines potential avenues for growth and development:
39
Geographical Expansion:
Extend the platform to cater to a broader geographical area, involving farmers from
different regions. This expansion could be facilitated by integrating location-based
services and adapting the system to diverse agricultural practices.
Integration of IoT and Sensor Technologies:
Incorporate Internet of Things (IoT) and sensor technologies to gather real-time data on
equipment usage, soil conditions, and weather patterns. This data-driven approach could
offer valuable insights to farmers, further optimizing agricultural practices.
Machine Learning for Recommendations:
Implement machine learning algorithms to analyse user behaviour, equipment exchange
patterns, and knowledge-sharing interactions. This data-driven approach can enhance
the platform's ability to provide personalized recommendations for equipment listings,
collaborations, and relevant agricultural insights.
Collaboration with Agricultural Research Institutions:
Forge partnerships with agricultural research institutions to integrate cutting-edge
research findings and technologies into the platform. Collaborating with experts can
enhance the knowledge-sharing section and provide farmers with access to the latest
advancements in farming practices.
Mobile Application Development:
Develop mobile applications for iOS and Android platforms, enabling farmers to access
Krishi-Sadhan conveniently from their smartphones. Mobile applications can enhance
user engagement and accessibility, particularly in areas with limited access to desktop
computers.
40
Diversification of Equipment Categories:
Expand the range of equipment categories available on the platform to include a broader
spectrum of agricultural tools and machinery. This diversification could attract a more
extensive user base and meet the varying needs of farmers with different agricultural
practices.
Blockchain for Transaction Transparency:
Explore the integration of blockchain technology to ensure transparency and security in equipment
exchange transactions. Blockchain can provide an immutable ledger, reducing the risk of fraudulent
activities and enhancing trust within the community.
Partnerships with Agricultural Suppliers:
Collaborate with agricultural equipment suppliers to create a marketplace for the
purchase of new equipment. This can provide farmers with additional options and create
a comprehensive ecosystem that caters to both equipment exchange and direct
procurement needs.
Implementation of Advanced Security Measures:
Continuously update and enhance the security measures to protect user data and
maintain the integrity of the platform. This includes regular security audits, encryption
improvements, and staying abreast of emerging cybersecurity threats.
User Feedback and Community-Driven Development:
Establish a mechanism for collecting user feedback and insights. Prioritize communitydriven development by involving users in the decision-making process, ensuring that
future enhancements align closely with the evolving needs of the farming community.
41
REFERENCES
[1] Sarkar, A. (2020). Agricultural Mechanization in India: A Study on the Ownership
and Investment in Farm Machinery by Cultivator Households across Agri-ecological
Regions. Millennial Asia, 11(2), 160–186
[2] Grant Thornton (2017). Mechanisation: Key to higher productivity to double
farmers’ income. Grant Thornton India.
[3] Department of Agriculture, Cooperation and Farmers, Welfare (DoACFW) (2018).
Pocket book of agricultural statistics, 2017. Directorate of Economics and Statistics,
Department of Agriculture Cooperation and Farmers Welfare, Ministry of Agriculture,
Cooperation & Farmers Welfare, Government of India.
[4] Bhattarai M., Singh G., Takeshima H., & Shekhawat R. S. (2018). Farm machinery
use and agricultural industries in India: Status, evolution, implications, and lessons
learned (Discussion Paper No. 01715). Development Strategy and Governance
Division, International Food Policy Research Institute.
[5] MoAC & FW, GOI. (2020) Revised Guidelines of In-situ crop residue
management scheme. Retrieved from agricoop.nic.in
42
JOURNAL
43
Download