Git Product home page Git Product logo

n26codingassignment's Introduction

n26CodingAssignment

A REST application to add transactions and retrieve the statistics of the last 60 seconds

Run project with Maven.

git clone https://github.com/soumyamishra89/n26CodingAssignment.git
cd "folder containing the above repository"
mvn clean install
mvn spring-boot:run

To run the test.

cd "folder containing the above repository"
mvn test

API Documentation

There are two endpoints \transactions and \statistics.

transactions

This endpoint will verify if the Transaction received is within the last 60 seconds of the current time and if valid then it will add the amount of the transaction to a Statistic. The transaction will be added to the Statistic corresponding to a particular second of the last minute.
e.g. if the system time is 12:00:01 and a transaction of time 11:59:40 arrives, then the application will get the Statistic corresponding to '40' second and add the amount to the total amount. Before adding the amount the application will check if the time on the Statistic is equal to time on Transaction (without the millis). If it is not equal then it will override the value on the Statistic with the Transaction values. Only 60 seconds of Statistic information is stored and rest are discarded.

Request

POST /transactions

Request Body

{
	"amount": 12.3,
	"timestamp": 1478192204000
}

Response
returns empty body with 201 or 204 status code

  • 201: when a transaction is added to Statistic
  • 204: when the transaction is not valid

statistics

This endpoint calculates statistics of all the transaction in the last 60 seconds. The overall statistics is calculated when a transaction is sent and this API call only retrieves the value.

Request

GET /statistics

Response
returns statistics json with 200 status code

{
	"sum":45.78,
	"avg":11.46,
	"max":19.87,
	"min":5.89,
	"count":4}

Herokuapp

The code is deployed on heroku app and can be accesses via the following API

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.