Kotlin Based Spring Boot ETL project

Overview

Adverity ETL REST API (AERA)

A simple ETL Spring Boot application with H2. This API provides the following basics functionalities:

  1. Endpoint that returns a list of WebTracking objects for dataSource and optional parameters: campaign and range of date.
  2. Endpoint that returns aggregated statistic values like count, sum, min, max, avg per metric and dataSource. Optional parameters: campaign and range of date.
  3. Endpoint that returns a statistics summary for the given datasource and optional parameters: campaign and range of date.

Design considerations

  • The API supports two levels of security by using Spring Security and JSON Web Token.

  • Logging: SL4J was used to decouple from any specific implementation. The underlying logging is provided by Log4J. To avoid any locking with a specific filesystem location, the generated logs are sent to the STDOUT console.

  • Exception handling: all the errors and exceptions are gracefully managed and mapped to the corresponding HTTP status code.

  • Documentation: all the main classes are intradocumented (Javadocs) and also the API is exposed via Swagger.

  • No hard coded values. All the config properties are defined in the application.properties file

  • Test coverage: the main functionalities were tested (integration tests) to validate their proper functionality.

Stack

  • Kotlin 1.5.31
  • Java 11
  • Spring Boot 2.5.5
  • H2
  • Kotlin Logging, SL4J & Log4J
  • Maven
  • JUnit 5

Getting Started

In order to start the application locally and run the APIs, you should execute from a command line the following instruction:

./mvnw spring-boot:run

You must be inside the base project directory the previous command.

After this the Adverity ETL REST API (AERA) will start.

Deployment

The application is fully deployed on Heroku and it is accessible at: https://etl-rest-api.herokuapp.com

Running the web services

  1. To get access to the API, you should get a token in the following endpoint:

    https://etl-rest-api.herokuapp.com/v1/security/generate-token?subject=appSubject

    HTTP method: GET

    Using BASIC auth with the following credentials:

     username=adverity
     password=adverity2021
    

    And adding to the header:

     Content-Type=application/json
    

    After invoking this endpoint you will get something like this:

      "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ3ZWF0aGVyU3ViamVjdCIsImV4cCI6MTUzOTU2NzI0OX0.J3Xli1EV-T_cP-nQ_uJbkYGcYJdGINSvlmrwC6cSiHY"
    

    You should copy all the result value (this is the generated token) in order to invoke the other secured endpoints.

  2. After generating the token, you can get the list of WebTracking objects for dataSource and optional parameters:

    https://etl-rest-api.herokuapp.com/v1/adverity/web-trackings/data-sources//Google Ads?campaign=GDN_Retargeting

    HTTP method: GET

    Header parameters:

           Authorization:Basic dXNlcjpmbGFjb25pQDIwMTg=
    
          Content-Type:application/json
    
          authorizationToken:eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJjYXRlZ29yeVN1YmplY3QiLCJleHAiOjE1NDQzMTU1NjZ9.D-_UsI_YiAWSTKXxAlyDc9aQhOZwP71HZzJC4dyeYM0
    

    Response:

    [
        {
            "dataSource": "Google Ads",
            "campaign": "Adventmarkt Touristik",
            "daily": "2019-11-14",
            "clicks": 147,
            "impressions": 80351
        },
        {
            "dataSource": "Google Ads",
            "campaign": "Adventmarkt Touristik",
            "daily": "2019-11-15",
            "clicks": 131,
            "impressions": 81906
        }
    ]
    
  3. To get the list of aggregated statistic values per metric and dataSource:

    https://etl-rest-api.herokuapp.com/v1/adverity/statistics/metrics/IMPRESSIONS/data-sources/Google Ads?campaign=GDN_Retargeting

    HTTP method: GET

    Header parameters:

      Authorization:Basic dXNlcjpmbGFjb25pQDIwMTg=
    
      Content-Type:application/json
    
      authorizationToken:eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJjYXRlZ29yeVN1YmplY3QiLCJleHAiOjE1NDQzMTU1NjZ9.D-_UsI_YiAWSTKXxAlyDc9aQhOZwP71HZzJC4dyeYM0
    

    Response:

    {
        "metric": "IMPRESSIONS",
        "count": 405,
        "sum": 18991655,
        "min": 13596,
        "max": 130041,
        "avg": 46892.98
    }
    
  4. To get the statistics summary for the given datasource and optional parameters:

    https://etl-rest-api.herokuapp.com/v1/adverity/summary-statistics/data-sources/{dataSource}/Google Ads?campaign=GDN_Retargeting

    HTTP method: GET

    Header parameters:

      Authorization:Basic dXNlcjpmbGFjb25pQDIwMTg=
    
      Content-Type:application/json
    
      authorizationToken:eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJjYXRlZ29yeVN1YmplY3QiLCJleHAiOjE1NDQzMTU1NjZ9.D-_UsI_YiAWSTKXxAlyDc9aQhOZwP71HZzJC4dyeYM0
    

    Response:

    {
     "statsPerMetrics": [
         {
             "metric": "CLICKS",
             "count": 410,
             "sum": 6454,
             "min": 1,
             "max": 42,
             "avg": 15.74
         },
         {
             "metric": "IMPRESSIONS",
             "count": 410,
             "sum": 183048,
             "min": 23,
             "max": 1238,
             "avg": 446.46
         }
     ],
     "clickThroughRate": 0.04  
     }
    

##Restrictions As this service is an ETL POC, there is still room for improvement, like:

  • Caching, at the client level (ETags) for GET retrieval operations, and at the application level (Redis to cache the service results).

  • Comprehensive testings for all the layers.

  • More robust API for querying data.

  • Pagination.

  • Addressing some performance improvements.

More info

You can check all the functionalities exposed by this API in: https://etl-rest-api.herokuapp.com/swagger-ui.html

Adverity ETL REST API (AERA)

Built With

  • Maven - Dependency Management

Authors

License

Apache License 2.0.

Acknowledgments

  • To the all open source software contributors.
You might also like...
Generated with spring boot kotlin starter kit

Kotlin backend Generated with spring boot kotlin starter kit The idea is to: Get a microservice written in kotlin for managing users and roles. To be

An application that simulate the Swedish Transport Agency, implemented with Spring Boot, Kotlin and GraphQL

graphql-kotlin-spring-server An application that simulate the Swedish Transport Agency, implemented with Spring Boot, Kotlin and GraphQL Running the s

API for a library using Kotlin, Spring-boot and covered by test

Library API This API is to create Books and be able to borrow from them I'm using: Spring Boot version 2.5.6 Kotlin 1.5.31 Java 11 I'm implementing us

Push notification application using One Signal + Spring Boot + Kotlin

Spring Boot push notification system using One Signal This project was created to demonstrate a simple application built with Kotlin + Spring Boot inc

API Rest With Kotlin And Spring Boot

##API REST WITH KOTLIN AND SPRING BOOT GET Url: http://localhost:8080/customers Response (Status Code: 200 Ok) { "_embedded": { "customer

Créer un microservice avec Spring Boot et Kotlin
Créer un microservice avec Spring Boot et Kotlin

🚀 Créer un microservice avec Spring Boot et Kotlin Ce dépôt contient les slides et la démo du talk "créer un microservice avec Spring Boot et Kotlin"

Cloud Bowl Sample - Kotlin Spring Boot

Cloud Bowl Sample - Kotlin Spring Boot To make changes, edit the src/main/kotlin/hello/KotlinApplication.kt file. Run Locally: ./mvnw spring-boot:run

Spring Boot built using Kotlin, H2, Postgres, Hibernate and JPA

Spring-Boot-Kotlin-Sample Spring Boot built using Kotlin, H2, Postgres, Hibernate and JPA Getting Started Reference Documentation For further referenc

MaxonBank is a Kotlin + Spring Boot + Axon Framework application that supports opening, depositing to, and withdrawing from accounts.

MaxonBank MaxonBank is a Kotlin + Spring Boot + Axon Framework application that supports opening, depositing to, and withdrawing from accounts. The ap

Owner
null
Spring Boot project scaffold written in Kotlin, which is based on the Official Guide.

Kotlin-Spring-Boot Spring Boot project scaffold written in Kotlin, which is based on the Official Guide. Development environment Windows choco install

idea2app 1 Feb 27, 2022
Spring-graphql-getting-started - Spring for GraphQL provides support for Spring applications built on GraphQL Java

Getting Started with GraphQL and Spring Boot Spring for GraphQL provides support

Shinya 0 Feb 2, 2022
Sample Social Login Project of Spring Boot and Kotlin

Sample-Spring-Boot-Social-Kotlin Sample Social Login Project of Spring Boot and Kotlin dependencies dependencies { implementation("org.springframewor

Seokhyun 2 Oct 11, 2021
The Okila server project uses the Spring boot framework and uses the Kotlin language

Okila-Server The Okila server project uses the Spring boot framework and uses the Kotlin language Format Response //The response successfully format

Nankai 1 Oct 25, 2021
Grocery - A simple CRUD Project using Spring Boot, Kotlin and MongoDB

Grocery - A simple CRUD Project using Spring Boot, Kotlin and MongoDB

null 3 Aug 10, 2022
Spring boot cloud tool usage trail and learning project

Spring boot cloud tool usage trail and learning project Todo Maven based multi-p

Yaoyu He 0 Dec 26, 2021
A spring-boot project that demonstrates data caching using Redis

A spring-boot project that demonstrates data caching using Redis

Sakawa Bob 1 Mar 26, 2022
A sample skeleton backend app built using Spring Boot kotlin, Expedia Kotlin Graphql, Reactive Web that can be deployed to Google App Engine Flexible environmennt

spring-kotlin-gql-gae This is a sample skeleton of a backend app that was built using: Spring Boot(Kotlin) Reactive Web Sprinng Data R2DBC with MYSQL

Dario Mungoi 7 Sep 17, 2022
Spring Boot Example with Kotlin and Domain Driven Design

Spring Boot Kotlin Domain Driven Design Example Just an example project where ddd is implemented with some other great patterns and architecture from

Fernando Guevara Sanchez 16 Jun 29, 2022
This repository demonstrates how Kotlin can simplify Spring Boot configuration properties file mapping

Kotlin spring-boot nested config props This repository demonstrates how Kotlin can simplify Spring Boot configuration properties file mapping @Constru

Maksim Kostromin 1 Oct 11, 2021