At Omotenashi Robotics Inc., alongside operating our own commercial linen factory and developing bimanual Physical AI robots in Tokyo, our engineering team co-develops and co-operates Homewine (with WINE TRAIL Inc.) — a subscription wine education platform, structured wine encyclopedia, and multimodal AI sommelier in Japan.
As the platform expanded to 1,146 static pages, 445 detailed wine monographs, 183 world wine classifications, a 1,000-question CBT sommelier exam drill, and 43 password-protected tasting video pages, our legacy WordPress (PHP + MySQL + admin-ajax.php) stack hit severe architectural ceilings:
-
Unpredictable TTFB on multi-facet wine filtering (
meta_querySQL joins). -
839 KB of denormalized client-side JSON (
scanner-master.json+catalog-rest.json), stalling mobile main threads. -
Legacy QR code constraints: Tens of thousands of printed physical wine textbooks already in customers' hands contain QR codes with
?pass=...query parameters for tasting videos — meaning zero URL breakage was allowed when eliminating PHP.
Here is how we eliminated WordPress completely (0 .php files remaining, enforced by CI), migrated to Cloudflare Pages + Edge Functions, compressed the client search database by 96.6% (to ~28 KB gzip) using Third Normal Form (3NF) columnar JSON, and released our core wine datasets under CC BY 4.0.
1. Compiling 839 KB of Denormalized JSON into a 28 KB 3NF Columnar Index
In a naive JSON array of wine objects, keys like "country_ja", "grape_ja", "producer_ja", and repeated dimension values ("Cabernet Sauvignon", "Bordeaux", importer names) dominate payload size.
During our static build pipeline (compile_wine_db.py), we transform all catalog records into wine-db.v2.json:
- 3NF Dimension Dictionaries: Countries, regions, grape varieties, wine types, producers, and importers are extracted into integer-indexed lookup tables.
- Keyless Positional Tuples: Each wine row is serialized as a compact positional tuple rather than an object with repeated property names.
-
2-Gram Token-Prefix Inverted Index (
pfx): Japanese wine search requires matching katakana with or without interpuncts (シャトー・マルゴーvsシャトーマルゴー) alongside French/Italian/English names (Chateau Margaux). By NFKC-normalizing tokens at build time and emitting a 2-character prefix inverted index, client-side search intersects small integer posting lists in < 1 ms without scanning every row.
{
"v": 2,
"dims": {
"countries": [["france", "フランス"], ["italy", "イタリア"]],
"grapes": [["cabernet-sauvignon", "カベルネ・ソーヴィニヨン"]]
},
"cols": ["slug", "ja", "en", "country_id", "region_id", "grape_id", "type_id", "price_jpy", "in_stock"],
"rows": [
["chateau-margaux", "シャトー・マルゴー", "Chateau Margaux", 0, 12, 0, 0, 118000, 0]
],
"pfx": {
"シャ": [0, 4, 19],
"ma": [0, 31]
}
}
We simultaneously removed render-blocking jQuery and Swiper bundles across 458 store pages, replacing them with zero-dependency vanilla ES modules.
2. Multimodal Front + Back Wine Label Scanner at the Edge
Most consumer wine scanners only inspect the front label. In Japan's wine market, however, sommeliers always check the Japanese back label to identify the importer — because whether a bottle crossed the equator in a temperature-controlled 14°C reefer container or an unrefrigerated parallel-import container dramatically affects bottle condition.
In our AI Wine Sommelier (/store/scan/):
- Users photograph both the front label and back label.
- A Cloudflare Pages Function computes SHA-256 digests, archives image pairs asynchronously to Cloudflare R2, and uses Gemini multimodal structured output strictly for entity extraction (producer, cuvée, vintage, and Japanese importer string).
- All factual claims — official classification tier, vintage weather/score, reefer transport status across 30 major Japanese importers, and market price ranges — are resolved deterministically against our curated database rather than hallucinated by the model.
3. Zero-Regression Static Builds: 92 Automated Build Assertions in 1.9s
Every deployment runs node build.mjs && node --test tests/*.test.mjs across all 1,146 generated HTML files in under 2 seconds, verifying:
- Valid
@graphJSON-LD syntax on every single page (Product,Article,FAQPage,Dataset,Quiz,BreadcrumbList). - Zero duplicate
<title>tags, single<h1>per<main>, non-emptyalt+ explicitwidth/heighton all 22,975 image references. - Zero collisions between the 978 URLs in
sitemap.xmland 301/302 rules in_redirects. - Edge HMAC-SHA256 cookie authentication (
HttpOnly; Secure; SameSite=Lax) with303 See Otherquery-stripping so legacy textbook?pass=QR codes keep working without ever echoing credentials into HTML.
4. Open Benchmark Dataset (CC BY 4.0)
To support researchers, sommelier exam learners, and developers building food-pairing or domain-specific retrieval systems, we have published four structured datasets from the platform under CC BY 4.0:
- Interactive Statistics & Citation Hub: https://homewine.jp/facts/
- World Wine Classifications Registry (All 183 Tiers): https://homewine.jp/store/classifications/
- 20 Regions × 18 Years Vintage Heatmap (360 Region-Years): https://homewine.jp/store/vintage-chart/
- 100 Everyday Japanese Dishes × 5-Axis Taste Vector Pairing DB: https://homewine.jp/store/pairing/
- Free 1,000-Question Sommelier CBT Drill: https://homewine.jp/academy/drill/
- GitHub Repository (CSV / JSON): omotenashi-robotics/wine-open-benchmarks
Top comments (1)
The constraint that does the most work in this post is the printed QR codes — tens of thousands of textbooks in customers' hands means zero URL breakage, and that single rule forces the whole architecture: no PHP, but the ?pass= flow has to survive on the edge with HMAC cookies and a 303 that strips the credential. The 3NF columnar trick is the other lesson I will steal: 839 KB to 28 KB is not a compression win, it is a data-model win, and the 2-gram prefix index for katakana with and without interpuncts is exactly the kind of detail a generic search library would get wrong. With 92 assertions running in 1.9 seconds across 1,146 pages, which check has actually caught a real regression so far — the JSON-LD validation, or the sitemap-versus-redirects collision check?