Skip to content
Back to blog
Sep 15, 20266 min read

From a photo to a traceable offline export

A personal architecture experiment with Telegram, Cloudflare, offline sync, and a reviewable CSV export.

AI WorkflowsAutomationQuality EngineeringCloudflare

A photo is not yet a reliable data record

A receipt workflow sounds simple at first: take a photo, extract the values, and export everything at the end of the month. In practice, quality questions appear immediately. What happens when the date is unreadable? How do we prevent duplicate files? How can we preserve what was originally on the receipt?

I built a small personal receipt bot to explore these questions. A photo arrives through Telegram, is stored server-side, and is then mirrored locally. Extracted values can be reviewed and corrected before an export is created.

The server is authoritative

The most important architecture decision was to keep the direction clear: the server is authoritative and the local computer is a read-only mirror. The PC never writes back. That removes conflicts between two mutable copies and allows interrupted syncs to resume safely.

Telegram sends the image to a Cloudflare Worker. R2 stores the immutable original, while D1 holds extracted metadata and review state. The local CLI downloads both and creates an offline copy.

Store first, extract second

The image is stored first. Only then does extraction try to identify merchant, date, amount, or category. If OCR or an AI call fails, the receipt is still safe and receives a review status.

Missing values are not guessed. An empty amount is safer for accounting than a convincing hallucination. Corrections change metadata only, never the original image.

Idempotency is a quality feature

Filenames are based on SHA-256 hashes. The same record can therefore be downloaded repeatedly without creating a second file. This sounds technical, but it directly affects everyday reliability: network failures and retries remain manageable.

The export is deliberately reviewable as well. CSV rows, totals, and categories are generated alongside numbered images. The Worker and local CLI share the same export logic so both paths produce the same result.

What the tests make visible

The current test suite contains 37 passing tests. It covers German amount formats, special characters, missing dates, CSV columns, total rows, and the link between images and export rows.

The interesting part is therefore not the bot alone. It is the combination of a clear system boundary, immutable originals, explicit review states, and reproducible exports. That is what turns a small automation into a dependable workflow.

The boundary is part of the design

The public presentation uses synthetic receipts only. Real merchants, trips, amounts, chat IDs, Cloudflare identifiers, tokens, and local paths belong neither in screenshots nor in a repository.

My main takeaway is that robust AI automation does not start with the model. It starts with safe failure states, traceable corrections, and an architecture that keeps uncertainty visible.