Giter VIP home page Giter VIP logo

king-spring-service's Introduction

King Spring Service

CI

About

Basic middleware REST API made in Spring that fetches online product data and creates endpoints from which we can:

  • search all products (product attributes are: name, price, short description and image)
  • search specific products (specified by the product's id)
  • search all categories
  • search products by keywords
  • filter products by price and/or category

Prerequisites

You have to install Docker and Docker Compose.
Everything else will be installed automatically by following the steps in the Installation section.

Installation

1. Clone the repository

With GitHub account:

git clone https://github.com/PjotrVr/king-spring-service
cd king-spring-service

Or with SSH:

git clone [email protected]:PjotrVr/king-spring-service.git
cd king-spring-service

2. Start application in a docker container (detach mode)

docker-compose up --build -d

3. Exit application

docker-compose down

Usage

Since this is just a REST API and not an actual app, I'd recommend using tools like Postman or Insomnia for easier usage.

If you don't have any of such tools, you can still make requests by using your browser and devtools extension.

Available endpoints:

  • GET /products: fetches all products
  • GET /products/categories: fetches all products and makes a list of distinct categories
  • GET /products/{id}: fetches specific product by its id if it exists
  • GET /products/filter?{filter}: fetches all products and then filters them by category and price range
  • GET /products/search?{query}: fetches all products and returns sorted list based on query-to-product matching algorithm

For more detailed explanation of endpoints, read API documentation.

Configuration

Everything that is configurable is inside .env file.

Parameters that you can change:

  • PORT: port that server will run on, DEFAULT: 8080
  • DB_NAME: database name, DEFAULT: springdb
  • DB_USERNAME: database username, DEFAULT: admin
  • DB_PASSWORD: database password, DEFAULT: admin
  • LOG_FILE: name of logging file, DEFAULT: application.log

By default, you can access database through h2 console.

Start the application.

Go to /h2-console and login with .env information. Don't forget to set path to database.

TODO

Basic:

  • Implement /products endpoint
  • Implement /products/categories endpoint
  • Implement /products/{id} endpoint
  • Implement /products/filter endpoint
  • Implement /products/search endpoint

Nice to have:

  • Add tests for all endpoints
  • Add basic authentication and authorization
  • Add logging
  • Add caching for similar product retrieval
  • Add docker

king-spring-service's People

Contributors

pjotrvr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.