This is a web app that allows users to make guesses on whether the market price of Bitcoin (BTC/USD) will be higher or lower after one minute.
Users can:
- See their current score and the latest available BTC price in USD
- Choose to enter a guess of either "up" or "down"
- Only make one guess at a time (each 60s)
- Have their guess resolved when the price changes and at least 60 seconds have passed since the guess was made
- Get 1 point added to their score if their guess is correct, or lose 1 point if their guess is incorrect
- Start with a score of 0
- The can close their browser and return to see their score and continue to make more guesses
The project consists of a client (ReactJS, TailwindCSS) and a server (NodeJS, ExpressJS, AWS - DynamoDB) written in TypeScript.
To run the app locally, follow these steps:
To run the client:
- Navigate to the
/client
folder in your terminal. - Run
npm install
to install the required dependencies. - Run
npm run start
to start the development server.
To run the server:
- Navigate to the
/server
folder of the project in your terminal. - Run
npm install
to install the required dependencies. - In
/server/config
duplicate the fileaws-config_dev.json
asaws-config.json
and add your aws credentials. - Run
npm run migrate
to execute database migrations. - Run
npm run build
to build the server project. - Run
npm run start
to start the server.
-
Move Server to a DDD Approach - Refactor the server code to follow a Domain-Driven Design (DDD) approach. This would involve creating necessary copies of entities, such as the Player and Guess entities, to avoid tight coupling and promote modularity;
-
Improve test coverage - Although there are currently some unit tests in the server code, it is recommended to further improve the test coverage to ensure the reliability and stability of the application;
-
Improve error handling - Enhance error handling in the server code by adding appropriate error messages and codes, and implementing appropriate error-handling mechanisms;
-
Use environment variables for configuration;
-
Implement E2E testing: Write automated tests for the server and client code to ensure that the application functions as expected;
- Prevent simultaneous guesses: To prevent the possibility of a user making two simultaneous guesses by copying their browser's localStorage value to another browser, the server-side code should be updated. Whenever the server receives a guess from a player, it should automatically resolve all pending guesses associated with that player ID.