# Turning a closing shop's know-how into cards

> A multi-tenant web service that records the operating know-how of small business owners who are closing down through a six-axis interview, attaches a quote of the original answer to every card sentence for verification, and publishes the cards anonymously so people preparing to open a business in the same trade can read them.

- Published: 2026-11-11
- Client: Personal project (synthetic data)
- Role: Planning, design, implementation, deployment
- Period: 2026-10-30 ~ 2026-11-03
- Stack: Python, FastAPI, Supabase, Postgres RLS, procrastinate, Qwen, vcrpy, GSAP, Cloud Run
- Outcome: Card grounding ratio mean 0.345 → 1.0 (real Qwen, synthetic golden set of 10 cases, 3 real evaluation runs)
- Tags: llm, grounding, multi-tenant, rls, cloud-run

**Why**: An owner who ran a shop for 20 years carries a whole business book in their head, and on the day the shop closes, that book gets thrown out too.

**Principle**: Ungrounded sentences are flagged, not hidden, and when a number is low, fix the cause, not the threshold.

## Metrics

| Metrics | Value | Scope | Source |
| --- | --- | --- | --- |
| Card grounding ratio (real Qwen, synthetic golden set of 10 cases) | Mean 0.345 → mean 1.0 in all 3 real evaluation runs · minimum 1.0 · leaks 0 · empty axes 0 | Reproducible measurement | scripts/qwen-eval.sh (qwen3.7-flash, API key required), Development log (private), 2026-11-03 |
| Keyless regression (recorded replay) | 20 passed (10 cassettes, 0 auth headers) | Reproducible measurement | Recorded replay tests in tests/golden/cassettes/, Development log (private), 2026-11-03 |
| Tests (at deployment) | Unit 563, E2E 132 (skip 11) | Reproducible measurement | Development log (private), 2026-11-03 |
| Total self-hosted font size | 1,556KB (threshold 2,048KB or less) | Reproducible measurement | UI redesign E2E, Development log (private), 2026-11-03 |
| Public URL smoke test | 7/7 passed (no login, no writes) | Production measurement | tests/e2e/test_deploy_smoke.py, Development log (private), 2026-11-03 |

## Links

- Demo: https://shoplegacy-1072416881206.asia-northeast3.run.app
- Repository: https://github.com/ilyos-numon/shoplegacy

## 1. Situation

When a small business closes, its suppliers, the way it handled regulars, its seasonal sales patterns, and its failures go unrecorded. The next shop in the same spot makes the same mistakes, and people preparing to open a business read books and watch videos but never hear the story of "that trade in that neighborhood."

So I had the owner talk through questions on six axes (location, suppliers, menu, pricing, customers, failures), and turned the answers into anonymous "shop legacy cards" searchable by trade and region. I assumed the owner would not type, and that personal and business-name details would be masked automatically. The biggest risk was an LLM-written card containing something the owner never said.

## 2. Scoping

I decided not to sell commercial-district analysis data, broker key money or real estate, or recruit owners automatically. For the interview engine, I took the handover interview engine I had built earlier and only swapped its question tree for the six small-business axes. Parts that are dangerous to get wrong, such as login, authorization, and token verification, went to proven open source and managed services instead of being built by hand.

To fit the public deployment on a single 512Mi instance, I left out the speech recognition model and kept direct text input. Payments also run on a fake provider in the demo.

## 3. Build

| Category | What | Rationale |
| --- | --- | --- |
| Reused | Supabase login and RLS, PyJWT, procrastinate queue, cryptography, vcrpy, interview engine | Use proven pieces where mistakes are dangerous |
| Modified | Engine question tree changed to six axes, verification prompt made card-specific | Parser reused as is |
| Built | Grounding verification rules, pre-publication quality gate, 16 staff and public screens | A card is published only after passing grounding ratio, axis coverage, consent, and masking checks |

Tenant isolation is enforced by RLS policies, not app-level conditions. The app connects with a role that cannot bypass RLS.

## 4. What broke

**Grounding ratio 0.345.** Evaluating the synthetic golden set of 10 cases with real Qwen gave a mean of 0.345, with 8 of 10 cases below the threshold. Instead of lowering the threshold or editing the golden set, I dumped the drafts and verification responses. In 47 of 60 axes, the draft merged two or more answers into one paraphrased sentence, and 25 sentences had their evidence numbers dropped by the verifier. Other hypotheses were ruled out because their counts were 0. I changed the draft to "one sentence per answer, in the answer's own wording" and made evidence numbers mandatory. The cost was less polished sentences, which I listed as a limitation.

**Key set, still 401.** The evaluation script read `.env` with shell `source`, which left the key empty. Switching it to read the file the same way the app does fixed it.

**A container that failed only on Cloud Run.** The empty argument `--host ""` passed in exec form was dropped, so startup failed. Wrapping the command in a single shell string kept the binding.

## 5. Results

| Metric | Value | Scope | Source |
| --- | --- | --- | --- |
| Card grounding ratio | Mean 0.345 → mean 1.0 in all 3 real evaluation runs · minimum 1.0 | Reimplementation, synthetic golden set of 10 cases | Evaluation script, Development log (private) |
| Keyless regression | 20 passed (10 cassettes) | Reimplementation | Recorded replay tests |
| Tests | Unit 563, E2E 132 (skip 11) | Reimplementation | Development log (private) |
| Total font size | 1,556KB (threshold 2,048KB or less) | Reimplementation | UI redesign E2E |
| Public URL smoke test | 7/7 passed | Operations | Deployment smoke test |

The 1.0 is measured on synthetic data. There is no quality measurement yet from real owner interviews.

## 6. If I did it again

I would start with real-user validation. I did not run the 5 real owner interviews or the 3 interviews with people preparing to open a business, and the screens and golden set are all synthetic data. Next in line are a step that polishes sentences while keeping the evidence quotes, speech recognition in production (an API provider or a separate worker), and a public demo account plus moving the DB to the Seoul region.
