Ayach Youssef

Case study — side project, 2026

Lantern Analytics

Web analytics that cannot track a person, because the database has nowhere to put the information it would need. A tracking snippet under two kilobytes, an ingest API, a server-rendered dashboard, and an AWS Terraform module to host it on a single small instance.

Role

Direction and review; built with AI coding agents

Timeline

November 2026

Stack

Hono · SQLite · Terraform (AWS) · Docker

Status

Source on GitHub. 33 tests. Terraform validated, never applied.

The problem

“Privacy-friendly” usually means “we hash it”

Most lightweight analytics tools still write something identifying to disk so they can tell a returning visitor from a new one: a hashed cookie, a stored IP, a long-lived fingerprint. The promise is that the hash is not personal data. The honest version of that promise is shorter: it depends.

The brief for this one was stricter. Count visits and pageviews, show top pages and referrers, run on a small self-hosted box, and make the privacy claim something a reader can check in the schema rather than take on trust.

lantern-analytics — dashboard
The Lantern Analytics dashboard for a site called Atlas Coffee Roasters: two totals, 833 visits and 1360 pageviews, a bar chart of the last 14 days, and a top-pages table listing /, /menu, /blog/how-we-roast and others with visits and pageviews
Two weeks of seeded traffic for a fictional roaster. Totals, a daily chart, top pages, top referrers. No client-side framework, no cookies.

The design

Four properties the code enforces

No column for it

The events table has a path, a referrer host, a device class, a timestamp and one flag, is_new_visit. There is no IP column, no cookie id, no hash. A privacy test serialises a real inserted row and asserts the IP and the user agent never appear in it.

Dedup that forgets at midnight

Telling a second pageview from a new visit uses an in-memory set of SHA-256 hashes of a random daily salt, the site, the IP and the user agent. At UTC midnight the salt is regenerated and the set is thrown away. Tests prove the same visitor hashes differently across the boundary and never rotates mid-day.

Rollups you can re-run

Daily stats are recomputed per site and day by deleting that day’s rows and re-deriving them from raw events in one statement. Running the rollup once, twice or five times produces identical totals, and a test does exactly that with a random count.

No oracle for guessing

The collect endpoint answers an unknown site token with the same empty 204 it gives a valid one, so a token cannot be probed. Reads always need the owning API key; one key’s dashboard is not reachable with another’s, and a test tries.

Infrastructure

AWS Terraform, tested without an AWS account

The hosting is one EC2 instance, an Elastic IP, a security group and an optional Route 53 record, written as a reusable module with an example and the same shape as my earlier DigitalOcean module.allowed_ssh_cidrs has no default, so port 22 open to the world cannot happen by omission; the AMI and subnet have no defaults either, because a module should not guess your region.

It has never been applied, because no AWS account exists for this project yet, and the README says so in the first paragraph. What has run: terraform fmt, validate on the module and the example, and terraform test against a mocked AWS provider, which plans the instance, the IP and the security group, confirms the DNS record only appears when a zone id and domain are supplied, and confirms the SSH rule always carries the caller’s CIDR and never 0.0.0.0/0. CI runs all of it on every push with no credentials.

dashboard at 375px
The same dashboard on a phone-width screen: totals stacked, the 14-day chart, top pages and referrers tables, and the embed snippet with the note 'No cookies, no IP storage, no persistent fingerprint'
Mobile-first by construction: the page is plain HTML and one stylesheet.

How it was built

With AI coding agents, and one bug they shipped

The code and tests were written by AI coding agents under my direction, in the same working pattern as Site Kit: I set the brief and the rules, reviewed what came back, and decided what counted as done. The brief was explicit that the privacy property had to be enforced by schema and tests, not by a sentence in the README, and that is the part of the output I checked hardest.

The first time I put real-looking traffic through it and opened the dashboard, the 14-day chart was an empty box. Every number was right; the bars were set with inline style attributes, and the page ships a strict content-security policy that silently drops those. The agents had written the policy and the chart separately and never loaded the page in a browser. The fix is heights as classes, plus a test that the dashboard HTML contains nostyle= at all. The Ship Log entry has the rest.

Honest limits

What this is not

It is a single SQLite file on a single instance, with in-memory rate limiters that reset on restart: fine for a handful of sites, not a multi-region design. There is no signup or billing; API keys are minted by an admin call. Device detection is a user-agent regex. And “no cookies, no IP storage” is a true, tested property of the code, which is not the same as a lawyer saying no consent banner is needed in your jurisdiction.