Skip to content

Simple Spring Boot application to ingest and process currency trade records

Notifications You must be signed in to change notification settings

whokc-github/currencyTrade

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CurrencyTrade

This is a very simple Spring Boot RESTful API application that basically ingests current trade records and performs simple CRUD operations. All operations are offered by the API backend service. The webpage is for viewing all current records in database only. For quick prototyping purpose, the H2 in-memory database is used.

API Reference

1. Get all trades in database

  GET /currencytrade/all
Parameter Type Description
N/A Not needed

Example API link:

localhost:8080/currencytrade/all

2. Get all trades for user

  GET /currencytrade/find/${userId}
Parameter Type Description
userId number Required. Id of user

Example API link:

localhost:8080/currencytrade/find/564999

3. Create new trade record

  POST /currencytrade/add/
Parameter Type Description
N/A Not needed

Sample JSON record for this operation (if use Postman, select "raw" under "Body" tab, and choose "JSON" as document type, then paste below sample):

{
    "userId": "564999",
    "currencyFrom": "EUR",
    "currencyTo": "GBP",
    "amountSell": 1000,
    "amountBuy": 747.10,
    "rate": 0.7471,
    "timePlaced": "24-JAN-21 16:30:44",
    "originatingCountry": "FR"
}

Example API link:

localhost:8080/currencytrade/add

4. Process trade record

  PUT /currencytrade/process/${id}
Parameter Type Description
id number Unique database record ID

Update/patch the "Amount Sell" value:

amountSell = multiply(amountBuy, rate)

Example API link:

localhost:8080/currencytrade/process/1

5. Delete trade records for a user

  DELETE /currencytrade/delete/{userId}
Parameter Type Description
userId number Required. Id of user

Delete all records belonging to a user

Example API link:

localhost:8080/currencytrade/process/1

Authors

Installation

Simply download the project mkt_trade_processor from github. The project source can be viewed and edited using IntelliJ IDEA.

To download dependencies, simply open a Terminal/Command Prompt and go to the project directory (mkt_trade_processor), and use below mvn command.

mvn package

Usage/Examples

Use Postman (or any similar tool) to call the APIs.

Web page (read-only) can be access via the link:

http://localhost:8080/

Screenshots

App Screenshot App Screenshot ![App Screenshot](src/main/resources/image/In_memory_DB_H2 Console_login.jpg) App Screenshot

Run Locally

Clone the project

  git clone https://github.com/whokc-github/currencyTrade.git

Go to the project directory

  cd currencyTrade

Start the server

  java -jar ./target/mkt_trade_processor-0.0.1-SNAPSHOT.jar

The server will be running on localhost:8080

The in-memory DB can be accessed via the link:

http://localhost:8080/h2-console

H2 DB Login:

Driver Class: org.h2.Driver
JDBC URL: jdbc:h2:mem:tcp:crm
User Name: sa
Password: <blank>

Use SQL to check data:

SELECT * FROM CURRENCY_TRADE;

Running Tests

To run tests, run the following command in project folder.

  mvn test

About

Simple Spring Boot application to ingest and process currency trade records

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published