Skip to content

A Web App that generates candles that monitor fluctuations of Bitcoin

Notifications You must be signed in to change notification settings

GustavoPellanda/Candle_Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Candle Generator

Candle Generator is a software system designed to obtain data from a chosen financial API that informs prices for a given currency and exhibit it graphically in the form of a candle chart.

Content

Explanation

Candle Generator is a software system that consists of three apps: The Service, The API, and The Web App. Its main goal is to display the fluctuations of a currency in a financial candle chart. As of the current date (09/11/23), it is configured to monitor and display the fluctuations of Bitcoin, using the API available at CoinGecko.

schematic drawing representing the functioning of the system

The Service is responsible for fetching data from the CoinGecko API, which includes Bitcoin prices over a specified time period. The address used to access CoinGecko is defined in the ".env" file, while the duration of each data fetch is determined by variables in "/enums/Period.ts." The Service then organizes this information into an object containing the necessary data for constructing a financial candle: opening, highest, lowest, and closing prices of Bitcoin during the specified time period. The code that tracks the highest and lowest prices is located in "/models/Candle.ts," which is also responsible for defining the structure of a candle object. Subsequently, each candle object created is sent to the RabbitMQ transmission queue. The RabbitMQ configuration is specified in the "docker-compose.yml" file, and the connection is managed by the code in "/messages/messageChannel.ts." The names of the queue and AMQP server are defined in the ".env" file.

The API is responsible for handling the streaming of candles from the Service to the Web and also for storing them in a database. It establishes a WebSocket channel through which clients can connect to and receive candle objects. The "/messages/messageChannel.ts" code is responsible for receiving the candle data transmitted via the RabbitMQ queue and routing it to both the MongoDB database and the socket.io channel. The Express server necessary for the API to run is started by "server.ts," which is also responsible for initializing the Message Channel. CRUD operations on the database are defined in "/controllers/candleController.ts," while the document model used for storage is defined in "/models/candleModel.ts," and the database connection is managed by "/config/db.ts."

The Web Application is responsible for creating a candlestick chart by fetching the candles provided by the API. The "App.vue" code makes an initial fetch of a predefined number of candles and then continuously listens for new candles to update the chart. The chart component itself is defined in "/components/CandleStickChart.vue," while "/store/modules/candleStore.ts" manages the data that is stored and provided to the chart.

Technologies Used

  • Typescript
  • Node.js
  • RabbitMQ
  • AMQP
  • MongoDB
  • Mongoose
  • Socket.io
  • Axios
  • Docker
  • Yarn
  • Express.js
  • PM2
  • Vue3
  • HTML & CSS
  • ApexCharts.js

Environment Set-Up

To run the development servers you'll need to have the RabbitMQ and MongoDB docker daemons running.

Main Codes

These are the codes that handle the basis of the operation of each app.

Generator: src/index.ts

API: src/server.ts and src/messages/messageChannel.ts

Web: src/App.vue

Building and Running

Candle Service can be run individually with the command yarn run.

The API can be run individually with the command yarn dev.

The TypeScript codes from the Service and the API can be translated into JavaScript using tsc.

The backend codes can be daemonized and operated in the background using PM2.

The Web App can be run individually with the command npm run serve.

Working Examples

screenshot of the programs working

About

A Web App that generates candles that monitor fluctuations of Bitcoin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published