Giter Club home page Giter Club logo

revolut's Introduction

Backend Test

Design and implement a RESTful API (including data model and the backing implementation) for money transfers between accounts.

1. How to start?

  1. In project directory run gradlew clean build on Windows or ./gradlew clean build on UN*X to compile, run tests and package the application.
  2. Go to build/libs and run the application via java -jar transfer-service.jar. It will start server on 8080 port (if you want to change the port, you should run application via java -Dhttp.port=other_port_number -jar transfer-service.jar, where other_port_number - number of http port which you prefer).

2. Implementation details

Third-party libraries

  1. Javalin - A simple web framework
  2. H2 - Java SQL database
  3. Flyway - A database migration tool
  4. Guice - DI framework
  5. Lombok - An annotation-based code generator

Problems

  1. H2 is used as data storage. This causes a file system to become clogged with database stuff (doesn't take up much space, because when the application starts and stops, flyway is clearing the data).
  2. The application supports transactions only on DAO-level.

3. API

All requests to the API are relative http://localhost:port

Endpoints

Endpoint Description Parameters Success Response/Status Code
POST
/account/:balance
Creates new account with specified balance :balance - balance on account
{
    "id": id,
    "balance": balance
}

201 CREATED
GET
/account/:id
Returns account by id :id - account's id
{
    "id": id,
    "balance": balance
}

200 OK
DELETE
/account/:id
Deletes account by id :id - account's id 204 NO CONTENT
POST
/account/:fromId/transfer/:toId/:amount
Transfers specified amount of money from account to another account
:fromId - account's id that balance will be reduced
:toId - account's id that balance will be increased
:amount - amount of money which will be transferred
204 NO CONTENT

Possible Errors

Status Code Error
404 NOT FOUND Account was not found.
400 BAD REQUEST The balance value must not be negative.
400 BAD REQUEST The transfer of money to the same account is not allowed.
400 BAD REQUEST Not enough money on balance.
4**, 5** Other unhandled errors.

revolut's People

Contributors

depratb avatar

Watchers

 avatar

Forkers

abmessaoud

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.