ThaiData UK โ Restaurant Data & Claim System
https://thaidata.uk โ Business intelligence and interactive tools for UK Thai restaurant operators. Free, no signup.
What's Here
- 1,594 Restaurant Pages โ Auto-generated from FSA data, one per UK Thai restaurant
- 253 City Pages โ Market data per UK city with FSA hygiene ratings
- 28 Chain Profiles โ Detailed intelligence on Thai restaurant chains
- 8 Interactive Tools: Wage calculator, delivery profit calculator, hygiene lookup, staffing calculator, market reports, supplier price tracker, restaurant valuation, competitor radar
- 8 Content Guides: Opening a restaurant, chef visas, marketing, revenue benchmarks, menu pricing, opening timeline, UK overview, city breakdown
- 5 City Guides: Enriched landing pages for Manchester, Leeds, Birmingham, Edinburgh, Bristol
- 35-Term Glossary: Industry terms with cross-references
- Free API v1: Cities.json endpoint โ no auth, no rate limit
- MCP Server: AI-callable tools at
/mcp (JSON-RPC 2.0)
- Claim System: Restaurant owners can claim and enhance their listings
Quick Start
git clone https://github.com/swifttiger888-commits/thaidata.git
cd thaidata
pip install -r requirements.txt
cp .env.example .env
cp wrangler.toml.example wrangler.toml
Architecture
โโโโโโโโโโโโโโโโโโโโโโโ
โ FSA API (Gov UK) โ
โโโโโโโโโโฌโโโโโโโโโโโโโ
โ weekly cron (Mon 9am)
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ fetch_all_thai_data โโโโ data/restaurants.json
โ .py (pipeline) โโโโ api/v1/cities.json
โโโโโโโโโโฌโโโโโโโโโโโโโโโโ api/v1/data.json
โ
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโ
โผ โผ โผ
generate_ generate_ generate_
restaurant_ menu_price_ city_links_
pages.py page.py .py
โ โ โ
โผ โผ โผ
r/[city]/ thai-menu- cities/[city]
[slug]/ price-index .html
index.html .html
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Cloudflare Pages (static deploy) โ
โ git push โ auto-build โ thaidata.uk โ
โ โ
โ functions/ โ API + MCP endpoints โ
โ api/ โ
โ claim.js POST /api/claim โ
โ admin.js POST/PUT /api/admin โ
โ listing.js GET/PUT /api/listing โ
โ search.js GET /api/search โ
โ upload.js POST /api/upload โ
โ claimed.js GET /api/claimed โ
โ diag.js GET /api/diag โ
โ mcp.js POST /mcp โ
โ _middleware.js CORS โ
โ โ
โ D1 Database (SQLite) โ
โ claims, listings, auth_tokens โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Project Structure
thaidata/
โโโ scripts/
โ โโโ fetch_all_thai_data.py # Main data pipeline (FSA API โ JSON)
โ โโโ generate_restaurant_pages.py # 1,594 individual restaurant pages
โ โโโ generate_menu_price_page.py # Menu price index page
โ โโโ collect_menu_prices.py # Manual price survey tool
โ โโโ add_city_restaurant_links.py # Link city pages โ restaurant pages
โ โโโ websub-ping.py # WebSub/IndexNow notification
โโโ functions/
โ โโโ _middleware.js # CORS handler
โ โโโ mcp.js # MCP server (AI tools)
โ โโโ api/
โ โโโ admin.js # Admin panel API
โ โโโ claim.js # Claim submission
โ โโโ claimed.js # Claimed listing queries
โ โโโ diag.js # Diagnostics
โ โโโ listing.js # Listing management
โ โโโ search.js # FSA proxy search
โ โโโ upload.js # Photo upload
โโโ data/
โ โโโ restaurants.json # 1,594 restaurants (SINGLE SOURCE OF TRUTH)
โ โโโ postcode_geocodes.json # Geocoded postcodes
โโโ api/v1/
โ โโโ cities.json # 253 city statistics
โ โโโ data.json # Overview data
โโโ schema.sql # D1 database schema
โโโ wrangler.toml # Cloudflare Pages config (LIVE)
โโโ wrangler.toml.example # Template for new devs
โโโ .env.example # Environment variable template
โโโ .gitignore
โโโ requirements.txt # Python dependencies
Data Pipeline
The weekly data refresh runs every Monday at 9:00 AM via cron job (Hermes Agent).
Pipeline steps:
scripts/fetch_all_thai_data.py โ Fetches FSA FHRS + FHIS APIs
- Searches by "Thai" keyword across all business types
- Searches 11 named chains (Giggling Squid, Busaba, etc.) for non-"Thai" named restaurants
- Deduplicates by FHRSID (first match wins)
- Maps Local Authorities โ cities via 85-entry lookup table
- Computes city statistics (population density, avg hygiene rating)
- Saves:
data/restaurants.json, api/v1/cities.json, api/v1/data.json
scripts/generate_restaurant_pages.py โ Generates individual /r/ pages
scripts/add_city_restaurant_links.py โ Adds restaurant links to city pages
- Push to git โ Cloudflare Pages auto-deploys
Run manually:
python3 scripts/fetch_all_thai_data.py
python3 scripts/generate_restaurant_pages.py
python3 scripts/add_city_restaurant_links.py
git add -A && git commit -m "weekly data refresh" && git push origin main
Note: The pipeline script writes to /tmp/thaidata-repo/ by default. Edit REPO_DIR at the top of scripts/fetch_all_thai_data.py if your working directory is different.
Environment Variables
Set these in Cloudflare Dashboard (Workers & Pages โ thaidata-uk โ Settings โ Variables):
| Variable | Required | Description |
|---|
ADMIN_PASSWORD | Yes | Password for /admin panel |
MAGIC_LINK_SECRET | Yes | 64+ char random key for claim token signing |
RESEND_API_KEY | Yes | Resend.com API key (starts with re_) for magic link emails |
SITE_URL | Yes | https://thaidata.uk |
D1 Database Setup
wrangler d1 create thaidata-db
wrangler d1 execute thaidata-db --file=schema.sql
Deploy
git add -A && git commit -m "your message" && git push origin main
Claim System Flow
- Owner visits
/claim/, searches for their restaurant
- Submits claim with name, email, phone, verification notes
- Admin reviews at
/admin/ (password protected)
- On approval: listing created, owner receives magic link email via Resend
- Owner edits at
/listing/manage?token=... โ description, photos, hours, etc.
Security:
- Magic link tokens: single-use, SHA-256 hashed, 1-hour expiry
- Admin sessions: 24-hour expiry
- Rate-limited admin login: 5 attempts / 15 min per IP
Data Sources
- Food Standards Agency (FSA) โ hygiene ratings and establishment data via FHRS API
- Food Hygiene Information Scheme (FHIS) โ Scotland data
- Manual menu price surveys โ 75 dish-price pairs across 5 cities
- ONS 2024 mid-year population estimates (for city per-capita calculations)
License
MIT โ data sourced from FSA (Open Government Licence).