/personalized-data-core

A spring boot application for a personalized data REST API service that provides shoppers personalized information to eCommerce servers.

Primary LanguageJava

Personalized Data Core v1.0

This is a spring boot application for a personalized data REST API service that provides shoppers personalized information to eCommerce servers.

The service consists of 2 main parts:

  1. Interface with data team (internal) - Receiving shoppers’ personalized information and product metadata from our data team and storing it in a specified database.
  2. Interface with eCommerce (external) - Provide fast-reading operation for the shoppers’ personalized information. image

Built With

Spring Initializr

init

Functions

  1. ADD product metadata
  2. ADD shoppers’ personalized information
  3. GET personalized information by shopper
    1. Filter by Category & Brand
    2. Limit (default - 10, max - 100)

Quick start

Prerequisites

This assumes that you already have:

  • Gradle installed
  • Java 17 installed and configured as the current Java version for the environment. Verify that java -version outputs version 17 and ensure that the JAVA_HOME environment variable is set to the Java installation directory containing bin.
  • Redis installed and running

Clone the repository

git clone https://github.com/thilina999/personalized-data-core.git

Build the project

Open the project in IntelliJ(or any other IDEA), which will automatically build it

Run the project

Open application.properties file. Update valid database connection details and make sure spring.jpa.hibernate.ddl-auto is set to create when running the application for the first time. Run the PersonalizedDataCoreApp class to run the application. This will start the application and create the required entities in the database.

Rest API Endpoints

Add Product Metadata

POST - http://localhost:8080/internal/api/v1/product-metadata

Request body

{
    "productId": "BB-2144746855",
    "category": "Babies",
    "brand": "Babyom"
}

Add Product Metadata

POST - http://localhost:8080/internal/api/v1/shopper-products

Request body

{
    "shopperId": "S-1000",
    "shelf": [
        {
            "productId": "BB-2144746855",
            "relevancyScore": 55.16626010671777
        }
    ]
}

Add Product Metadata

GET - http://localhost:8080/external/api/v1/products?shopperId=S-1000

GET - http://localhost:8080/external/api/v1/products?shopperId=S-1000&category=Books&brand=BrandH&limit=30

Request Header

Authorization: Basic (Username: actuator, Password: !data2024)

Response Body

[
{
    "productId": "BB-2144746855",
    "category": "Babies",
    "brand": "Babyom"
},
...
]
Import API collection at src/main/resources/postman to try with Postman

Contact

Thilina Dissanayake

Link: https://github.com/thilina999/personalized-data-core