GithubHelp home page GithubHelp logo

price-is-right's Introduction

myRetail RESTful service

RESTful service that can retrieve product and price details by ID. Prices can also be updated.

The products are retrieved by ID from an external service. The prices are stored in myRetail internal database with key being the product id.

The service is hosted in Heroku which is a cloud Platform as a Service (PaaS). Heroku was chosen as it is good for spinning up proof-of-concepts quickly without having to focus on the deployment details.

Try it out

You can try on the hosted demo site via swagger:

http://price-is-right-rstruthers.herokuapp.com/swagger-ui.html

Example product ids

Valid ids

16696652, 13860428, 138604289

Invalid ids

15117729, 16483589, 16752456, 15643793

Framework used

Spring Boot was chosen as the framework because it enables rapid development of robust Java based applications. Making use of the spring-boot-starter-data libraries makes it easy to build a RESTful application and have the application plug in to a database of the developer's choosing.

Spring Boot is also well-documented and there are many tutorials and examples out on the web.

Database used

Cassandra, a NoSQL database is used to store the prices for products. The product id is they key.

Cassandra was chosen as it was designed to handle large amounts of data across many servers. This is appropriate for a multi-national corporation such as myRetail. The fetching of data is very fast and there is not a single point of failure. Furthermore, Cassandra scales well. New servers can be added as more capacity is needed.

The database is provided by Instaclustr Heroku plugin which hosts the database in AWS.

Get the code

git clone https://github.com/rstruthers1/price-is-right

Build instructions - local

Run the following command:

./gradlew clean build

Run the unit tests and generate test coverage reports - local

Run the following command:

./gradlew clean test jacocoTestReport

If there is a test failure, check the test results in build/reports/tests/test/index.html

The test coverage metrics are provided by the JaCoCo plugin. The minimum coverage currently is set at 75% for every coverage category.

If the coverage is below 75% for any coverage category, then the build will fail. Please add more unit tests. To check the coverage report, see: build/reports/jacoco/test/html/index.html

If the tests pass and the coverage is above 75%, a coverage report will be printed out at the console. Example:

- instruction coverage rate is: 94.31%, minimum is 75%
- branch coverage rate is: 100.0%, minimum is 75%
- line coverage rate is: 92.54%, minimum is 75%
- complexity coverage rate is: 80.95%, minimum is 75%
- method coverage rate is: 77.78%, minimum is 75%
- class coverage rate is: 83.33%, minimum is 75%
Passed Code Coverage Checks

To Run - local

Run the following command:

./gradlew bootRun

Deploy to heroku

Deploy will happen to heroku upon any push to master in github

Endpoints - local

Get product price

GET http://localhost:8080/products/{id}

Headers:

Accept:application/json

Update product price

PUT http://localhost:8080/products/{id}

Headers:

Accept:application/json
Content-Type:application/json

request body

{
    "value": 12.29,
    "currency_code": "USD"
}

Endpoints - remote

Get product price

GET http://price-is-right-rstruthers.herokuapp.com/products/{id}

Headers:

Accept:application/json

Update product price

PUT http://price-is-right-rstruthers.herokuapp.com/products/{id}

Headers:

Accept:application/json
Content-Type:application/json

request body

{
    "value": 12.29,
    "currency_code": "USD"
}

price-is-right's People

Contributors

rstruthers1 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.