https://github.com/DavidCandreanu00/BTC-Price-predictor-BE.git
This README contains instructions on how to use the backend part of the BTC price prediction project.
The project was created using AWS technologies, including API Gateway, Lambdas, DynamoDB, SQS, and was deployed with AWS CDK.
The app is currently hosted on S3.
The aim was to develop a system that allows users to make predictions on the price of BTC one minute into the future. API Gateway exposes several endpoints covering main functionality such as generating a user ID, retrieving user details and score, and placing a prediction.
Several Lambdas were deployed to handle the functionality of the API. For example, the createUser lambda generates a random UUID and checks if it hasnβt been assigned to another user yet. The getUserScore retrieves the userβs status and current score as a response.
The prediction mechanism is handled by the messageProducer (to place a prediction) and messageConsumer (to resolve it). The 1-minute timeframe of the prediction is generated by the SQS queue, which has a delay of 1 minute before sending events to the consumer.
Whenever a user makes a prediction, the current BTC price is fetched from a public API and is sent in an event format alongside the direction of the prediction and the userID who placed it to the SQS queue.
The queue waits for 1 minute before sending the event to the consumer. When the consumer receives the event containing the BTC price at the time of the prediction and the prediction itself, it fetches the BTC price again, compares it to the prediction, and updates the score of the user with the provided ID in the DynamoDB table of users.
The project was deployed with AWS CDK to a personal AWS account.
In order to deploy this project you will need to have AWS CDK and CLI installed. Once that is done, you will need to specify the access point by configuring the Access Key Id and Secret Access Key from your AWS account.
This README will not cover the instructions on how to do this, but they can be followed in this detailed article (Steps 1-4).
npm i at the root level to install all modules used for deployment.npm i in the src/lambdas folders to install the modules used by the Lambdas.npm run build at the root level to build the project.cdk synth to view the CloudFormation template of the projectβs stack.cdk bootstrap.cdk deploy to deploy the stack to AWS.Similar to the frontend part, time constraints limited the scope of this project. Future plans include:
The frontend repository can be accessed at this URL.
npm run build compile typescript to jsnpm run watch watch for changes and compilecdk deploy deploy this stack to your default AWS account/regioncdk diff compare deployed stack with current statecdk synth emits the synthesized CloudFormation template