PERSONAL

A daily letter that must never fail or repeat

One reader, ₹0 budget, zero tolerance for a missed or repeated morning.

Role
Sole engineer (49 of 49 commits), family project
Context
Family
When
since Oct 2026
Status
Private, not linkable, checked 26 Nov 2026
Reading time
5 min read

Details anonymised

Mine: the product and its spec, and the design of the installable React app, the Postgres schema and every permission in it, the letter pipeline and its fallbacks, and the test and CI gates

Built with: React 19 (installable app), TypeScript, Vite, Tailwind v4, Supabase (Postgres 17, Auth with two-factor sign-in, Edge Functions, scheduled jobs), Gemini (letter drafts and the fact check), Groq (fallback drafts), Cloudinary (photos), Web Push, Vercel, Vitest, Playwright, pgTAP, GitHub Actions (CI and nightly backups)

The app's home screen on a laptop, showing a sample letter on a ribbon card with invented text

At a glance

  • One letter at 07:00 IST: a model drafts it, code checks it and I approve it
  • Every permission enforced in Postgres and tested with pgTAP
  • ₹0 a month on free tiers, with nightly encrypted backups
Automated tests passing in CI
2,209 tests
COUNT in 170 files, 86.44% statement coverage; CI run 44791503578
Source: CI run 44791503578 at aff06285, checked 26 Nov 2026
Browser tests passing in CI
316 tests
COUNT WebKit and Chromium, with accessibility and 150%-text checks; CI run 44791503578
Source: CI run 44791503578 at aff06285, checked 26 Nov 2026
Database test assertions (pgTAP)
2,014
COUNT planned assertions in 29 pgTAP files, run locally; 24 migrations
Source: pgTAP files and migrations at aff06285, checked 26 Nov 2026

The problem

One person in my family starts each day with a letter from me. It has to arrive at 07:00 IST. It must never repeat an earlier letter, and no family name may ever reach a model provider. The budget is ₹0 a month, so it runs on free tiers, and free model tiers can be busy at night. A missed or repeated morning is the failure that matters here. Most of the work runs overnight, so the system has to recover on its own or fall back safely. So I treated a small family app like production software: a spec first, then rules the code enforces, then tests for those rules.

What I built

An installable web app and a nightly letter pipeline. Each evening a run drafts tomorrow’s letter, and code checks the draft before it reaches me for approval.

The reliability ladder. Every rung a letter passes between the evening run and the 07:00 IST push. The fact check only records its verdict for now.

Solid: rules · Dashed fence: model · Diamond: gate · Cyan: data

How it flows

  1. Each evening run builds the request for tomorrow's letter. A PII gate swaps the reader's name for a template slot and refuses to send if a family name or another listed term is left. It fails closed.
  2. Gemini drafts the letter as a template. If the main model is busy, a second Gemini model and then Groq are asked in the same attempt.
  3. Code checks the draft's shape, its length, its template slots and a list of banned phrases.
  4. The never-repeat check compares the draft with earlier letters by meaning, by wording and by its opening, and rejects a close match.
  5. A second model call quotes each claim and the fact behind it, and code judges the verdict. For now it only records that verdict; it does not block a letter.
  6. A rejected draft is tried again on the next run, every 30 minutes from 21:37 to 05:07 IST, up to 12 tries a night.
  7. I approve each letter by 06:30. If I don't, a hand-written backup letter goes out instead, while backups last; with none left, the draft goes out.
  8. At 07:00 IST the letter goes out as a push notification.

The model only ever writes templates. Code fills in the reader’s name and the family names when the letter is shown, and a PII gate refuses any request that still holds one. The never-repeat check compares each draft with earlier letters by meaning, by wording and by its opening, and rejects a close match. If the main Gemini model is busy, a second Gemini model and then Groq are asked in the same attempt. A rejected draft is tried again on the next run, up to 12 tries a night. I review every letter by 06:30. If I don’t, a hand-written backup letter goes out instead, while backups last.

Every permission lives in Postgres: grants, row-level security and definer functions, never a hidden button alone. The admin account needs two-factor sign-in. CI holds the main JavaScript chunk to a 170 KB budget. Every night the database is dumped, encrypted and kept for 14 days.

Note

These screens come from the real app, run on my machine with invented sample text. No real letter, name or photo appears in them.
The app's home screen on a phone, with a sample letter and its Love it and Reply buttons
Fixture data
The admin's Upcoming page on a laptop, with tomorrow's sample draft and its Approve, Edit, Reroll and Use a backup buttons
Fixture data

Key decisions

Three choices shaped the build. Each one trades a little convenience for a failure that cannot happen quietly.

The model writes templates, and code writes the names

Alternative rejected
Putting the family's names in the prompt and trusting the model to handle them
Why
A name that never reaches the provider cannot leak there. The PII gate checks every outbound request and fails closed, so a slip stops the request instead of sending it.

Every permission is enforced in Postgres

Alternative rejected
Hiding admin screens and buttons in the client
Why
A hidden button is not a permission. Grants, row-level security and definer functions hold even if someone calls the API directly, and the pgTAP files test them.

An unapproved morning falls back to a letter a person wrote

Alternative rejected
Sending the model's draft unreviewed, or sending nothing
Why
If I have not approved the draft by 06:30, an unused hand-written backup letter goes out. Only with no backups left does the unapproved draft go out.

The never-repeat rule follows the same idea. A prompt can ask for a fresh letter but cannot promise one, so code enforces it: the similarity check refuses a draft that is too close to an earlier letter.

The pipeline’s rules live in plain TypeScript that the server functions share. So the unit tests exercise the real gates, not copies of them.

How it was proven

Automated checks by layer. The unit and browser counts are the tests that passed in CI run 44791503578 at aff06285 on 20 Nov 2026. The database bar counts planned pgTAP assertions, which run locally, not in CI. COUNT count Source: CI run 44791503578 at aff06285, checked 26 Nov 2026
Data table
Automated checks by layer
Layer Tests or assertions Note
Unit (Vitest) 2209 Tests passing in CI, in 170 files
Browser (Playwright) 316 Tests passing in CI, on WebKit and Chromium
Database (pgTAP) 2014 Planned assertions in 29 files, run locally

CI run 44791503578 at commit aff06285, on 20 Nov 2026, passed 2,209 unit tests in 170 files.[1] Coverage in that run was 86.44% statements, 82.76% branches, 87.38% lines. The same run passed 316 browser tests on WebKit and Chromium, with accessibility checks and a 150%-text suite. The screenshot and traced-performance checks are skipped on push; they run in a weekly full job instead.

The database has 24 migrations and 29 pgTAP files with 2,014 planned assertions.[2] They check that grants are closed by default, that each function runs only for the roles that need it, and that an unapproved letter is swapped for a backup. They run from my machine against the database, each file inside a transaction that is rolled back. They do not run in CI, so this page counts them as planned assertions, not as passes in a CI run.

The nightly backup job succeeded on every scheduled run from 2 to 24 Nov 2026, 23 of 23.[3] Each run dumps the database, encrypts the dump and keeps it for 14 days. The receipts are rendered from the run records, because the repository is private and a link to it would not open for you.

Outcomes

The whole system costs ₹0 a month. It runs on the free tiers of Supabase, Cloudinary, Gemini, Groq, Vercel and GitHub. In the cited CI run the main chunk was 91.47 KB gzipped, under its 170 KB budget.[1]

The pipeline now degrades in steps instead of failing at once. Since 19 Nov 2026 a busy main model hands the draft to a second Gemini model, then to Groq, within the same attempt. A rejected draft gets another try on the next run, up to 12 tries a night. If I have not approved a draft by 06:30, a letter a person wrote goes out at 07:00 IST instead, while backups last.

What the reader sees is one letter on a card, with Love it and Reply under it. The reading screen follows strict rules. Text starts at 18 px and scales up to 150%, nothing is smaller than 16 px, and touch targets are at least 48 px. Body text keeps a contrast of 7:1. The browser suite checks the layout at 150% text on a 320 px screen.

Limitations and what I’d change

  • The fact check only records its verdict for now. At the last logged check, on 14 Nov 2026, it ran in shadow mode, so it cannot yet stop a letter.
  • The pgTAP suite runs from my machine, not in CI, so a change could break a permission without CI noticing. I would add a database job to CI.
  • The screenshot and traced-performance checks run only in the weekly job, so a regression they would catch can sit for up to a week.

Credits and permissions

A family project; names withheld. The app is private and never linked, and its repository stays private. So the test, coverage, bundle and backup figures point to hosted receipts instead of the code.

Details anonymised: names, brands and identifying links are withheld.

  1. CI run 44791503578 at aff06285, 20 Nov 2026, checked 26 Nov 2026
  2. pgTAP files and migrations at aff06285, checked 26 Nov 2026
  3. Backup workflow runs, 2-24 Nov 2026, checked 26 Nov 2026

Contact

Have a project?

Open to a small amount of freelance work: AI features, internal tools and web apps for small teams. Tell me what you're building, who it's for and when you need it.

Write to me →