A mock digital currency exchange platform which allows users to buy and sell Bitcoin and Ethereum based on actual real-time market price. This web application is built with Sinatra Ruby framework. Features inspired by Coinbase exchange.
This app is deployed in Heroku: https://coin-exchange-sinatra.herokuapp.com/
The goal of creating this application to practice translating high-level requirements into working code, integrating third-party web APIs and translating them into user-friendly interfaces and charts. Dynamic input forms were rendered through the use of jQuery. Performance bottlenecks such as slow loading speed were addressed.
Clone or download this git repository. Within the terminal opening the root of this project, execute the following line to install dependencies:
bundle install
To run the server locally, execute:
bundle exec ruby cx.rb
Once Sinatra is running in the background, open up a web browser and enter localhost:4567
in the URL address bar to begin.
Third-party APIs are used to integrate real-time BTC and ETH prices into the application and to display a 30-day BTC and ETH chart.
- API for real-time BTC and ETH prices: https://min-api.cryptocompare.com/data/pricemulti?fsyms=BTC,ETH&tsyms=USD
- API information for historical hourly price data: https://www.cryptocompare.com/api/#-api-data-histohour
In the case where the application fails to fetch real-time data, the last retrieved price data will be used. This will apply to buy/sell prices as well as historical chart data. It is possible to run the application entirely off-line. For the best user experience, it is recommended that you have an active Internet connection.
User will receive a sign-up bonus funding of virtual USD balance into their account, which can be used to purchase mock BTC or ETH.
If you do not wish to create a new account, you can use the default credentials:
- username:
admin
- password:
secret
Signed-in user will be automatically logged out after a certain period of inactivity. On every account action (buy/sell/page navigation), the idle time will be reset.
Prices are updated real-time - which means the web app's exchange rates follow the actual markets. A strict price validation is implemented (price swing within 0.5%) so that users may not be able to manipulate the inputs to buy/sell at a false exchange rate.
To run tests:
bundle exec ruby test/cx_test.rb
Tests will now retrieve current price data from cache_prices.yml
. This will prevent significant price fluctuations due to API response lagging time.
Icon made by Those Icons from www.flaticon.com
Chartkick, together with Google Charts are used for drawing beautiful charts.
Crytocompare API is used as an API source for all of the real-time pricing and historical price data.