This project provides a GraphQL API for tracking betting data. It allows users to create bets, view their bets, and see a list of the best bets per user.
- Create new bets with associated user data
- Retrieve bets and associated outcomes
- Query for the best bet per user with a limit on the number of results
These instructions will get you a copy of the project up and running on the machine for development and testing purposes.
Before you begin, ensure you have met the following requirements:
- Node.js (LTS version). The app tested with node.js version 20.9.0
- npm or Yarn as package managers
- PostgreSQL database running locally or remotely
To install Bet Tracker API, follow these steps:
git clone https://github.com/sergeialimov/dice-app
cd bet-tracker-api
yarn install
Create a .env file in the root of the project and update it with the database credentials and other configuration settings:
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=app_username
DB_PASSWORD=app_password
DB_DATABASE=app_db
Before running the application, set up the initial database structure and optionally fill it with fake data for testing:
Populate the database with fixtures:
sh ./scripts/fixtures.sh
yarn serve
To access the GraphQL playground and start making queries, navigate to:
http://localhost:3000/graphql
query {
getBet(id: 1) {
id
userId
betAmount
chance
payout
win
user {
id
name
}
}
}
query {
getBestBetPerUser(limit: 3) {
id
userId
betAmount
chance
payout
win
user {
id
name
balance
}
}
}
To run the tests for this project:
yarn test
Lint code with ESLint by running:
yarn lint
To build the project for production:
yarn build
This project is licensed under the MIT License - see the LICENSE file for details.
While the project is fully functional, there are a few limitations and areas that are still under development:
-
Docker Compatibility: The Docker setup has not been fully tested and might require additional adjustments for optimal performance.
-
Test Coverage: Currently, the test coverage is not comprehensive. We aim to improve test coverage in future updates to ensure reliability and stability.
-
Configuration Refactoring: The project configuration is functional; however, we plan to refactor it using
@nestjs/config
module for better environment variable management.