This repository is the answer to the technical test at Flowdesk. More info in the instruction
- Clone the repository with
git clone
. - Make sure your node version is
node@22
. If you usevolta
it should automatically be set up with the right one. - Run
npm i
to install dependencies. - Now you can
- Test your app with
npm run test
- Run your app in dev mode with a watcher with
npm run dev
- Build your app with
npm run build
- Start your production app with
npm run start
- Test your app with
How to access the project?
Once running, 2 endpoints are available:
- a healthcheck, at http://127.0.0.1:3000
- the global price index getter, at GET
/global-price-index/:baseAsset/:quoteAsset
(see http://127.0.0.1:3000/global-price-index/BTC/USDT as an example)
This project is written in typescript, build with tsc
and babel
and executable with node
.
This project is using volta, the field .volta
in package.json
file can help to pin the node's version on our development computer.
This project doesn't use any database, everything is handled in memory. This is obviously not working for a real life usage, but for this technical test it is well enough.
As we need to take into consideration we may add new exchanges later, or new cryptos, this project can evolve.
To add a new crypto, it will be needed to
- add it in the
config/default.json
config file (service.globalPriceIndex.handledCryptos
attribute) - handle the new crypto in the encoders in
src/clients/*/codec.ts
- update the
supportedPairs
insrc/domain/crypto.ts
To handle a new exchange, you will need to
- add it in the
config/default.json
config file along with its URIs (clients
attribute) - add it in the
exchanges
variable insrc/domain/exchange.ts
- create the client in
src/clients
(do not forget to export it in theindex.ts
) - create the exchange library in
src/libraries/exchanges
(do not forget to export it in theindex.ts
) - add the new builder in
src/libraries/globalPriceIndex/index.ts
The dev-x is pretty poor so far. It would be a lot healthier to add at least
- hooks to typecheck and lint on git commit
- some CI to automatically run test on PR
Ideally, we would have contract tests. At the deploy step, an action would subscribe to the 3 APIs we use to get the specs (in OpenAPI format or any other one) and validate our clients against it. I have no idea if such an API specification format exist for websockets though ¯\_(ツ)_/¯
We can also consider adding service tests, which hasn't been done here to timebox the project.
I'm not a crypto-pro; hence, it's very possible that some variable namings happen to be poor, and don't fit the domain in the best way. In any case, with a better domain-knowledge, I could have done a better code.
Licensed under Beer-ware.