Assignment 6 Report
Assignment 6 Report
Project members:
● Dias Rysbekov, CSE-2401M - main frontend of the project
● Bekzat Aitbekov, CSE-2401M - main backend of the project
Github:
● https://github.com/Yangdux/AdvancedDB
Frontend code under “main” branch
Backend code under “backend” branch
Project goals:
1. Apply NoSQL database principles to store and retrieve user data and product
information.
2. Implement a collaborative filtering recommendation system.
3. Develop a user-friendly environment with personalized recommendations.
4. Gain experience in performance testing and optimization.
Project deliverables:
● A detailed project proposal outlining the chosen NoSQL database, data modeling
approach, and recommendation algorithm.
● A functioning with the recommendation system integrated.
● Documentation on how to set up and run the project.
● Performance analysis and optimization report.
Project description:
● Our project is a mobile application for a shop selling technical appliances such as
laptops, mobile phones, computer accessories and internal parts. The application was
written in Flutter mobile development language created by Google and MongoDB
NoSQL database by integration with the Java environment of development. Project
has all the requested functionality:
○ Users can register and login to their respective accounts.
○ Users have profile pages that show their account data, such as full name,
email, age, gender and their balance of money they have in their account.
○ Users can see all the products that are listed in our database, including
respective data of the products such as description, quantity, price, category,
number of likes on that product and its image. The working database had 120
products and 10 user accounts.
○ We have implemented a recommendation engine and collaborative filtering
functionalities. First is based on user activities such as likes given and
purchases made. Collaborative filter assesses all users’ actions in order to give
the product list to the users. This will be explained more below.
○ The app has a user history page which shows all the products that have been
purchased by the user and products that have been liked, and viewed.
○ It also manages the search functionality through the backend api call which
receives a string type keyword and returns a list of products satisfying this
request.
○ All the requests to the database are done through api calls.
○ We also completed performance testing on our recommendation engine, which
will be shown and discussed below.
Project stack:
● Flutter mobile development language, with its packages (libraries).
● Java 17
● Libraries under Spring Framework: Data JPA, Security, Boot, MVC
● Ngrok is used as a server to connect the backend with frontend
Stack reasoning:
● We have decided to write a mobile application over web application because Dias
Rysbekov is a Junior Mobile Developer at WonkAI company. He has a sufficient level
of professionalism to write mobile apps that are both efficient and pleasant in UX/UI.
Flutter is an open source cross-platform language framework written in Dart
programming language created by Google. It can be used to write efficient web and
mobile apps, for ios and android devices. It has great community support and demand
on the market.
● The reason for choosing Java as a backend is that Bekzat Aitbekov is an Java intern in
EPAM Systems. He had plenty of experience implementing API using Java and
Spring Framework. Java is a versatile language, used all around the world to write
web and other applications. The Spring Framework is an application framework and
inversion of control container for the Java platform. The framework's core features
can be used by any Java application, but there are extensions for building web
applications on top of the Java EE (Enterprise Edition) platform.
● MongoDB is used as a NoSQL database, because both Bekzat and Dias are the most
familiar with it, compared to other DBs. In addition, since our main choice for
frontend was Flutter MongoDB was a go-to choice, because Flutter has the most
amount of supported libraries for NoSQL databases for MongoDB after Firebase DB.
We did not choose Firebase because it has many predefined supporting systems that
can be used and thus making the goals of the project too easy to reach.
Project analysis:
Frontend of the project:
1. User registration and profiles
For this section of our project Dias have created three pages: Login page, Registration
page and Profile page. In our github repository, which we have provided two pages are
responsible for these pages: LoginPage.dart and ProfilePage.dart. In the login page users can
either login using their emails and passwords or press the “Sign Up” text button to move to
the registration page and create a new account filling their name, email and password to the
forms provided. Passwords have validation checks both on front and back end of the app to
be sure that no password is less than 8 symbols, has 1 upper case, 1 special symbol
characters. Here are the images of the successful pages.
Picture 4 is a Home page which shows the results of the recommendation engine and in case
if a person does not have recommendations it returns the whole list of the items. Picture 5 is a
Categories page where all of our 12 categories are returned. Ant the Picture 6 is a products
page for monitors category as an example. As you can see here the images of products are the
same because we fairly did not have enough time to properly search for the pictures of items
and place them appropriately. Thus we wrote a script to assign every item a picture of their
category. Thus all the monitors have the same picture, same as for all other categories.
3. User History
Our flutter application also has a user history page which stores the purchase and likes
history of the user account. This data is also retrieved from our database since every
purchase and like is recorded. From the front part we simply wrote the respective API
call to access that data. On this page there are two tabs, first is the “Purchases” tab
and second is the “Likes” tab. Both likes and purchases history lists are returned from
the database through our API calls.
5. Search Functionality
Search functionality in the frontend of the project is pretty similar to everything else.
We have search bars across our application and when we write a certain word to
search and press the search icon on the search bar it makes an API call which returns
results for that search. These results are shown as a separate list over the page where
the search bar was located. To finish the searching session users simply need to press
the return text button. Pictures 9 and 10 are the examples of how this is done.
User registration and overall security is implemented with Spring Security. Each time an
existing user tries to login, he sends a POST request to the server with email and password in
body. In return, the server sends JWT Token, which times out after 24 hours.
The next screenshots are representation of these models in Java and MongoDB respectively:
● User
● Product
Picture 13. Product model
● Purchases
● Category
Picture 15. Category model
3) User History
User can view his purchase history and list of liked products.
Purchase history under this endpoint: /api/purchases/{userId}
4) Recommendation Engine
Recommendation engine work by the following logic:
We get the lists of categories of purchased and liked products for a particular user. We append
the rest of products from other categories. This list is sorted by likes in descending order and
returned.
If the user is new, the list of liked and purchased categories is empty. Then all products under
all categories is sorted by likes and returned
5) Collaborative filtering
This functionality works with almost the same logic as the recommendation engine.
Products that were liked the most are put into the list, sorted by likes, and the top 15 products
are returned.
6) Search Functionality
The search query of a user is sent to this endpoint:
Firstly we compare the query among categories. If nothing is found, compare it with the
product description. All found products are returned to the user.
7) Database
The connection to the database is with Spring Data JPA for MongoDB
Example:
If custom methods needed (find by name, find by category, etc.), method names must clearly
indicate that:
8) Performance
We are testing the performance of the app based on time to load two sets of products
The first set (which is used in the app) contains 120 products. In the second set we have 1000
decoy products. The screenshots show these sets respectively.
For this test, we created a separate model as well, “ProductTest”. It has the same
fields as Product, except “img” and “likedBy”.
As shown in this screenshot, first we start the timer, call for a method that loads all
documents from a collection, and stop the timer, showing it in console.
2) We go to this endpoint in Postman
Getting 120 recommendations:
As can be seen from the results, load time significantly increases with the number of products
in the collection.