THE UNIVERSITY OF DANANG
UNIVERSITY OF SCIENCE AND TECHNOLOGY
FACULTY OF INFORMATION TECHNOLOGY
GRADUATION PROJECT
DEPARTMENT: INFORMATION TECHNOLOGY
SPECIALIZED: SOFTWARE TECHNOLOGY
PROJECT :
BUILDING A SYSTEM OF AUCTION AND SALE FOR
AGRICULTURAL PRODUCTS.
STUDENT
: Ha Nguyen Khanh
STUDENT CODE : 102150094
CLASS
: 15T2
INSTRUCTOR
: Hoa Do Thi Tuyet
Da Nang, 12/2019
COMMENT OF INSTRUCTOR
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
COMMENT OF REVIEWER
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
..........................................................................................................................................
PREFACE
In fact, there is no success that is not associated with the help of more or less from
others. During the past five years, when I started studying in this university, I have
received a lot of help from my teachers, family and friends.
First of all, I would like to express my sincere thanks to all the teachers of the
Faculty of Information Technology - Da Nang University of Technology for teaching
and guiding me during the past five years.
I would like to express my sincere thanks to Ms. Do Thi Tuyet Hoa, who gave her
whole-hearted guidance, as well as for creating all the conditions for me to complete
this graduation project. If it weren't for her insightful instructions, evaluation, and
advice, I think completing my graduation project would be much more difficult.
Once again I would like to sincerely thank you.
The project is implemented in a period of 3 months. First step into practice, explore
the field of web applications, with limited knowledge and many surprises. Therefore,
the inevitable shortcomings. I look forward to receiving valuable comments from
teachers and friends to improve my knowledge in this field.
Lastly, I would like to wish the teachers in the Faculty of Information Technology
and Ms. Do Thi Tuyet Hoa so healthy and confident to continue the beautiful
mission of imparting knowledge to the next generation.
Best regards!
Da Nang, Day ...., Month ...., Year 2019
Nguyen Khanh Ha
5
ASSURANCE
I swear :
1. The content of this project is done by me under the direct guidance of Ms. Do
Thi Tuyet Hoa.
2. The references are clearly cited with the author's name, the name of the work,
the time and place of publication.
3. If there are invalid or infringing copies, I accept full responsibility.
Student
Nguyen Khanh Ha
6
TABLE OF CONTENT
PREFACE
i
ASSURANCE
ii
TABLE OF CONTENT
iii
LIST OF TABLES, PICTURES
vi
LIST OF SYMBOL, ACRONYM
viii
INTRODUCTION
1
1. About the topic
1
2. Purpose, request.
1
3. Research Methods
1
4. Tools used
1
5. Result
2
6. Content of the project.
2
CHAPTER 1:THEORETICAL BASIS
3
1.1. Overview of server side
3
1.1.1. Framework Node.js
3
1.1.1.1. Definition of Node.js
3
1.1.1.2. Nodejs operating model
3
1.1.1.3. Advantages of Node.js
4
1.1.2. Framework Express.js
5
1.1.2.1. Express.js
5
1.1.2.2. Express.js structure
5
1.1.3. JWT standard (JSON Web Token)
5
1.1.3.1. JSON Web Token
5
1.1.3.2. Explain more about three components of JWT
6
7
1.1.4. MongoDB
7
1.1.4.1. Introduction
7
1.1.4.2. Advantages of MongoDB compared to relational database (RDBMS)
7
1.1.4.3. Some characteristics of MongoDB
8
1.1.5. Visual Studio Code programming environment
8
1.2. Overview of Client-side
8
1.2.1. React.js
8
1.2.1.1. Introduction
8
1.2.1.2. What is React?
9
1.2.2. Redux.js
9
1.2.2.1. Introduction
9
1.2.2.2. Principle
10
The first, Single source of truth
10
The second, State is read-only
10
And the last, Changes are made with pure functions
10
1.2.2.3. Redux structure
11
1.3. Application of real-time interaction between client-server
11
1.3.1. Websocket
11
1.3.2. How to transfer data in real time
12
1.3.2.1. Create a connection
12
1.3.2.2. Handshake
12
1.4. Single-page in React.js
13
1.5. Conclusion of chapter
14
CHAPTER 2:SYSTEM ANALYSIS AND DESIGN
14
2.1. Introduction
14
2.1.1 Purpose
14
2.1.2. Interface requirements
15
2.1.3. Non-functional requirements
15
2.2. System design
16
2.2.1. Actors
16
8
2.2.2. Use case diagram
17
2.2.2.1. Diagrams
17
2.2.2.2. Use case description.
21
2.2.3. Sequence diagram
26
2.2.4. Class diagram
27
2.2.5. Database design
29
CHAPTER 3:DEPLOYMENT AND EVALUATION OF RESULT
33
3.1. Deployment
33
3.1.1. Environment
33
3.1.2. Install MongoDb
34
3.2. Result
34
3.2.1. Client website
34
3.2.2. Admin website
44
CONCLUSION
45
- Result:
46
- Unfulfilled results
46
- Development direction
46
REFERENCES
47
9
LIST OF TABLES, PICTURES
Table 2.1: Login use case
Table 2.2: Logout use case
Table 2.3: Register use case
Table 2.4: Add product use case
Table 2.5: Update Product use case
Table 2.6: Delete Product use case
Table 2.7: Search Product
Table 2.8: See product by category use case
Table 2.9: View Product use case
Table 2.10:Add bid section use case
Table 2.11: Bid product use case
Table 2.12: User Table
Table 2.13: Role Table
Table 2.14: AccessToken Table
Table 2.15: Product Table
Table 2.16: Category Table
Table 2.17: Auction Table
Table 2.18: AuctionDetail Table
Table 2.19: Cart Table
Table 2.20: CurrencyUnit Table
Table 2.21: Announcement Table
Table 2.22: FAQ Table
22
23
23
24
24
24
25
25
25
26
26
30
31
31
31
32
32
32
33
33
33
34
Picture 1.1: Describe how the Node.js works
Picture 1.2:Structure of Express.js
Picture 1.3: Redux structure
Picture 1.4: WebSocket connection
4
5
11
13
10
Picture 1.5: Single page application
Picture 2.1: Overview use case
Picture 2.2: Owner use cases
Picture 2.3: Overview customer use case
Picture 2.4: Customer use case
Picture 2.5: Admin use case
Picture 2.6: Create auction sequence diagram
Picture 2.7: Bid product sequence diagram
Picture 2.8: Class diagram
Picture 2.9: Database design
Picture 3.1: Home page client website
Picture 3.2: Login page
Picture 3.3: Register page
Picture 3.4: Profile page
Picture 3.5: Products pages
Picture 3.6: UI of products for owner
Picture 3.7: Owner add auction for their product
Picture 3.8: Owner’s products after successfully add auction
Picture 3.9: Product detail page
Picture 3.10: Customer bid product by add money
Picture 3.11: Bid Table updated after that
Picture 3.12: Customer cart where contain products that they win in auctions
Picture 3.13: Login page
Picture 3.14: Homepage
Picture 3.15: User management
11
14
18
19
20
21
22
27
28
29
30
36
37
38
39
40
41
41
42
43
44
44
44
45
46
46
LIST OF SYMBOL, ACRONYM
ACRONYM:
- JWT: Json Web Token
- RDBMS: Relational Database Management System
- JSON: JavaScript Object Notation
- URI: Uniform Resource Identifier
- MVC: Model View Controller
- HTTP: Hypertext Transfer Protocol
- TCP: Transmission Control Protocol
- FAQ: Frequently Asked Question
- SPA: Single Page Application
12
Building a system of auction and sale for agricultural products
INTRODUCTION
1. About the topic
With the strong development of information technology in recent years, its application
in life is not too strange to us. From industry, service, transportation to agriculture, ...
Its appearance helps to promote economic development and life clearly. Helps reduce
investment in labor power while improving economic efficiency.
In this topic, I focus on the agricultural sector, specifically on agricultural products. It
can be seen that for many years, farmers have always been in a precarious situation
because the products they make are too dependent on some traders. Some are
exclusive and may determine the price for the item at a pinch price.
With the aim of limiting the 'crop gain, crop loss' situation of Vietnamese farmers in
general due to lack of information and demand for their products, the main cause is
often forced by some traders. Since then, I have devised this topic with the purpose of
building a platform where the prices of agricultural products become transparent and
stable in accordance with the rules of the market economy.
2. Purpose, request.
I proposed this idea with the desire to help farmers be more active in solving the
problem of consuming the products they make. With just a few simple steps, they can
find out the highest possible price of the product they make and the unit that consumes
that product, as well as compare it with the market average. From that, avoiding the
pressure of traders to price, improve economic efficiency.
To achieve that goal, it is required to understand the relevant knowledge such as the
law of supply and demand, e-commerce, auction, ...
3. Research Methods
-
System analysis and design.
-
Create the database.
-
Build system.
-
Software Testing.
Student: Nguyen Khanh Ha
Instructor: Do Thi Tuyet Hoa
13
Building a system of auction and sale for agricultural products
4. Tools used
-
Database: Mongodb
-
Backend: Node.js
-
Frontend: React.js
5. Result
About theory:
Understand the profession of auctions and e-commerce.
Capture emerging technologies like nodejs and reactjs, understand how NoSQL
Mongodb works.
About application:
Develop a system to meet the needs of auctioning agricultural products and buying
and selling functions for users. Also demonstrate the management functions for the
system administrator.
6. Content of the project.
Projects include the following:
- Chapter 1: Theoretical basis
- Chapter 2: System analysis and design
- Chapter 3: Deployment and evaluation of result
- Conclusion and development direction.
Student: Nguyen Khanh Ha
Instructor: Do Thi Tuyet Hoa
14
Building a system of auction and sale for agricultural products
CHAPTER 1:
THEORETICAL BASIS
1.1. Overview of server side
1.1.1. Framework Node.js
1.1.1.1. Definition of Node.js
Node.js is an open-source server side runtime environment built on Chrome's V8
JavaScript engine. It provides an event driven, non-blocking (asynchronous) I/O and
cross-platform runtime environment for building highly scalable server-side
application using JavaScript.
Node.js can be used to build different types of applications such as command line
application, web application, real-time chat application, REST API server etc.
However, it is mainly used to build network programs like web servers, similar to
PHP, Java, or ASP.NET.
Node.js was written and introduced by Ryan Dahl in 2009.
1.1.1.2. Nodejs operating model
Node.js processes user requests differently when compared to a traditional web server
model. Node.js runs in a single process and the application code runs in a single
thread and thereby needs less resources than other platforms. All the user requests to
your web application will be handled by a single thread and all the I/O work or long
running job is performed asynchronously for a particular request. So, this single thread
doesn't have to wait for the request to complete and is free to handle the next request.
Student: Nguyen Khanh Ha
Instructor: Do Thi Tuyet Hoa
15
Building a system of auction and sale for agricultural products
When asynchronous I/O work completes then it processes the request further and
sends the response.
An event loop is constantly watching for the events to be raised for an asynchronous
job and executing callback function when the job completes.
Picture 1.1: Describe how the Node.js works
1.1.1.3. Advantages of Node.js
Besides speed and scalability, using JavaScript on servers and browsers helps you
avoid having to switch languages. You can do anything with only one language.
Another strong point of Nodejs is extremely suitable for JSON. JSON is considered
ideal when used by a JavaScript program. When working with nodejs, data can flow
through layers without having to reformat.
In the end, JavaScript is really popular, which makes it easier to develop Node apps
than other server-side languages.
Student: Nguyen Khanh Ha
Instructor: Do Thi Tuyet Hoa
16
Building a system of auction and sale for agricultural products
1.1.2. Framework Express.js
1.1.2.1. Express.js
Express js is a small, but flexible framework built on top of Nodejs. It provides
powerful features for web or mobile development
About support packages: Express.js has a multitude of support packages so you don't
have to worry about working with this framework.
About performance: Express.js provides more features for better programming. Not
reducing the speed of Node.js.
1.1.2.2. Express.js structure
Picture 1.2:Structure of Express.js
1.1.3. JWT standard (JSON Web Token)
1.1.3.1. JSON Web Token
JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and
closed way for securely transmitting information between parties as a JSON object.
This information can be verified and trusted because it is digital signature. JWTs can
be signed using a secret algorithm or a public / private key.
Example:
Student: Nguyen Khanh Ha
Instructor: Do Thi Tuyet Hoa
17
Building a system of auction and sale for agricultural products
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjEzODY4OTkxMzEsImlzcyI6Im
ppcmE6MTU0ODk1OTUiLCJxc2giOiI4MDYzZmY0Y2ExZTQxZGY3YmM5MGM4YWI2ZDBmNjIwN
2Q0OTFjZjZkYWQ3YzY2ZWE3OTdiNDYxNGI3MTkyMmU5IiwiaWF0IjoxMzg2ODk4OTUxfQ.u
KqU9dTB6gKwG6jQCuXYAiMNdfNRw98Hw_IWuA5MaMo
And this is the structure:
<base64-encoded-header>.<base64-encoded payload>.
signature>
In its compact form, JSON Web Tokens consist of three parts separated by dots (.),
which are:
-
Header
-
Payload
-
Signature
1.1.3.2. Explain more about three components of JWT
Header
The header typically consists of two parts: the token type and the signing algorithm
used for encryption (HMAC SHA256 or RSA).
{
"alg": "HS256",
"typ": "JWT"
}
Payload
The second part of the token is the payload, which contains the claims. Claims are
statements about an entity (typically, the user) and additional data. There are three
types of claims: registered, public and private claims.
-
Registered claims
Student: Nguyen Khanh Ha
Instructor: Do Thi Tuyet Hoa
18
Building a system of auction and sale for agricultural products
These are a set of predefined claims which are not mandatory but recommended, to
provide a set of useful, interoperable claims. Some of them are: iss (issuer), exp
(expiration time), sub (subject), aud (audience) and others.
-
Public Claims
These can be defined at will by those using JWTs. But to avoid collisions they should
be defined as URI that contains a collision resistant namespace.
-
Private Claims
These are the custom claims created to share information between parties that agree on
using them and are neither registered or public claims.
The payload is then Base64Url encoded to form the second part of the JWT.
Signature
To create the signature part, you have to take the encoded header, the encoded
payload, a secret, the algorithm specified in the header, and sign that.
For example, if you want to use HMAC SHA256 algorithm, the signature will be
created in the following way:
HMACSHA256 (
base64UrlEncode(header) + "." +
base64UrlEncode(payload),
secret
)
Because the Signature itself includes both headers and payloads, the Signature can be
used to check the integrity of the data when transmitting.
Student: Nguyen Khanh Ha
Instructor: Do Thi Tuyet Hoa
19
Building a system of auction and sale for agricultural products
1.1.4. MongoDB
1.1.4.1. Introduction
MongoDB is an open source, document-oriented NoSQL database program in which
tables are flexibly structured to allow data stored on tables without having to follow a
certain type of structure. Because of this flexible structure, MongoDB can be used to
store complex and diverse structured data.
1.1.4.2. Advantages of MongoDB compared to relational database
(RDBMS)
- Fewer Schema: MongoDB is a Document-based database, in which a Collection
holds different documents. The number of fields, content, and size of one Document
may differ from another.
- The structure of an object is clear.
- No complicated joins.
- MongoDB is easy to expand.
- The mapping of application objects to database objects is unnecessary.
1.1.4.3. Some characteristics of MongoDB
- Document oriented repository: Data is stored in JSON style.
- Indexing on any attribute.
- Diverse queries.
- Faster update.
1.1.5. Visual Studio Code programming environment
Visual Studio Code is a Microsoft product, launched in April 2015 at the Build
conference. Features are simple, compact, easy to install. Visual Studio Code can be
installed on Windows, Linux and Mac OS and supports multiple languages.
Student: Nguyen Khanh Ha
Instructor: Do Thi Tuyet Hoa
20