A Prompt for a Group Expense Splitter
Trips, shared flats and dinners all end with the same question: who owes whom? This brief builds the app that answers it, with the math done right.

Key takeaways
- Store money in whole cents and never recompute an old split: save each person's share when the expense is created.
- Balances are calculated from expenses and settlements, never typed in or stored as a number you edit.
- The app records who owes whom; it does not move money. Say so in the brief and in the app.
If you want an app that splits trip, flat or dinner costs between friends, this is the prompt to start with. It builds a web app where a group adds shared expenses, splits each one equally, by exact amounts or by shares, sees a running balance per person, and gets the shortest list of payments that settles everyone up. The brief is strict about money math, because rounding errors are the bug that kills trust in this kind of app.
The prompt
Build a group expense splitter web app, mobile-first, clean and calm. Use Startbase Cloud for sign-in (email magic link) and data. Data: groups (name, currency code, created_by, invite_code), members (group, display name, optional user account, so I can add a friend who has not signed up yet), expenses (group, description, amount in integer cents, paid_by member, date, category from a short list, created_by), expense_shares (expense, member, share in integer cents), and settlements (group, from member, to member, amount in cents, date). Splits: equal, exact amounts, or shares (for example 2:1:1). For equal splits, give any leftover cents to the first members so shares always add up exactly to the amount. Save the shares when the expense is saved; never recalculate old expenses when membership changes. Screens: 1) My groups with my balance in each. 2) Group page: expense list newest first, each person's balance (green owed, red owes), and an Add expense button. 3) Add expense: amount, description, who paid, split type, and a live preview of each share. 4) Settle up: the minimum set of payments to bring everyone to zero, with a Mark as paid button that records a settlement. 5) Join a group by invite link, then claim one of the existing member names. Only group members can see a group. Out of scope: real payments or bank links, receipt scanning, currency conversion between currencies, and recurring expenses.
The reasoning, line by line
Integer cents
Computers store decimals like 0.1 imprecisely, and money math with floating point numbers drifts by a cent here and there. Storing every amount as whole cents (1999 instead of 19.99) removes the problem. Naming it in the brief is the cheapest bug prevention you will ever do.
Leftover cents have an owner
Split 10.00 three ways and you get 3.33, 3.33, 3.33: a cent disappears. The brief gives the extra cent to the first member so shares always add up to the total. Any rule is fine, as long as there is one and the sum always matches.
Shares are saved, not recomputed
When someone joins the flat in March, January's rent should not change. Saving each person's share in its own row freezes history. It also makes balances simple: what you paid, minus what you owe, plus settlements you received, minus settlements you paid.
Members without accounts
The person who organizes a trip adds everyone on day one, but half of them never sign up. Members as names with an optional linked account lets the app work for the organizer alone, and lets friends claim their name later through the invite link.
Minimum payments to settle
With six people, naive settling can mean fifteen transfers. A common approach repeatedly matches the person who owes the most with the person owed the most, which keeps the list short and easy to follow. Asking for it by name ("the minimum set of payments") gets you that instead of a pairwise table.
Group-only visibility
"Only group members can see a group" is what makes the agent write row-level security policies on groups, expenses, shares and settlements. Money data between friends is still private data.
Your first three follow-ups
- 01"Let me edit or delete an expense. Keep an activity log for the group that says who changed what and when, with the old and new amounts, visible to every member."
- 02"Add a group summary: total spent, spent by category as a simple bar chart, and spent per person, for the whole group or a date range."
- 03"When someone adds an expense, show a small notice on the group page for other members since their last visit: '3 new expenses since Tuesday'."
The activity log comes first because edits are where groups start arguing. "Who changed the hotel bill?" needs an answer. The summary turns the app into something people open after a trip, not only during it. The new-since-last-visit notice is a gentle alternative to push notifications, which a web app on most phones cannot rely on.
Two variations
- Shared flat bills: add recurring expenses after all ("rent on the 1st, split by room size shares") with a scheduled job that creates each month's expense automatically, and a monthly email summary to every member with an account. Startbase Cloud runs scheduled jobs inside the database, and schedules are in UTC, so say what time zone you mean.
- A trip splitter with multiple currencies: keep one group currency for balances, but let each expense record the original currency and the rate used, entered by the person adding it. You avoid depending on a live exchange rate feed, and everyone can see the rate.
What breaks most often, and the fix to ask for
- Balances do not add up to zero. Across a group, all balances must sum to exactly zero. If they do not, ask: "Add a check that group balances sum to zero cents. Find expenses whose shares do not sum to their amount and show them to me before fixing."
- Exact splits accept wrong totals. Ask: "In exact split mode, disable Save until the shares add up exactly to the amount, and show the difference live."
- A removed member breaks old expenses. Ask: "Never delete members who appear in expenses or settlements. Mark them inactive instead, hide them from new expenses, and keep them in history."
- Anyone with the link sees the group. The invite code should let people join, not read. Ask: "The invite link only shows the group name and a Join button. Expenses are visible only after joining. Recheck the policies on every group table."
- Settle up suggests silly payments. If it says A pays B and B pays A, the algorithm is pairwise. Ask: "Compute net balances first, then match the largest debtor with the largest creditor until everyone is at zero."
What this app should not promise
The splitter records debts; it does not move money. Say so on the settle up screen ("pay them however you like, then mark it paid") so nobody thinks a button sends cash. Linking bank accounts or payment apps for transfers involves financial regulation and providers built for it, and is far beyond a first version.
If you want the single-person version (budgets, categories, monthly spending), the guide on building an expense tracker covers it. For why "only members can see a group" matters and how policies enforce it, read row-level security explained simply. The Database docs show how to browse the tables and policies the agent creates, and user login explained covers the magic link sign-in.
Frequently asked questions
How do expense splitting apps calculate who owes whom?
Each person's balance is what they paid minus their shares of all expenses, adjusted by settlements. Balances across the group sum to zero. To settle, the app matches people who owe with people who are owed until everyone reaches zero.
Why store money in cents?
Decimal amounts stored as floating point numbers lose precision, so totals drift by a cent. Whole cents are exact, and you format them as currency only for display.
Can a bill splitting app send money between friends?
A first version should not. Moving money needs licensed payment providers and their own compliance. Record debts and settlements in the app and let people pay each other however they already do.

