Inspiration

What it does

How we built it

Challenges we ran into

Accomplishments that we're proud of

What we learned

What's next for Jitters Pays You Back

Inspiration

Every team that ships at 3 a.m. has the same small injustice the next morning. Someone fronted the pizza and the coffee. The bill gets split evenly, which is easy, and unfair to the people who did the work. Nobody wants to argue about it, so nobody does.

Jitters is an anxious little monkey who codes all night, and he hates that feeling. So he reads the night's git log, works out who carried it, and settles the bill, with an apology on every charge.

What it does

  1. Paste your team's git log (git log --pretty=format:'%an|%ae|%aI|%s' --shortstat), the bill, who paid it and your team's time zone. Or press "Load the 3 a.m. sample": 25 commits by 4 people.
  2. An AI weighs every commit from 0 to 3. A typo fix is light; rewriting auth at 3 a.m. is heavy. Code doubles every commit made between local midnight and 6 a.m., then sums each person's points.
  3. Code splits the bill to the exact cent. Whoever carried least pays most: a person's share is (1 - what they carried) / (people - 1), split by the largest-remainder method, so the cents always add up to the bill. The one who paid gets the rest back.
  4. Every amount shows its reason: the points, the night commits, the biggest commit, the formula. "His working" lists every commit, how heavy he thought it was, and why it counts.
  5. A second AI call writes one nervous apology per person who owes, from facts the code worked out. The code writes the money part of each note itself, and drops any apology with a digit or a dollar sign in it, so the model never writes a number.
  6. Press "Pay them (sandbox)". Each person who owes gets one charge in the Braintree sandbox, a PayPal service. The page reads every transaction back from Braintree and shows its status.

How we built it

  • PayPal: Braintree's GraphQL API in its sandbox (payments.sandbox.braintree-api.com/graphql). One chargePayPalAccount mutation per person who owes, with Braintree's PayPal test nonce; if that errors, chargePaymentMethod with the test card nonce. A GraphQL answer of 200 with an errors list counts as a failure and is shown. The read-back is a node(id:) query. The sandbox host is fixed in code: there is no live mode.
  • AI: Llama 3.1 8B on Cloudflare Workers AI, two calls per plan: commit weights, then apologies. The answers are parsed defensively: the first JSON object in the text, every field validated, weights clamped to 0-3, bad rows dropped. The model sees commit messages and sizes, never an email. If it fails or answers junk, Jitters falls back to a keyword-and-size rule and says so on the page.
  • The server trusts nothing the page sends. It recomputes every cent from the submitted plan, refuses a bill over 1,000 or more than 10 people, and stores a hash of each paid plan: send the same plan again and it returns the stored result, so nobody is charged twice. A partial failure retries only the failed charges.
  • The page is plain HTML, CSS and JS with no build.
  • Tests first: working fakes of Workers AI and the Braintree GraphQL API back 113 tests: parsing, the night multiplier, the cent split, the AI parse (good, junk, partial), every send path (charge, repeat, partial failure and retry, gateway down, tampered plan, missing keys), the read-back, and a browser test of the page at phone and desktop width.

Challenges we ran into

Keeping the model away from money. At first one model call returned both the weights and the apologies, so each apology was written before the code knew what anyone owed. Now the code works out the shares first and hands the facts to a second call, the code writes every number in the note, and an apology with a digit or a dollar sign in it is thrown out.

Accomplishments that we're proud of

The cents always add up, and every one has a reason you can read. An even split hides who did the work; this one shows it, and the monkey apologizes for it.

What we learned

GraphQL APIs answer 200 when they fail. A payment app has to read the errors list on every answer, or it will tell you money moved when it didn't.

What's next for Jitters pays you back

Read a repository's log straight from a link, split by pull requests reviewed as well as commits, and a PayPal payout to the one who paid when it leaves the sandbox.

Built With

Share this project:

Updates

Submission history