Professional Documents
Culture Documents
GRADUATION THESIS
Developing a files and directories sharing system
Hanoi, 04 – 2022
Acknowledgement
First of all, I would like to express my deep gratitude to teacher Dr. Do
Quoc Huy for directly guiding and creating favorable conditions for me during
the graduation thesis.
I would also like to thank the teachers at Hanoi University of Science and
Technology, especially the teachers of the School of Information and
Communication Technology, who imparted knowledge and experience to me.
The knowledge and experience play an important role in my graduation thesis as
well as will be the strong foundation for me in my future career.
Finally, I would like to thank my family and friends for their help,
encouragement and suggestions so that I can complete this graduation project.
Sincerely !
Table of Contents
ACKNOWLEDGEMENT ................................................................................................................................ 2
I. CHAPTER 1 - GENERAL INTRODUCTION .............................................................................................. 5
1.1. PROBLEM ................................................................................................................................................. 5
1.2. PURPOSE AND SCOPE OF WORK..................................................................................................................... 5
1.3. SOLUTION OVERVIEW ................................................................................................................................. 6
1.4. THESIS STRUCTURE ..................................................................................................................................... 7
1.5. DICTIONARY .............................................................................................................................................. 7
II. CHAPTER 2 – ANALYZING THE SYSTEM ............................................................................................... 7
2.1. CURRENT STATUS SURVEY ............................................................................................................................ 7
2.2. USE CASES OVERVIEW ................................................................................................................................. 7
2.2.1. Operating with file Use cases ........................................................................................................... 9
2.2.2. Operating with directory Use cases ................................................................................................. 9
2.3. USE CASES SPECIFICATION ............................................................................................................................ 9
2.3.1. Guest use cases ..............................................................................................................................10
2.3.1.1. Login...................................................................................................................................................... 10
2.3.1.2. Register ................................................................................................................................................. 11
2.3.1.3. Forgot Password ................................................................................................................................... 12
2.3.2. User use cases ................................................................................................................................13
2.3.2.1. Log out .................................................................................................................................................. 13
2.3.2.2. Search ................................................................................................................................................... 14
2.3.2.3. Update information .............................................................................................................................. 14
2.3.2.4. Use case Change Password................................................................................................................... 16
2.3.2.5. Use case Upload ................................................................................................................................... 17
2.3.2.6. Use case Download............................................................................................................................... 18
2.3.2.7. Use case Preview .................................................................................................................................. 19
2.3.2.8. Use case Set Permission permissions ................................................................................................... 19
2.3.2.9. Use case Share ...................................................................................................................................... 19
2.3.2.10. Use case Delete File .............................................................................................................................. 21
2.3.2.11. Use case Watch List File........................................................................................................................ 21
2.3.2.12. Use case Create .................................................................................................................................... 22
2.3.2.13. Use case Delete .................................................................................................................................... 23
2.4. FLOWS OF SYSTEM ...................................................................................................................................24
2.4.1. Login ...............................................................................................................................................24
2.4.2. Register...........................................................................................................................................24
2.4.3. Forgot password.............................................................................................................................25
2.4.4. Search .............................................................................................................................................25
2.4.5. Change Information .......................................................................................................................25
2.4.6. Change password ...........................................................................................................................26
2.4.7. Upload ............................................................................................................................................26
2.4.8. Download .......................................................................................................................................26
2.4.9. Preview ...........................................................................................................................................27
2.4.10. Set permission ...........................................................................................................................27
2.4.11. Share..........................................................................................................................................28
2.4.12. Delete File ..................................................................................................................................28
2.4.13. Watch List File ...........................................................................................................................29
2.4.14. Create Directory ........................................................................................................................29
2.4.15. Delete Directory .........................................................................................................................29
III. CHAPTER 3 – TECHNOLOGIES ........................................................................................................... 30
3.1. CLIENT-SERVER ARCHITECTURE...................................................................................................................30
3.2. MODEL – VIEW – SERVICE – CONTROLLER (MVSC) DESIGN PATTERN...............................................................30
3.3. POSTGRESQL ..........................................................................................................................................32
3.4. TYPESCRIPT AND NODEJS ..........................................................................................................................33
3.4.1. Typescript .......................................................................................................................................33
3.4.2. NodeJS ............................................................................................................................................34
3.4.3. Knex JS and Objection JS................................................................................................................34
3.4.4. Express JS........................................................................................................................................34
3.4.5. Axios ...............................................................................................................................................35
3.4.6. Next JS and React JS .......................................................................................................................35
3.4.7. Material UI .....................................................................................................................................36
3.5. DOCKER .................................................................................................................................................36
3.6. NGINX ...................................................................................................................................................37
IV. CHAPTER 4 – DESIGNING THE SYSTEM .............................................................................................. 38
4.1. DATABASE DESIGN....................................................................................................................................38
4.2. CLASS AND PACKAGE DESIGN ......................................................................................................................41
4.3. SYSTEM STRUCTURE..................................................................................................................................43
4.4. FEATURE DESIGN .....................................................................................................................................43
4.4.1. File storage and management .......................................................................................................43
4.4.2. File versioning and history management .......................................................................................44
4.4.3. File sharing .....................................................................................................................................44
4.4.4. File usage statistic ..........................................................................................................................44
V. CHAPTER 5 – OUTSTANDING SOLUTIONS AND CONTRIBUTIONS ........................................................ 44
VI. CHAPTER 6 – CONCLUSION .............................................................................................................. 44
I. Chapter 1 - General introduction
1.1. Problem
In the era of technology development, information exchange over the network
has become an indispensable need of people. Especially when the Covid-19
pandemic broke out like today, all human activities from going to work, going to
school, or shopping are done online at home. This led to the development of file
storage and sharing, which was present on any system on the Internet.
Currently, two of the most popular file storage and sharing systems are Google
Drive and One Drive. These are two systems that have been around for a long
time and have attracted a large number of users. Google Drive's popular audience
is teenagers and older, while One Drive is aimed at businesses. However, these
two systems still have some inconveniences, and have not optimized many
functions. For example, Google Drive does not have a shared folder management
function, the information when shared is quite open. Anyone after sharing a
document can delete the file or make changes without even knowing the owner
of the file in advance. Another example is that both systems do not have the
function of statistics of interactions with any file of the user, so it is not possible
to strictly control who has made changes to a file of a user. user. In addition, these
two systems have many other weaknesses, making them difficult to use, as well
as not suitable for their entire user base.
This report introduces a new file storage and sharing system, with the aim of
overcoming the disadvantages from the above two systems. The main audience
that this system targets is businesses. The details and each function of the system
will be described in the sections below.
When forget your password, user can request for resetting via the registered
email. New password will be emailed. They can then continue to log in to the
Software with the new password.
Anyone can change their personal information and have full discretion over their
file system and directory (add/view/delete/edit). They have the right to share files
and set permissions for their content files to other users.
- For allocating the request from user to frontend as well as the request from
frontend to backend, Nginx will take responsible to do the “load balancing”
1.4. Thesis structure
Form the next chapter, the graduation thesis will be organized as follows:
- Chapter 2: Survey some highly rated and widely used file sharing sites. On
that basis, overview use case diagrams and flow diagrams will be given to
clearly see the interaction of the two agents (guest and users) with the
system and some non-functional requirements.
- Chapter 6: the final chapter of the project report, through to review the
results that the thesis have been achieved, to summarize gained knowledge
and experiences. Finally, there are a few development directions to
improve the quality of the product.
1.5. Dictionary
• Fields in Login:
Name Description Required Eligibility conditions Example
Username User account Yes Accept letters, Longnh123
numbers, longer than
0 and shorter than 255
characters.
Password Password Yes Accept letters, 123456
numbers, longer than
0 and shorter than 255
characters.
2.3.1.2. Register
Name Register
Purpose Allowing a Guest creating an account to become a User
Actor Guest
Pre- No
condition
Post- Guest owns a account and can use that account to login the system
condition
Main flow 1. Actor accesses Register page.
2. The system shows up Register pages.
3. The actor fills in the fields:
3.1. If one or many required fields are missed, move to
Flow 3.1.
3.2. Username is duplicated, move to Flow 3.2
3.3. Password is not strong enough, move to Flow 3.3
3.4. Email is not valid, move to Flow 3.4
3.5. Actor chooses “Cancel”, move to Flow 3.5
4. System saves the information and notifies success. Actor is
directed to the Login pages.
Sub-flow No
Branch - Flow 3.1: System notifies required fields not filled. Ask the
flow actor to fill the fields.
- Flow 3.2: System notifies username is duplicated, Ask the
actor to enter a new username.
- Flow 3.3: System notifies Password is not strong enough,
notifies a strong password condition. Ask for a new
password.
- Flow 3.4: System notifies email Is invalid, Ask for re-filling
the field.
- Flow 3.5: System directs the actor to the Login page.
• Fields in Register:
Name Description Required Eligibility Example
conditions
Username Username Yes Accept letters, Longnh123
numbers, longer
than 0 and shorter
than 255
characters.
Password Password Yes Longer than 0, L@123456
shorter than 255
characters.
Include letters,
numbers or
special
characters.
Email Email used to Yes In form longnh@gmail.com
contact with xxx@xxx.xxx
the actor
Name Actor Name Yes Include letters Nguyễn Hoàng
and spaces. Long
Longer than 0,
shorter than 255
characters.
Birthday Actor No In form DD / MM 20/8/1999
birthday / YYYY,
A date exists in
real life.
Phone Phone Yes The length is 10 0123456789
number number used
to contact
with the actor
Sub-flow No
Branch - 3.1. System notifies email invalid, Ask Actor re-filling the
flow fields.
- 3.2. System directs the actor to the login page.
- 4.1. System notifies email does not exist.
- 5.1. System notifies errors and directs to Forgot Password
page.
• Used fields
Name Description Required Eligibility Example
conditions
Email Email used to Yes In form longnh@gmail.com
contact with xxx@xxx.xxx
Actor
2.3.2.2. Search
Name Search
Purpose Search directories or files
Actor User
Pre- Actor is logged in the system
condition
Post- Files/ directories are shown up in Search. Actor can open
condition directories or preview the files from search.
Main flow 1. Actor fills in the files or directories name in Search input
and chooses the search icon.
- Actor click outside the search input, move to Flow 1.1
2. System shows up files or directories available in the actor
repository.
- System does not find any result , move to Flow 2.1
Sub-flow No
Branch - 1.1 System directs actor to the previous page.
flow - 2.1 System shows up notifies “Not found any result”.
• Used fileds
Name Description Required Eligibility conditions Example
keyword Keywords in files Yes Longer than 0, shorter Lib
or directories than 255 characters.
• Used fileds
Name Description Required Eligibility conditions Example
Old Current Yes Accept letters, and 123456
password Password numbers, longer than
0 and shorter than 255
characters. Password
must be the same
current Password.
New New Password Yes Accept letters, 123456
password numbers, longer than
0 and shorter than 255
characters.
Confirmed Confirmed Yes Accept letters, and 123456
Password password numbers, longer than
0 and shorter than 255
characters. Match the
new password.
• Used fileds
Name Description Required Eligibility Example
conditions
Email Email used to No In form longnh@gmail.com
contact with xxx@xxx.xxx
Actor
Sub-flow No
Branch - 1.1 System shows up pop-up “Directory does not exist”.
flow - 1.2 System shows up pop-up “Directory does not belonged
to you”.
• Used fileds
Name Description Example
Name File name New Dir 1
Type File extension doc
Size File size 17 KB
Time The day that file is 8:00 13/4/2020
Added upload
2.4.1. Login
2.4.2. Register
2.4.3. Forgot password
2.4.4. Search
2.4.7. Upload
2.4.8. Download
2.4.9. Preview
Mechanism
- The model is responsible for managing the data of the application. It
receives user input from the controller, queries into the database to get
suitable records or performs data transformations (create, update or delete
records) and returns to the controllers.
- The view renders the presentation of the data received from the service in
a particular format.
- The controller responds to the user input from services, performs
interactions on the data model objects, collects the records returned by
models and handles the logic interaction with those data before passing
them to services. The controller receives the input, optionally validates it
and then passes the input to the model.
- The service is responsible to transfer the user inputs from views, direct
them to the right function in the controller and return the result from them.
As with other software patterns, MVC expresses the "core of the solution" to a
problem while allowing it to be adapted for each system. Particular MVC designs
can vary significantly from the traditional description here.
3.3. PostgreSQL
PostgreSQL is one of the most advanced, free and open source object-relational
database management system (RDBMS) available. It is high scalability and
compliance with technical standards, designed to handle a wide range of
workloads, from personal computers to data warehouses or Web services with
many concurrent users.
- Developed by PostgreSQL Global Development Group, First Released:
08/07/1996.
- Flexible and can be run on a variety of platforms such as Mac OS X,
Solaris, and Windows.
- Free and open source software so PostgreSQL can be used, modified, and
disseminated by anyone for any purpose.
- Highly stable.
Features
PostgreSQL integrates many great features to help developers build apps that
respond to complex functions, query quickly, and securely maintain integrity and
reliability. To be more reliable, It also provides various security, authentication,
and disaster recovery options. PostgreSQL has proven to be highly scalable both
in terms of the amount of data and the number of concurrent users.
- Complex query (complex query)
- Event procedures (triggers)
- Views
- Integrity transactions
- Multi-version concurrency control
- Parallel query (parallel query)
- Streaming replication
Datatypes
- Primitives: Integer, Number, String, Boolean
- Structure: Date/Time, Array, Range, UUID.
- Document: JSON/JSONB, XML, Key-value
Data integrity
- UNIQUE, NOT NULL
- Primary Keys
- Foreign Keys
- Exclusion constraints
- Function Lock, Recommended Lock
- Concurrent, efficiency
- Cataloging: B-tree, Multicolumn, Expressions, Partial
- …
Security
- Authentication: GSSAPI, SSPI, LDAP, SCRAM-SHA-256, Certificate
and others
- Powerful access control system
- Column and row level security
Ability of extension
- Storage method
- Procedural Languages: PL/PGSQL, Perl, Python (and many more)
- External data wrapper: connect to other databases or streams with standard
SQL interface
- And many extensions provide additional functionality, including PostGIS
- Text search:
- Support for international character sets, e.g. through ICU collations
- Full-text search
3.4. Typescript and NodeJS
3.4.1. Typescript
TypeScript is a programming language developed and maintained
by Microsoft. It is built on JavaScript
TypeScript may be used to develop JavaScript applications for both
client or server execution (as with Node.js). The default TypeScript Compiler can
be used or the Babel compiler can be invoked to convert TypeScript to JavaScript.
TypeScript offers all of JavaScript’s features and an additional layer on top
of these: TypeScript’s type system. This means that your existing working
JavaScript code is also TypeScript code. The main benefit of TypeScript is that it
can highlight unexpected behavior in your code, lowering the chance of bugs.
3.4.2. NodeJS
Node.js is a free, open-source server environment and runs on various
platforms (Windows, Linux, Unix, Mac OS X,…). It uses asynchronous
programming, eliminates the waiting, and simply continues with the next request.
It also runs single-threaded, non-blocking, which is very memory efficient.
- Nodejs generate many dynamic page content
- Node.js can create, open, read, write, delete, and close files on the server
- Node.js can collect form data
- Node.js can add, delete, and modify data in your database
- Node.js can do anything that a server app needs to do.
3.4.3. Knex JS and Objection JS
Knex.js is a. SQL query builder for PostgreSQL, MSSQL, MySQL,
MariaDB, SQLite3, Better-SQLite3, Oracle and Amazon Redshift designed to be
flexible, and portable to use.
It features both traditional node style callbacks as well as a “Promise” interface
for cleaner async flow control, a stream interface, full–featured query and schema
builders, transaction support (with save points), connection pooling and
standardized responses between different query clients.
Routings:
Routing refers to determining how an application responds to a client
request to a particular endpoint, which is a URI (or path) and a specific HTTP
request method (GET, POST, and so on).
Each route can have one or more handler functions, which are executed
when the route is matched.
Defining routing using methods of the Express app object that correspond
to HTTP methods; for example, app.get() to handle GET requests and app.post to
handle POST requests. For a full list, see app.METHOD.
These routing methods specify a callback function (sometimes called
“handler functions”) called when the application receives a request to the
specified route (endpoint) and HTTP method. In other words, the application
“listens” for requests that match the specified route(s) and method(s), and when
it detects a match, it calls the specified callback function.
Middlewares
Middleware functions are functions that have access to the request object
(req), the response object (res), and the next function in the application’s request-
response cycle. The next function is a function in the Express router which, when
invoked, executes the middleware succeeding the current middleware.
Docker Compose is a tool used to define and run Docker programs that use
multi-containers. With Docker Compose, we use a YAML file to set up the
necessary services for the program. Finally, with one command, we will create
and start all services from those settings.
Using Compose typically involves the following three steps:
- Declare the program's environments in the Dockerfile.
- Declare the necessary services for the program in the docker-compose.yml
file so that the services can run together in an environment.
- Run the docker-compose up command to start Compose and run the
program.
Docker Compose has commands that allow to manage your program's lifecycle:
- Start, Stop and Rebuild the service.
- View the status of running services.
- View the log output of the running service.
3.6. Nginx
NGINX is open source software for web serving, reverse proxying, caching, load
balancing, media streaming, and more. It started out as a web server designed for
maximum performance and stability. In addition to its HTTP server capabilities,
NGINX can also function as a proxy server for email (IMAP, POP3, and SMTP)
and a reverse proxy and load balancer for HTTP, TCP, and UDP servers.
IV. Chapter 4 – Designing the system
4.1. Database design
- Files: is used to store all the files information (not included the content of
file which is stored in the server disk)
- Detail of File table
Field Type Description
id Integer Identification number
physicalLocation String File location in the server disk
name File’s name
size Integer File’s size
type File’s type (extension)
ownerId Integer Owner of the file id
defaultOperation The default operation of file
directoryId Integer The parent directory id
views Integer Number of views by owner
downloads Integer Number of downloads owner
- Directories: is used to store all the directory information (not included the
content of file which is stored in the server disk)
- Detail of Directories table
Field Type Description
id Integer Identification number
physicalLocation String File location in the server disk
name String Directory’s name
ownerId Integer Owner of the directory id
defaultOperation Integer The default operation of directory
directoryId Integer The parent directory id
- Versions: is used to store the versions of files. While Files table save the
information of the current file, Versions table save the information of
previous one. Whenever user edit file with a new content the current
content will become a version.
Detail of Users table
Field Type Description
id Integer Identification number of user
userId Integer Owner of the file id
fileId Integer File Id
physicalLocation String File location in the server disk
createdAt Unix String Moment that created the version
4.2. Class and package design
The classes and packages is designed after the MVSC Design Pattern. The
system includes 4 packages which are Model Package, Controller Package,
Service Package and View Package.