A simple bill split app to manage expenses built on top of NestJS.
- Node.js v18 or higher
- npm v8 or higher
- pnpm v8 or higher
Server: Node, NestJS
Database: In-memory Objects
Package Manager: pnpm
Versions: node v18.12.1 (npm v8.19.2) , pnpm 8.6.0
-
Unzip the file
-
Go to the project directory
cd nestjs-bill-split
- Install node and pnpm (Optional - No need if you already have it)
After you have installed node,
RUN: sudo npm install -g pnpm
- Install dependencies
RUN: pnpm install
- Start the server
RUN: pnpm run start
- Open Swagger
localhost:3000/docs
-
For simplicity sake, this app dosent have a concept of group. All added users are part of the same global group. The group functionality can be easily added as the design supports it.
-
Since everything is managed by in-memory objects, data wont persist if server is stopped/restarted.
-
App supports expenses up to two decimal places. Any more than that will be rounded off.
-
Email ids should be distinct when adding users. However, duplicate usernames are allowed.
-
There are two kind of splits that the app supports while adding expenses,
When expense type is EQUAL, it will divide the amount equally between all the users present in the system.
Expense - **/api/expense** [POST] { "expenseType": "EQUAL", "name": "test expense", "paidBy": "[email protected]", "amount": 1500.97 }
When expense type is UNEQUAL, it will divide the amount as per the split information provided.
-
Here, numberOfUsers and splitInfo are mandatory additional params. The length of splitInfo array should be equal to numberOfUsers.
Expense - **/api/expense** [POST] { "expenseType": "UNEQUAL", "name": "test expense", "paidBy": "[email protected]", "amount": 3600, "numberOfUsers": 3, "splitInfo": [ { "email": "[email protected]", "amount": 1000 }, { "email": "[email protected]", "amount": 1400 }, { "email": "[email protected]", "amount": 1200 } ] }
-
- Add User
- Add Expense (EQUALLY and UNEQUALLY)
- Get balances for a particular user with users total share.
- Get balances for all users with the total group spendings.
To run tests, run the following command
unit test:
RUN: pnpm test