Skip to content

Application Design

Sven Loesekann edited this page Apr 19, 2018 · 2 revisions

Main Design

The goal is to have a fully reactive frontend from db to ui. To enable such a design the Frontend needs to be reactive and the backend too. Angular and the reactive features of Spring provide the needed features. The data import and data preparation needs to be separated from the ui part of the application to offer good response times.

Frontend

Angular is reactive if promises or observables are used to communicate with the server. This project uses observables to have just one reactive pattern in the frontend code.

Backend

Spring offers the reactive features in Version 2. That means a reactive db driver is needed(MongoDB in this case) and a db to store the data. The reactive part can be found in the controllers of the rest interface like 'BitfinexController' . The quotes a read of the db and are provided as Flux or Mono to enable the reactive features of Spring.

Data Import

To get the quotes from the exchanges the scheduled task 'ScheduledTask' is run. It requests the quotes once a minute of the exchanges and stores them in the collections of the db. The scheduled tasks have a config 'SchedulingConfig' that provides a separate thread pool to the task and decouples them of the Controllers.

Data Preparation

To provide 7 day, 30 day, 90 day charts db collections with hourly and daily data are needed. To provide the collections once a day between 0 and 2 o'clock the 'PrepareData' task is run. It takes the quotes of the 'ScheduledTask' and calculates the averages per hour and per day and stores them in its own collections in the db. As as scheduled task the it also gets the thread of the scheduling thread pool.

Clone this wiki locally