- Python 61%
- TypeScript 27.7%
- CSS 10.3%
- Dockerfile 0.5%
- Shell 0.4%
- Other 0.1%
PayPal emails carry no PDF and their HTML is cluttered nav/footer chrome. There is no official PayPal API for per-transaction receipt PDFs, so on export we now render a clean receipt from the data we already have — merchant (from "Zahlung an X"), amount, date — plus the PayPal transaction code pulled from the body, instead of rendering the raw email. Non-PayPal emails still render as before. Export-time only; no re-scan needed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DJV3FVfb13Ka42rBmDbD1B |
||
|---|---|---|
| apps | ||
| docs | ||
| scripts | ||
| .dockerignore | ||
| .gitignore | ||
| AGENTS.md | ||
| CLAUDE.md | ||
| docker-compose.yml | ||
| docker-entrypoint.sh | ||
| Dockerfile | ||
| pyproject.toml | ||
| README.md | ||
Billdozer
Scan Gmail for business invoices, review safely before approval, then export accounting-ready files on your machine.
Screenshots
Setup — connect Gmail, pick your tax year, start the scan.
Review — Cards — fast triage by keyboard (← reject, → approve, ↑ Needs PDF) or touch swipe; open any item to preview and edit.
Review — Grid — category-colored invoice cards with per-card actions.
Export — summary stats, category breakdown, then Step 1 extract PDFs → Step 2 download ZIP.
Who this is for
- Solo operators and small teams who keep invoice records in Gmail.
- Bookkeeping-heavy workflows that need a conservative, review-first process.
- People who want local-first tooling instead of sending mailbox data to a hosted service.
What Billdozer can do
- Scan Gmail with 12 invoice-related search terms and 37 known vendor domains — scans run in the background with a live progress bar.
- Classify candidates into six categories (Equipment, Phone/Internet, Software, Website, Transport, Training).
- Keep uncertain matches in a review queue — never auto-approves anything.
- Review in three modes: swipe cards (keyboard or touch), grid, or list with bulk actions — with one-tap Undo on every action.
- Open any item to preview the email (or extracted PDF) and correct the vendor, amount, date, VAT, or category before export.
- Learns from your corrections: re-categorizing a sender is remembered and auto-applied on the next scan.
- Flags likely duplicate invoices (same vendor, amount, and date) and keeps them out of the export total.
- Upload manual PDFs for invoices that arrived without attachments (e.g. Amazon portal).
- Extract PDFs for all approved items — attachments downloaded directly, email bodies rendered via Playwright.
- Export a ZIP with
YYYY-MM-DD_Vendor_Amount.pdffilenames and a CSV manifest. - Protect export actions behind a session token (
X-Billdozer-Tokenheader).
Before you start — Google OAuth credentials
Billdozer reads your Gmail through the Google API. You need to create your own OAuth credentials in Google Cloud so the app can request access to your inbox. This is a one-time setup and takes about five minutes.
Full step-by-step guide (with screenshots and troubleshooting): Google OAuth Setup
Short version:
- Go to Google Cloud Console, create a project, and enable the Gmail API.
- Go to OAuth consent screen → External → fill in app name → add your Gmail address as a Test user.
- Go to Credentials → + Create Credentials → OAuth client ID → Web application → add
http://localhost:9191/api/auth/gmail/callbackas an authorized redirect URI → Create. - Copy the Client ID and Client Secret into Billdozer's setup wizard.
When connecting Gmail, Google will show an "app not verified" warning — click Advanced → Go to app to proceed. This is expected for personal/testing apps.
Quickstart
One command from the repository root sets everything up (venv, deps, frontend build, Chromium) and starts the app:
./scripts/start.sh
Or do it manually:
python3 -m venv .venv
.venv/bin/pip install -e ".[dev]"
npm --prefix apps/web install
npm --prefix apps/web run build
.venv/bin/uvicorn main:app --app-dir apps/api --port 9191
Then open http://localhost:9191 and follow the three-step setup wizard. For development with autoreload + the Vite dev server, use ./scripts/dev.sh.
Docker
docker compose up
Or build and run manually:
docker build -t billdozer .
docker run -p 9191:9191 -v ./.billdozer:/app/.billdozer billdozer
Optional: manual OAuth env vars
If you prefer not to use the setup wizard, set these before starting the app:
export BILLDOZER_GMAIL_CLIENT_ID="your-google-client-id"
export BILLDOZER_GMAIL_CLIENT_SECRET="your-google-client-secret"
Typical workflow
- Create Google OAuth credentials (see above) and enter them in the setup wizard.
- Connect Gmail — Billdozer requests read-only access.
- Select your tax year and start a scan.
- Triage the review queue: swipe through cards, or use grid/list for bulk actions. Open any item to preview the email and fix the vendor, amount, date, or category. Mis-tapped? Hit Undo.
- For invoices without attachments, Billdozer shows a direct link to the vendor portal — download the PDF there and upload it to the card.
- Go to Export → Step 1: Extract PDFs, then Step 2: Download ZIP.
Local security and privacy
- Billdozer is built for local-first use on your machine — no data leaves your host.
- Gmail OAuth tokens are Fernet-encrypted at rest in
.billdozer/tokens.json. - The UI session token (
X-Billdozer-Token) guards export and open-folder actions. - Rotate the session token via
POST /api/auth/session-token/rotate. - Password login is rate-limited (5 failed attempts per 5 minutes per IP).
- Untrusted email HTML is rendered to PDF with JavaScript disabled and all network requests blocked (no tracking pixels, no SSRF).
- The Docker image runs the server as a non-root user.
Troubleshooting
Common issues: redirect URI mismatch, "app not verified", empty review queue, export auth errors, Docker volume mounts.
Full guide: Troubleshooting
For developers
Full guide: Developer Setup
Repo layout: apps/api (FastAPI + SQLite), apps/web (React + Vite + TypeScript). Contributor context: CLAUDE.md, AGENTS.md.
Optional AI assistance
Classification and extraction are rule-based by default with no external dependency. You can optionally enable an AI backend to help only where the rules fall short — 90-Needs-Review fallbacks, missing metadata (amount/date/vendor), and portal-link scoring. AI never overrides a confident rule result; it is consulted as a last resort. Enable via env vars:
| Variable | Purpose |
|---|---|
BILLDOZER_AI_PROVIDER |
ollama (local, no API key) or openrouter (cloud). Empty = off (default). |
BILLDOZER_AI_MODEL |
Model id. Default: llama3.1 (Ollama) / anthropic/claude-haiku-4.5 (OpenRouter — cheap & fast; the UI also suggests Gemini 2.5 Flash, GPT-4o mini, and Claude Opus 4.8). |
BILLDOZER_AI_API_KEY |
Required for OpenRouter. |
BILLDOZER_AI_BASE_URL |
Optional endpoint override. |
Or configure it in the web UI: Setup → Optional: AI assistance (provider, model, key, base URL, with a "Test connection" button). The UI config is stored encrypted in .billdozer/ and takes precedence over the env vars; the API key is never returned, only a masked hint. OpenRouter is a single integration covering Claude, GPT, and open-source models; Ollama keeps everything local and private.
Login & reverse proxy
Optional password login protects the whole app. Set it in Setup → Optional: Security & proxy (or BILLDOZER_PASSWORD); with a password set, the UI shows a login screen and every API call requires a session token. Without one, Billdozer stays open (local dev). Behind a reverse proxy, set the public base URL in the same place (or BILLDOZER_PUBLIC_BASE_URL) — the Gmail OAuth redirect URI is derived from it. Both are stored encrypted in .billdozer/ and take precedence over the env vars; the password is stored hashed (PBKDF2), never returned.
Tax-year sessions
Each scanned tax year is a saved session: Setup → Your tax years lists every year you've scanned with its review status, lets you resume any year, and delete a year's data when you're done with it. Work is persisted per year, so you can scan/review in parts and come back later.
Roadmap
- Add support for additional mail providers (IMAP, Exchange/EWS) alongside Gmail.
Repository
Canonical git repository: https://forgejo.nielsbox.cc/niels/Billdozer



