Skip to content

anishpanthi/bootiful-aggregator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting Started

Bootiful Aggregated Book Service

Introduction

Bootiful Aggregated Book Service is a Spring Boot application that demonstrates the aggregation of paginated results from two different tables, BookA and BookB. The application provides a single endpoint to fetch combined paginated results from both tables, ensuring consistent and accurate pagination.

Features

  • Aggregates data from two separate tables within the same application.
  • Supports pagination to display a specified number of records per page.
  • Ensures efficient data fetching and aggregation.
  • Simplifies the aggregation logic by using dynamic offsets.

Table of Contents

Setup

Prerequisites

  • Java 21 or higher
  • Gradle
  • H2 (or any other relational database)

Installation

  1. Clone the repository:

    git clone https://github.com/anishpanthi/bootiful-aggregator.git
    cd bootiful-aggregator
  2. Configure the database:

    This application uses H2 In-Memory database, so you can leave the database configuration as it is in the application.yml file If you want to use your own database like PostgreSQL, you can configure it in the application.yml file:

    spring:
      datasource:
        url: jdbc:postgresql://localhost:5432/your-database
        username: your-username
        password: your-password
        driver-class-name: org.postgresql.Driver
        initialization-mode: always
      jpa:
        hibernate:
          ddl-auto: update
        defer-datasource-initialization: true

    Ensure that schema.sql and data.sql are placed in the src/main/resources directory. Sample is provided in the repository.

  3. Build the application:

    ./gradlew build
  4. Run the application:

    ./gradlew bootRun

Usage

Once the application is running, you can access the aggregated books endpoint to fetch paginated results.

Example Request

To fetch the first page with 5 records:

GET http://localhost:8080/aggregator/api/books?page=0&size=5
{
  "content": [
    {
      "id": 1,
      "title": "Book A1",
      "source": "A"
    },
    {
      "id": 1,
      "title": "Book B1",
      "source": "B"
    },
    {
      "id": 2,
      "title": "Book A2",
      "source": "A"
    },
    {
      "id": 2,
      "title": "Book B2",
      "source": "B"
    },
    {
      "id": 3,
      "title": "Book A3",
      "source": "A"
    }
  ],
  "page": {
    "size": 5,
    "number": 0,
    "totalElements": 10,
    "totalPages": 2
  }
}

Reference Documentation

For further reference, please consider the following sections:

Guides

The following guides illustrate how to use some features concretely:

Additional Links

These additional references should also help you:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages