Skip to content
Work

Partnership ledger bot

Bookkeeping for a two-person business, typed as ordinary chat messages.

A Discord bot that turns messages like “-500 tl server” into a ledger, converts currencies at the day's rate and settles who owes whom. An AI model helps read messages, but never touches the numbers.

01

Problem

Two partners shared income and expenses in a Discord channel. Every month the same argument came back: are costs taken out of the profit first, or is the profit split first and the costs shared afterwards?

Both methods give the same result. The bot shows them side by side on every balance, which ended the argument.

02

How it works

Nobody has to learn a format. Messages like “+120 website deposit”, “-15 hosting” or “-500 tl server” become income, expenses and transfers; Turkish lira is converted to US dollars at that day's rate, and instalments are tracked until they are paid.

The bot reacts with a check mark when it understood a message, and with a question mark plus its assumption when it was unsure. Ordinary chat is left alone.

03

Where the AI stops

A rule-based parser reads most messages. Only the ones it cannot read go to a small, fast model, whose only job is to pull fields out of the text. A stronger model answers free questions like “what did we earn this month?”.

  • The model never calculates an amount: sums, splits and balances are deterministic code.
  • For questions, it receives figures that were already computed and is told not to derive new ones.
  • It returns names, never identities; code maps names to partners and accounts, and an unknown name leads to a question instead of a record.
  • Without an API key the bot keeps working; only the AI layer switches off.

04

Engineering

Python 3.11 with discord.py and SQLAlchemy. Money is never a float: amounts are stored as integer minor units and handed out as decimals, so the ledger always adds up. A single-instance lock stops a second copy of the bot from doubling every reply and AI call. It runs as a Windows service on a VDS, and 119 automated tests cover the parser, the ledger, the AI fallback and the bot's behaviour.

Next step

Have a project in mind? Tell me what it needs to do.

A few sentences are enough to start. You get an honest answer: a rough estimate, the questions that matter, or a recommendation for someone better suited.