GithubHelp home page GithubHelp logo

lurkingryuu / cryptocurrency-converter Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 132 KB

A server side NodeJs application to convert prices of cryptocurrencies using real time conversion rates

JavaScript 96.87% Dockerfile 3.13%

cryptocurrency-converter's Introduction

Cryptocurrency Conversion Application

Overview

This applicatio provides a service for cryptocurrency conversion. It uses Express.js as the server framework and MongoDB for data storage. This API also saves the available cryptocurrencies every hour in database to avoid calling the external API multiple times. Also provides functionality to get the list of companies holding the currency.

Author

Yelisetty Karthikeya S M, aka lurkingryuu

Running the Application Locally

Installation

  1. Clone the repository
  2. Install the dependencies
  3. Configure the environment variables
git clone [email protected]:lurkingryuu/cryptocurrency-converter.git
cd cryptocurrency-converter
cp .env.example .env
  1. Start the server
npm install
npm start

Environment Variables

The following environment variables are necessary to run the application:

  • MONGODB_URL: The URL of the MongoDB database
  • COINGECKO_API_KEY: The API key for the CoinGecko API

Other environment variables can be found in the .env.example file.

Running the Application in Docker

Docker ce

  1. Clone the repository - same as above
  2. Build the Docker image
  3. Configure the environment variables - same as above
  4. Run the Docker container
docker build -t crypto_converter .
docker run -d --env-file .env -p 8080:3000 --name crypto_converter-1 crypto_converter
  1. Check the health of the API
$ docker ps

CONTAINER ID   IMAGE                    COMMAND                  CREATED              STATUS                        PORTS                     NAMES
15cdc3e4d5d3   crypto_converter         "npm start"              About a minute ago   Up About a minute (healthy)   0.0.0.0:8080->3000/tcp    crypto_converter-1
  1. Access the API at http://localhost:8080
  2. Stop and remove the container after use
docker stop crypto_converter-1
docker rm crypto_converter-1

Docker Compose

  1. Clone the repository - same as above
  2. Configure the environment variables - according to the docker-compose.yaml file
  3. Run the Docker Compose
docker-compose build
docker-compose up -d
  1. Check the health of the API
$ docker ps

CONTAINER ID   IMAGE                          COMMAND                  CREATED         STATUS                   PORTS                     NAMES
f3640494709e   cryptocurrency_converter-app   "npm run start"          7 minutes ago   Up 7 minutes (healthy)   0.0.0.0:3000->3000/tcp    crypto-converter-app
91a941d68da3   mongo:6.0.15-rc0-jammy         "docker-entrypoint.sā€¦"   7 minutes ago   Up 7 minutes             27017/tcp                 crypto-converter-db

Optionally, you can check the logs of the API container

docker compose logs -f
  1. Access the API at http://localhost:3000
  2. Stop and remove the containers after use
docker-compose down --volumes
rm -rf ./data

API Reference

Go to Endpoints for the quick reference.

Postman

The APIs can be run in Postman using the collection provided here

The Documentation can be found here.

Hosted API

The API is hosted on azure based on the workflow in the repository and can be accessed koinx.lurkingryuu.me

Alternate link: koinx.azurewebsites.net

Endpoints

GET /ping

This endpoint is used to check the health of the API.

Request:

GET /ping

Response:

HTTP/1.1 200 OK
Content-Type: application/json

"Pong!"

POST /convert

This endpoint is used to convert a cryptocurrency to another cryptocurrency.

Request:

POST /api/convert

{
    "fromCurrency": "bitcoin",
    "toCurrency": "basic-attention-token",
    "date": "12-01-2024"
}

Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "rate": 176558.73727068843
}

POST /api/companies-holding

This endpoint is used to get the list of companies holding the currency in descending order based on total holdings.

Request:

POST /api/companies-holding

{
    "currency": "ethereum"
}

Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "count": 2,
    "companies": [
        "Meitu Inc",
        "Mogo Inc."
    ]
}

cryptocurrency-converter's People

Contributors

lurkingryuu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.