jbujalance / biwenger-transfers

A Biwenger transfer recorder that stores the market movements in a MongoDB database
0 stars 0 forks source link
biwenger comunio

Biwenger Balance Tracker

This is a personal application to keep track of every user balance in a Biwenger League. This document is intended for those who would like to do something similar, finding inspiration in this project.

Infrastructure

The application is meant to run on a server, in order to be able to expose the Balances endpoint and to run the tracker CRON jobs, which retrieve the transfers and the bonuses from Biwenger periodically. Also, all the retrieved data is stored in a MongoDB cluster which must be reachable. I personally use MongoDB Atlas.

Configuration

The following environment variables are available to configure the application:

Deployment on Heroku

The server is deployed in a Heroku web dyno, from which it exposes the Balances endpoint. The scripts in the folder ./bin are scheduled as CRON jobs with the Heroku scheduler to run periodically.

Run locally

To run locally in a dev environment, the project makes use of the .dotenv tool. Use the following command to run the server loading the environment variables from the not-committed .env file:

npm run start-dev

Usage

Once the application is deployed and running, the endpoint /api/balances will provide the balances of all the users in the league in the following format:

[
    {
        "biwengerId": 123456,
        "name": "Mr. Bean",
        "gain": 4375600,
        "spend": 19200216,
        "balance": -14824616
    },
    {}
]

TODO