CoinTrack is a server-side application developed using Node.js and MongoDB. The app fetches and stores cryptocurrency data and provides APIs to get the latest data and standard deviation for these cryptocurrencies.
- Node.js
- Express
- MongoDB
- Mongoose
- Axios
- Node-cron
-
Clone the repository:
git clone <repository-url> cd cointrack
-
Install dependencies:
npm install
-
Set up environment variables: Create a
.env
file in the root directory and add the necessary environment variables. -
Start MongoDB: Ensure MongoDB is running locally or provide a connection string to a remote MongoDB instance.
- Start the server:
npm start
The server will start on the port specified in the environment variables or default to 3000
.
The API endpoints can be easily tested by using Postman. Here's an example:
- Description: Latest data about the specific cryptocurrency.
- Method: GET
- Query Params:
{ "coin": "bitcoin" // 'bitcoin', 'matic-network', 'ethereum' }
- Sample Response:
{ "price": 40000, "marketCap": 800000000, "24hChange": 3.4 }
- Description: Standard deviation of the price of the cryptocurrency for upto the last 100 records.
- Method: GET
- Query Params:
{ "coin": "bitcoin" // 'bitcoin', 'matic-network', 'ethereum' }
- Sample Response:
{ "deviation": 4082.48 }
The server fetchs the current price (USD), market cap (USD), and 24-hour change of 3 cryptocurrencies: Bitcoin
, Matic
, and Ethereum
.
This job runs once every 2 hours and stores the data in the MongoDB database.
This was deployed to Microsoft Azure URL:
https://cointrack.azurewebsites.net/
The .github/workflows/main_cointrack.yml
file contains CI/CD pipeline config to build and deploy to the above project.
The database is hosted on MongoDB Atlas.