Skip to content
This repository was archived by the owner on May 30, 2026. It is now read-only.
This repository was archived by the owner on May 30, 2026. It is now read-only.

Move balance calculation from the frontend to the backend #101

Description

@thomaseizinger

Currently, we return bills and debts to the frontend. However, in addition to the debts, the frontend also shows the balances of each participant. This information is not present in the API response and hence, the frontend needs to calculate it by itself.

This is:

  1. error prone: the frontend is written in JS and has barely and tests
  2. inconsistent in terms of responsibilities: the frontend should focus on design and UX, not on doing math

In addition, we recently introduced property-based tests into the backend to have more thorough tests and better guarantees that our optimization algorithms actually behave correctly.
For these tests, we already calculate the balances of each participant because no matter how we optimize the debts, the balances always need to stay the same: they are the perfect metric to check on whether an optimization algorithm is correct.
However, at the moment, all this logic is part of the test suite and not the production code.
If we return balances in the API we can:

  1. Move this code to the production code and thereby support it properly (this will clean up the tests quite a bit)
  2. Remove some math from the frontend

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions