Ilgaz Er Practice App Individual Contribution Report - bounswe/bounswe2023group1 GitHub Wiki

Ilgaz Er

Related Issues

API implementation

My feature for the app was the following: The user searches single words to fetch the corresponding wikidata entity. Then, the user can fetch all of the categories that the entity belongs to. Furthermore, the user can save the previous entities they accessed and see them in a list.

WikidataService

This class provides methods for querying the Wikidata API to search for and retrieve information about entities. It has the following methods:

  • executeWikidataQuery(String query) is a private method that takes a query string as input and returns a JsonNode object representing the response from the Wikidata API. Its purpose is to alleviate code repetition in the other two methods.

  • getWikidataEntityFromId(String id) uses executeWikidataQuery(String query) to retrieve information about a specific entity from the Wikidata API. It extracts the entity's labels and supercategories from the JSON response and returns them as an EntityData object.

  • searchForWikidataEntity(String query) uses executeWikidataQuery(String query) to find a specific entity from the Wikidata API using a query string. It extracts the entity's labels and supercategories from the JSON response and returns them as an EntityData object.

Containerisation and Deployment

In general, I worked with Ali to create the deployment and development infrastructure of the project.

  • Link: #185 I migrated the frontend hosting from npm start to static file hosting through nginx. I also implemented a reverse proxy for the backend, such that the backend is accessible through cmpe352.ilgazer.com.tr/api/[endpoint].

  • Link: #196 I containerised the backend build process in order to alleviate issues with building the project in different computers.

  • Link: #229 Took charge of the deployment process and fixex various bugs with our Docker configuration.

Object Category Fetching through Wikidata Api

Utilized Third Party URIs

Wikidata API, https://www.wikidata.org/w/api.php

The Wikidata API is an interface for accessing data stored in Wikidata, a free and open knowledge base. It allows developers and users to retrieve information about entities and properties in Wikidata, and to query the knowledge base using a wide range of search criteria and filters.

Name, route, description of created API functions

/category/findEntity: GET endpoint that takes a query parameter (query) and returns a JSON response containing the entity data for the given query. It uses the WikidataService to search for the Wikidata entity corresponding to the given query. It returns an EntityData.EntityRecord object in the response body.

/category/getCategoriesOf: GET endpoint that takes an ID parameter (id) and returns a JSON response containing the categories of the Wikidata entity with the given ID. It uses the WikidataService to retrieve the entity data and then gets the categories of the entity. It returns a list of EntityData.EntityRecord objects in the response body.

/category/saveEntity: POST endpoint that takes an ID parameter (id) and saves the corresponding entity data to the database. It uses the WikidataService to retrieve the entity data and then saves it to the database using the EntityRepository. It returns a 200 OK status code if the entity is saved successfully.

/category/getEntities: GET endpoint that retrieves all saved entities from the database and returns them in a JSON response. It uses the EntityRepository to retrieve all saved entities and returns a list of EntityData.EntityRecord objects in the response body.

Sample Calls

Sample Request: 1

Sample Request: 2

Sample Request: 3

Sample Request: 4

Description of unit tests

  • testIdOf() - This test checks whether the findEntity() method in CategoryController returns the expected response when given a particular input. It mocks a call to a method in WikidataService and checks whether the response code is 200 and the body is correct.

  • testGetCategoriesOf_nocats() - This test checks whether the getCategoriesOf() method in CategoryController returns the expected response when the target entity has no categories. It mocks a call to a method in WikidataService and checks whether the response code is 200 and the body is an empty array.

  • testGetCategoriesOf_one_cat()- This test checks whether the getCategoriesOf() method in CategoryController returns the expected response when the target entity has one category. It mocks a call to a method in WikidataService and checks whether the response code is 200 and the body is an array of one category name-id pair.

  • testGetCategoriesOf_two_cats() - This test checks whether the getCategoriesOf() method in CategoryController returns the expected response when the target entity has two categories. It mocks a call to a method in WikidataService and checks whether the response code is 200 and the body is an array of two category name-id pairs.

Challenges

During the deployment phase of a project, I encountered several challenges that required me to learn and grow as a developer. One major challenge was configuring and deploying the application using Docker and Nginx. This was not the first time I had used Docker and Nginx, however I used several of their functionalities for the first time. The most challenging issue I faced was configuring both the backend and the frontend build in Docker. This took a lot of time and a lot of trial and error, but I was successful in the end.

Despite these challenges, the deployment phase of the project was also an opportunity for growth. It allowed me to learn more about the intricacies of deploying an application in a production environment, as well as how to use Docker's more advanced features. I gained a better understanding of how to set up a production environment properly and how to troubleshoot and resolve issues that arise.