cd /news/ai-products/our-19-report-has-no-database-row-th… · home › topics › ai-products › article
[ARTICLE · art-177919] src=dev.to ↗ pub= topic=ai-products verified=true sentiment=↑ positive

Our $19 report has no database row. The whole purchase lives in the URL fragment.

A developer at check.tattoo, a service that scores tattoo ideas before purchase, built a stateless restore mechanism that stores the entire $19 paid report in the URL fragment rather than a server-side database. Because the report is generated by a model at temperature 0.4, re-running the check would produce different wording and possibly different numbers, so the team rejected restore codes in favor of a base64url-encoded positional JSON payload that browsers never transmit to a server. Real reports measured between 2,829 and 3,443 characters, and decoding validates a version number, integer scores from 0 to 100, exactly six dimensions, and per-field length caps.

recommendation

When a paid artifact must be restored exactly, store the full payload in the URL fragment with a version prefix and strict shape validation instead of re-generating it or keeping a lookup table.

more in playbook: Running AI in production
by read4 min views2 publishedNov 28, 2026

check.tattoo scores a tattoo idea before you get it. The score is free. The full report is a one-time $19 payment for one design: the reasoning behind each score, what to change, and a brief for the artist.

There are no accounts, and that created a problem.

After payment, two things are written to the browser: the entitlement ("this design is unlocked") and the report itself. Both live in localStorage.

localStorage is not durable. Safari's tracking prevention can evict script-written storage after about a week without a return visit. So a buyer could pay, come back ten days later on an iPhone, and find nothing.

The usual fix is a restore code and a table: store the purchase server-side, hand the buyer a code, and look it up later. We considered it and rejected it for a reason specific to this product.

A lookup would restore the right to the report, not the report. The report is generated by a model running at temperature 0.4. If you re-grant the unlock and re-run the check, you get a different report, with different wording and maybe different numbers. Handing back different numbers isn't restoring a purchase.

So the restore link carries the whole report.

After paying, the buyer gets a link like this:

https://check.tattoo/restore#r=<base64url of the whole report>

Everything after # is the fragment, and browsers never send the fragment to a server. So this design stores nothing: no table of purchases, no codes anyone could guess, no personal data, nothing to delete later.

Opening the link re-installs the exact report that was paid for, for that one design.

The trade-off is explicit in the code: anyone holding the link gets that report. That's the same property a downloaded PDF has. It covers one design and can't unlock anything else.

The payload is JSON, base64url-encoded. Three things go wrong if you write this the obvious way:

export const encodeFragment = (payload: unknown): string => {
  const bytes = new TextEncoder().encode(JSON.stringify(payload));
  let latin1 = "";
  for (const b of bytes) latin1 += String.fromCharCode(b);
  return btoa(latin1).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
};

btoa is latin1-only and throws on anything above U+00FF.TextEncoder first.+, / and = are not safe in a fragment

export const decodeFragment = (hash: string, key: string): unknown => {
  try {
    const m = new RegExp(`[#&]${key}=([A-Za-z0-9_-]+)`).exec(hash);
    if (!m) return undefined;
    const b64 = m[1].replace(/-/g, "+").replace(/_/g, "/");
    const latin1 = atob(b64 + "=".repeat((4 - (b64.length % 4)) % 4));
    const bytes = new Uint8Array(latin1.length);
    for (let i = 0; i < latin1.length; i += 1) bytes[i] = latin1.charCodeAt(i);
    return JSON.parse(new TextDecoder().decode(bytes));
  } catch {
    return undefined;
  }
};

The report includes six dimension summaries, two or three recommendations and an artist brief. To keep the URL manageable, the payload is positional: an array, not an object. Keys would add hundreds of characters.

[version, designKey, orderId, overall, headline,
 [[score, verdict, summary] × 6],
 [[priority, title, detail] × n],
 artistBrief, contextLine]

Every field has a length cap (headline 300, each summary 1,200, the brief 4,000, at most five recommendations). According to a note in the code, five real reports measured between 2,829 and 3,443 characters. That's long for a URL, but it's the whole purchase.

A version number comes first, so the layout can change later without old links decoding into garbage.

Decoding checks the shape and rejects anything off. The version must match, scores must be integers from 0 to 100, and there must be exactly six dimensions. Strings are cut to their caps again on the way in. A shortened excerpt:

if (v !== RECOVERY_VERSION) return null;
if (typeof designKey !== "string" || !designKey) return null;
if (!isScore(overall) || typeof headline !== "string") return null;
if (!Array.isArray(dims) || dims.length !== DIMENSION_IDS.length) return null;

The browser doesn't send the fragment, but scripts on the page can read it. Our host injects a page-view measurement script into every page, and that script posts window.location.href, fragment included, to its own endpoint shortly after load. We can't change that script.

So the fragment has to leave the address bar before any deferred script runs. A synchronous inline script at the top of <head> does it:

<script>
  (function () {
    function strip() {
      try {
        var l = window.location;
        if (/^\/restore\/?$/i.test(l.pathname) && /[#&]r=/.test(l.hash)) {
          window.__restoreFragment = l.hash;
          try { sessionStorage.setItem("checktattoo.restoreFragment.v1", l.hash); } catch (e) {}
          history.replaceState(history.state, "", l.pathname + l.search);
        }
      } catch (e) {}
    }
    strip();
    window.addEventListener("hashchange", strip, true);
    window.addEventListener("popstate", strip, true);
  })();
</script>

Three details:

location.href, the address is plain /restore. sessionStorage``hashchange and popstate listeners, in the capture phase. Opening a recovery link doesn't restore anything by itself. Restoring writes to localStorage and replaces whatever report is already there. Someone who opens a friend's link out of curiosity shouldn't lose their own report without being asked. So /restore shows what it found and waits for a click. If a different paid report is already in that slot, it's archived rather than overwritten.

It doesn't fit if a purchase needs to be revocable, or if the payload is too large or too sensitive to hand to the user.

Our site has a page about the restore link for buyers. The tool itself is free to try at check.tattoo.

── more in #ai-products 4 stories · sorted by recency
── more on @check.tattoo 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/our-19-report-has-no…] indexed:0 read:4min 2026-11-28 · —