Code Monkey home page Code Monkey logo

fund-transaction-api's Introduction

The task is to build a simple REST API using Spring Boot Framework and PostgreSQL.

API TASK

Implement a transaction API for enabling fund transfer between users.

SUBTASK 1: Database Design

  • You will use PostgreSQL as your choice of database for this assignment.
  • Create sql scripts for database creation. It should be possible to setup the db with a single terminal command.
  • Load a users table from spec/users.json with a load script. You can use any language for this (python, js, raw sql, shell, etc) but it must be automated.
  • The transactions table should have valid {senderId, receiverId}. Both these values should belong to a valid users. Bonus points if you use foreign keys!

SUBTASK 2: Retrieve a transaction

GET: /api/transactions/<transactionId>

  • Returns transaction information for a given transaction Id. Check spec/transaction.json for the transaction format.

SUBTASK 3: Retrieve all transactions

GET: /api/transactions/

  • Returns all transactions [list of spec/transaction.json]

SUBTASK 4: Create a new transaction

POST: /api/transactions/

  • Creates a new transaction.
  • Payload will contain {senderId, receiverId, amount, details}.
  • Transaction Id will be autogenerated on backend - should be uuid!.
  • Validate the transaction to check if balance is sufficient in sender's account.
  • Store the transaction in the database.

SUBTASK 5: Reverse a transaction

DELETE: /api/transactions/<transactionId>

  • Reverses a transaction and restores the senders and receivers balance accordingly.

Steps to Install

Load Script

  • Install psycopg2 using:
    pip install psycopg2
    
  • Run the python script to load the users.json to PostgreSQL database server
    python script.py <your username> <your password> <hostname> <portname>
    
    Here hostname and portname are optional and can be omitted:
    python script.py <your username> <your password>
    

Application Properties

  • Navigate to application.properties in the resources folder
  • Change the default username and password to your own PostgreSQL server's username and password:
    spring.datasource.username=yourusername
    spring.datasource.password=yourpassword
    
  • If your host and port are different from defaults, change the JDBC url.\

From:

  spring.datasource.url=jdbc:postgresql://localhost:5432/neowise

To:

  spring.datasource.url=jdbc:postgresql://<your host>:<your port>/neowise

All set! Now run the Spring Boot Application!

fund-transaction-api's People

Contributors

nuuron avatar

Watchers

 avatar

fund-transaction-api's Issues

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.