Moving from the UK to the USA one thing I found is there is a weird obsession with everything being posted to me, or having to go in-person for a government service; really made me greatful for what felt like shit services back home but being able to replace my driving license online without having to go queue in a DMV is something i'll take back anyday.
Anyway, back to mail. I've got a stack of letters so high that I could probably play a good game of jenga with them, not only that but I've lost, or thrown out so many I've lost track. Sooo... I decided to make
a small service using the cloudflare workers stack which lets me scan in mail, automatically save it in a bucket generate a summary and get full-text search through all my mail on my phone. No more guessing what the bank said or when I got a letter.
## Stack
- Workers: PWA, and doc upload api
- Containers & Durable Objects: Perform OCR on uploaded docs & extract the first page as a thumbnail
- D1: full-text search and document storage
- R2: document storage
- Workers AI: summerize and extract the data from the mail
## The Setup
I have a HP OfficeJet Pro 9125e, has a double sided ADF (auto-doc feader), which I can just put letters into and it will scann both and dump them onto a SMB server. This server is running on a pi-zero, discreetly hidden behind a flag, which when it sees a new PDF be uploaded will take it, POST it to a cloudflare worker and delete the file locally. The worker will then run OCR (teseract), convert the first page to a webp image as a tumbnail and finally run it though a small LLM with Worker's AI to extract some structured data.
I can then just open the PWA on my lock screen and see all my mail right there, search through it on the go, etc!
## Pics
