Skip to content

DepraTb/revolut

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

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.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published