Implement a background job that will fetch the current price in USD, market cap in USD and 24 hour change of 3 cryptocurrencies: Bitcoin, Matic, and Ethereum and store it in a database. This job should run once every 2 hours.
Used node-cron libraray to setup the Cron Jobs and wrote the "fetchCryptoData" function that fetches the required data from CoinGecko's API. Stored it in MongoDB Database.
Implement an API "/stats", that will return the latest data about the requested cryptocurrency.
Created a route with all the error and edge case handling to retrieve the latest fetched data from our MongoDB Server.
Working Routes:
https://fetch-crypto.fly.dev/stats?coin=matic
https://fetch-crypto.fly.dev/stats?coin=bitcoin
https://fetch-crypto.fly.dev/stats?coin=ethereum
Implement an API "/deviation", that will return the standard deviation of the price of the requested cryptocurrency for the last 100 records stored by the background service in the database.
Created a route with all the error and edge case handling to retrieve the latest fetched data from our MongoDB Server and applied the standard deviation formula on that.
Working Routes:
https://fetch-crypto.fly.dev/deviation?coin=matic
https://fetch-crypto.fly.dev/deviation?coin=bitcoin
https://fetch-crypto.fly.dev/deviation?coin=ethereum
Deploy your database using MongoDB Atlas or other similar tools.
Used the MongoDB Atlas to remotely host our Database.
Deploy your backend using platforms like Heroku or any cloud platform like AWS, GCP or Azure and expose the API to the public.
Deployed on Fly IO for seamlessly running our backend server.
Test Link: https://fetch-crypto.fly.dev/ping
Think of this assignment as a production grade project. Using best practices, writing clean code etc. will fetch you additional points.
Used a clean code approach that follows modularity. Used Controllers that are used for validations in the API's.
Wrote Services that handles the functionality requested by the particular controller.
Used Repository Section which is responsdible for interacting with the database.
Took the help of "Prettier" npm library to keep the consistency in the syntax of the code.
Followed a well-structured production ready way to approach the code.
Do think well about how you want to design your database schemas.
Designed a clean and concise schema that helps retrieves and stores the data in the DB Optimally.
We care about the usage of version control and the way you structure(and name) your commits!
Used Git and Github for version control. Committed the changes with the understandable names.
Clone this Repository
Create a .env file and write all the fields present in .env.sample file
npm install
npm run dev