-
Notifications
You must be signed in to change notification settings - Fork 46
Application 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.
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. The Frontend shows howto provide 2 translations with Angular and uses request rewriting for it.
Spring Boot 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.
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.
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.
To provide stateless security for the orderbook api Jwt tokens are used. The tokens are provided/signed by the backend stored by the frontend and used for authentication of the oerderbook api.