Skip to content

Case Study - Link Converter (Java 21, Spring Boot, MySql, JUnit, Jacoco, Prometheus,Grafana, Docker, Kubernetes, Github Action (CI/CD), Sonarqube)

Notifications You must be signed in to change notification settings

Rapter1990/linkconverter

Repository files navigation

Case Study - Link Converter

Main Information

📖 Information

Web URL to Deeplink

Write an endpoint that converts web URLs to deeplinks.

  • The endpoint should receive a web URL and return a converted deeplink.
  • You must store each request and response in persistent storage.
  • You should design your table columns or document fields to capture at least:
    • Original URL
    • Converted deeplink
    • Timestamp of request
    • Client identifier (if applicable)

1. Product Detail Page

Every product in Trendyol has multiple product detail page URLs. Example format:

https://www.trendyol.com/{BrandName-or-CategoryName}/{ProductName}-p-{ContentId}?boutiqueId={BoutiqueId}&merchantId={MerchantId}
  • Product detail page URL must contain the “-p-” text.
  • Product detail page URLs must contain ContentId, located immediately after the “-p-” prefix.
  • The URL can optionally include boutiqueId and/or merchantId query parameters.
  • If the URL does not contain boutiqueId, do not add CampaignId to the deeplink.
  • If the URL does not contain merchantId, do not add MerchantId to the deeplink.
  • Note: In deeplinks, the parameter is called CampaignId instead of boutiqueId.

2. Search Page

Search page URLs must be converted to valid deeplinks. Rules:

  • Search page path must begin with /sr.
  • The q query parameter must be converted to the Query parameter in the deeplink.
  • Be careful to preserve Turkish characters (percent-encoded values).

3. Other Pages

All other pages (neither product detail nor search) must be converted to the empty “homepage” deeplink:

ty://?Page=Home

Example Requests & Responses

Request (Web URL) Response (Deeplink)
https://www.trendyol.com/casio/saat-p-1925865?boutiqueId=439892&merchantId=105064 ty://?Page=Product&ContentId=1925865&CampaignId=439892&MerchantId=105064
https://www.trendyol.com/casio/erkek-kol-saat-p-1925865 ty://?Page=Product&ContentId=1925865
https://www.trendyol.com/casio/erkek-kol-saat-p-1925865?boutiqueId=439892 ty://?Page=Product&ContentId=1925865&CampaignId=439892
https://www.trendyol.com/casio/erkek-kol-saat-p-1925865?merchantId=105064 ty://?Page=Product&ContentId=1925865&MerchantId=105064
https://www.trendyol.com/sr?q=elbise ty://?Page=Search&Query=elbise
https://www.trendyol.com/sr?q=%C3%BCt%C3%BC ty://?Page=Search&Query=%C3%BCt%C3%BC
https://www.trendyol.com/Hesabim/Favoriler ty://?Page=Home
https://www.trendyol.com/Hesabim/#/Siparislerim ty://?Page=Home

Deeplink to Web URL

Write an endpoint that converts deeplinks back to web URLs. Use the same rules from Task 2 in reverse.

  • The endpoint should receive a deeplink and return the corresponding web URL.
  • You must store each request and response in persistent storage.
  • You should design your table columns or document fields to capture at least:
    • Original deeplink
    • Converted web URL
    • Timestamp of request
    • Client identifier (if applicable)

Conversion Rules

  • Product Page Deeplink:
    • Page=Product with ContentId must map to a Trendyol product detail URL.
    • If CampaignId is present, include boutiqueId={CampaignId} in the web URL.
    • If MerchantId is present, include merchantId={MerchantId} in the web URL.
    • Replace ty://?Page=Product&ContentId={ContentId} with:
      https://www.trendyol.com/brand/name-p-{ContentId}
      (Note: you may substitute a placeholder brand/name or derive from stored data if available.)
  • Search Page Deeplink:
    • Page=Search with Query={q} must map to:
      https://www.trendyol.com/sr?q={q}
  • Favorites / Orders Deeplinks:
    • ty://?Page=Favorites or ty://?Page=Orders (and any other non-product, non-search deeplink) both map to the homepage:
      https://www.trendyol.com

Example Requests & Responses

Request (Deeplink) Response (Web URL)
ty://?Page=Product&ContentId=1925865&CampaignId=439892&MerchantId=105064 https://www.trendyol.com/brand/name-p-1925865?boutiqueId=439892&merchantId=105064
ty://?Page=Product&ContentId=1925865 https://www.trendyol.com/brand/name-p-1925865
ty://?Page=Product&ContentId=1925865&CampaignId=439892 https://www.trendyol.com/brand/name-p-1925865?boutiqueId=439892
ty://?Page=Product&ContentId=1925865&MerchantId=105064 https://www.trendyol.com/brand/name-p-1925865?merchantId=105064
ty://?Page=Search&Query=elbise https://www.trendyol.com/sr?q=elbise
ty://?Page=Search&Query=%C3%BCt%C3%BC https://www.trendyol.com/sr?q=%C3%BCt%C3%BC
ty://?Page=Favorites https://www.trendyol.com
ty://?Page=Orders https://www.trendyol.com

Explore Rest APIs

Endpoints Summary

Method Url Description Request Body Path Variable Response
POST /api/v1/convert/url Convert a web URL into a deep link ConversionRequest CustomResponse<ConversionResponse>
POST /api/v1/convert/deeplink Convert a deep link into a web URL ConversionRequest CustomResponse<ConversionResponse>

Technologies


  • Java 21
  • Spring Boot 3.0
  • Restful API
  • Open Api (Swagger)
  • Maven
  • Junit5
  • Mockito
  • Integration Tests
  • Docker
  • Docker Compose
  • CI/CD (Github Actions)
  • Postman
  • Prometheus
  • Grafana
  • Sonarqube
  • Kubernetes
  • JaCoCo (Test Report)

Postman

Import postman collection under postman_collection folder

Prerequisites

Define Variable in .env file

LINKCONVERTER_SERVICE_DB_IP=localhost
LINKCONVERTER_SERVICE_DB_PORT=3306
DATABASE_USERNAME={MY_SQL_DATABASE_USERNAME}
DATABASE_PASSWORD={MY_SQL_DATABASE_PASSWORD}

Open Api (Swagger)

http://localhost:5150/swagger-ui/index.html

JaCoCo (Test Report)

After the command named mvn clean install completes, the JaCoCo report will be available at:

target/site/jacoco/index.html

Navigate to the target/site/jacoco/ directory.

Open the index.html file in your browser to view the detailed coverage report.


Maven, Docker and Kubernetes Running Process

Maven Run

To build and run the application with Maven, please follow the directions shown below;

$ cd linkconverter
$ mvn clean install
$ mvn spring-boot:run

Docker Run

The application can be built and run by the Docker engine. The Dockerfile has multistage build, so you do not need to build and run separately.

Please follow directions shown below in order to build and run the application with Docker Compose file;

$ cd linkconverter
$ docker-compose up -d

If you change anything in the project and run it on Docker, you can also use this command shown below

$ cd linkconverter
$ docker-compose up --build

To monitor the application, you can use the following tools:

  • Prometheus:
    Open in your browser at http://localhost:9090
    Prometheus collects and stores application metrics.

  • Grafana:
    Open in your browser at http://localhost:3000
    Grafana provides a dashboard for visualizing the metrics.
    Default credentials:

    • Username: admin
    • Password: admin
  • AlertManager:
    Open in your browser at http://localhost:9093

Define prometheus data source url, use this link shown below

http://prometheus:9090

Kubernetes Run

To run the application, please follow the directions shown below;

  • Start Minikube
$ minikube start
  • Open Minikube Dashboard
$ minikube dashboard
  • To deploy the application on Kubernetes, apply the Kubernetes configuration file underneath k8s folder
$ kubectl apply -f k8s
  • To open Prometheus, click tunnel url link provided by the command shown below to reach out Prometheus
minikube service prometheus-service
  • To open Grafana, click tunnel url link provided by the command shown below to reach out Prometheus
minikube service grafana-service
  • Define prometheus data source url, use this link shown below
http://prometheus-service.default.svc.cluster.local:9090

Sonarqube

  • Go to localhost:9000 for Docker and Go there through minikube service sonarqube for Kubernetes
  • Enter username and password as admin
  • Change password
  • Click Create Local Project
  • Choose the baseline for this code for the project as Use the global setting
  • Click Locally in Analyze Method
  • Define Token
  • Click Continue
  • Copy sonar.host.url and sonar.token (sonar.login) in the properties part in pom.xml
  • Run mvn sonar:sonar to show code analysis

Docker Image Location

https://hub.docker.com/repository/docker/noyandocker/linkconverter/general

Screenshots

Click here to show the screenshots of project

Figure 1

Figure 2

Figure 3

Figure 4

Figure 5

Figure 6

Figure 7

Figure 8

Figure 9

Figure 10

Figure 11

Figure 12

Figure 13

Figure 14

Figure 15

Figure 16

Figure 17

Figure 18

Figure 19

Figure 20

Figure 21

Figure 22

Figure 23

Figure 24

Figure 25

Figure 26

Figure 27

Figure 28

Figure 29

Figure 30

Figure 31

Figure 32

Contributors

About

Case Study - Link Converter (Java 21, Spring Boot, MySql, JUnit, Jacoco, Prometheus,Grafana, Docker, Kubernetes, Github Action (CI/CD), Sonarqube)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published