Giter Club home page Giter Club logo

market-trade's Introduction

Market Trade - Realtime Charts

Message Consumption

The endpoint handle the POST requests asynchronously via the java.util.concurrent.Callable class.

The TradeMessages are stored into MongoDB which is schema-less and easy to scale out.

In regards to performance, the endpoint was load tested with [Apache jMeter] (http://jmeter.apache.org/) making 1000 concurrent requests on a local env.

Message Processor

The TradeMessageController uses the StatisticService, which pull data from MongoDB and creates the statistics.

StatisticService sends data through websockets from the server to the client in realtime via 2 channels.

Channel '/init' broadcasts the initial data to render the Charts right after the connection of the client (browser) to the socket.

Channel 'topic/charts' broadcasts new Statistics right after the creation of every TradeMessage.

Message Frontend

The front-end draws the Charts built with Google Visualization API to display data in realtime.

Tech Stack

  • Java 1.8
  • Spring Boot /Spring MVC
  • Mongo (noSql db)
  • Gradle (build)
  • Websocket/Stomp (realtime messages)
  • Thymeleaf (template engine)
  • Google Visualization API (realtime charts)
  • TwitterBootstrap (css)
  • jUnit Mockito (testing)

Prerequisites

Setup

  • Clone the repo git clone https://github.com/pangio/market-trade.git
  • Build ./gradlew clean compile
  • Run ./gradlew bootRun

Endpoints / Http Methods

  • Returns the list of all Trade Messages.

GET: http://localhost:8080/trades

  • Finds a Trade Message by id.

GET: http://localhost:8080/trades/{tradeMessageId}

  • Creates a new Trade Message.

POST: http://localhost:8080/trades

JSON body example:

{
    "userId" : "134256",
    "currencyFrom" : "EUR",
    "currencyTo" : "GBP",
    "amountSell" : 1000,
    "amountBuy" : 4338,
    "rate" : 5.43,
    "timePlaced" : "14-JAN-15 10:27:44",
    "originatingCountry" : "FR"
}

Tests

  • Under the test source folder find the suite com.cf.markettrade.AllTests.java

Statistics - Realtime Charts

Just browse http://localhost:8080/statistics

Screenshots

Alt text Alt text Alt text

NOTES

  • Content Type should be set to application/json .
  • Mongo sholud be running on localhost with the default values as port=27017 and dbpath=/data/db

market-trade's People

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.