Own build · Open source · AI agent

An income and tax tracker for UK self-employed workers, with an AI assistant that never does the maths

Taxi drivers, couriers and tradespeople get paid daily and often only find out what they owe at the Self Assessment deadline. I built a tracker that shows the running figure every day, and an AI assistant you can simply ask.

Project snapshot

Type
Own build, open source
For
UK self-employed workers
Built with
Python, SQLite, Flask, Gemini
Tests
8 automated (pytest)
Code

This is my own portfolio project, not a client engagement. The screenshots use made-up demo data, and there are no client results to report, so this page shows how it was built instead.

The problem

If you are self-employed and paid by the day, the money comes in daily but the tax bill arrives once a year. Most people in that position keep figures in a notebook or their head, add them up in January, and get a surprise. Fuel, parking and once-a-year bills like insurance, MOT and a council licence make the real profit hard to see.

The goal was simple: record a day in seconds, and always know your profit and an estimate of the tax you owe so far.

Income tracker dashboard showing income, expenses, profit and estimated tax cards, forms to add a day and a yearly cost, and a weekly profit bar chart
The dashboard: totals, a form for each day, yearly costs and profit by week. Demo data.

What it does

Daily entries

Add a day's income and expenses from the web form, the menu or by chat. More than one entry per day is fine.

UK tax-year weeks

Week 1 starts on 6 April, and each entry stores its tax year, so years never mix.

Yearly costs

Insurance, MOT, road tax and licences come off profit for that tax year, with their own page.

Tax estimate

A running 2026–27 estimate including Class 4 National Insurance and the higher rate. Clearly labelled as an estimate, not a tax return.

Missing-day catch-up

The assistant asks about any day since your first entry that has no record.

Local and private

Everything is stored in a SQLite database on your own computer, never uploaded.

How the AI part works

The assistant is a grounded tool-calling agent, not a chatbot. That one design choice is the point of the project:

  1. The AI picks a tool. Gemini reads the question, for example "what did I earn in week 23?", and replies with one tool name: a day, a week, the totals, add an entry, add or list yearly costs, or help.
  2. Python does the maths. The figures come from the saved entries, calculated by ordinary code. The AI never adds up a number, so it cannot invent one.
  3. Guardrails catch the rest. Questions outside the records are refused, negative amounts are turned positive, nothing is saved without a yes, and an unclear reply is asked again.
  4. One brain, two doors. The same function answers in the terminal and in the dashboard's chat pop-up, so both always agree. The API key stays on the computer; the browser never sees it.
The AI assistant pop-up answering what the totals are and what was earned in week 23
The assistant pop-up. The numbers in its answers come from Python, not from the AI. Demo data.

A real example from testing: early on, "I paid 60 for a parking permit" was picked up as £60 of income. One rule in the prompt ("money the user paid is never income") fixed it, and the assistant now declines rather than saving the wrong thing. That is the kind of failure a tool-calling design makes easy to find and fix.

How it was built

It grew in four versions, each one working before the next began:

  • Version 1: a command-line menu with UK tax-year weeks and a tax estimate
  • Version 2: the Gemini tool-calling assistant with guardrails
  • Version 3: storage moved from JSON files to SQLite, with parameterised queries
  • Version 4 and on: a Flask web dashboard with forms, a chart, a yearly-costs page and the AI chat pop-up

Eight automated tests check the parts that are easy to get wrong: the April tax-year boundary (5 April vs 6 April), missing-day detection and the tax figures at exact band edges such as £50,270.

Yearly costs page listing insurance, council licence, road tax, MOT and phone with a total
Yearly costs page
A week page listing each day's income, expenses and profit
One week, day by day

What this shows for your business

The same pattern works for any small business that wants to ask questions of its own data in plain English: bookings, jobs, sales or stock. The AI understands the question, your own system supplies the facts, and nothing is made up. If you want an assistant like this on top of your records, that is what we build.

Built and written by Mohsan Abasi, founder of Pivot Bureau. Last updated 30 November 2026.

Want an AI assistant on your own data?

Tell us what you'd like to ask your records, and we'll show you how it would work.

Contact us See the code on GitHub