I've been trying to model an efficient schema for a bill split app, the requirements are as follows:
- There can be groups in which there can be multiple participants, and conversations consisting of exactly 2 participants.
- One group/conversation can have many bills
- One bill can be paid by many people, can be paid for many people (eg. A and B contributed 100$ and it was split equally between A, B, C, and D).
- If a user goes into the profile of another user, they can see what they owe to them or vice versa, on a global level, i.e. total of all the groups.
- If they go in the group details, they can see individual group members and what they owe to the user or what the user owes to them on the group level.
- A bill can have transactions representing payments made for the bill, and the actual amount used by each participant.
- These payments can be settled.
It would be great if anyone could guide me on how to model this database efficiently. Thanks!
PS: I'm using MongoDB right now