F1 Wiki Automator
F1 Wiki Automator is a comprehensive automation pipeline and dashboard that keeps the Formula 1 Wiki on Fandom updated with real-time race data. By pulling from open F1 telemetry endpoints, scraping session articles, and parsing session times, it formats, compiles, and deploys MediaWiki wikitext templates automatically at the conclusion of every Grand Prix weekend session.
System Architecture
Compute & AI
| Core Runtime | Cloudflare Workers (TypeScript) |
| AI Generation | Cloudflare Workers AI (Llama 3), Gemini, OpenAI fallbacks |
| APIs Ingested | Jolpi F1 API (formerly Ergast) & F1.com crawling |
| Local scripts | Python (Pandas, BeautifulSoup) |
Data & Messaging
| Cache Storage | Cloudflare KV (Rate-limit buffering & stats caches) |
| Sync Control | Per-Target KV Flags (granular section/template states) |
| Cron Tasks | Wrangler Triggers (30-min polling & auto-retries) |
| Outbound API | MediaWiki Bot API & Resend API (6 AM PST mailing) |
Security & Quality
| Access Shield | Cloudflare Turnstile CAPTCHA (on manual overrides) |
| Regex Audit | CodeQL-safe line-based wikitext parsing |
| Credentials | Wrangler Secrets (Bot accounts & API keys) |
| Data Guard | Safe infobox updates (avoids overwriting human edits) |
Automated Cron Synchronizer: Cloudflare Worker cron triggers poll the Jolpi F1 API and scrape F1.com periodically during race weekends. As sessions conclude, the worker drafts LLM session reports, populates infoboxes, updates standings and career stats, and pushes wikitext updates directly to Fandom.
Core Features
- LLM-Powered Section Reports — Automatically crawls F1.com session articles and uses Llama 3 (Cloudflare Workers AI), Google Gemini, or OpenAI with automatic failovers to draft factual, encyclopedia-style reports for GP sections without overwriting human edits.
- Dynamic Infobox Updating — Parses and populates race infoboxes (
Infobox_Race/Infobox Sprint Race) with pole times, podium finishers, fastest laps, and sprint standings as each session concludes. - 21 Career Stats Templates — Computes cumulative stats (Championships, Wins, Podiums, Poles, Entries, Laps Led, etc.) by combining historical baselines with active season results.
- Practice & Test Driver Automation — Scrapes raw practice results from Formula1.com, handles time differentials, and dynamically appends rookie test drivers appearing in FP1 to the wiki’s Entry List.
- Granular KV Sync Flags — Leverages per-target Cloudflare KV sync states (for each section, career template, and standings template) to isolate retry behavior and prevent a single failure from blocking other updates.
- CodeQL-Safe Wikitext Parsing — Avoids ReDoS vulnerabilities by replacing polynomial regular expressions with custom line-by-line parsing algorithms (
wikitext-parse.ts) for MediaWiki templates. - Operational Reporting Dashboard — Integrates with the Resend API to deliver daily status emails (at 6 AM PST) listing API quotas, successes, failures, and warnings like crawling issues or unresolved test driver flags, managed via an interactive, F1-themed web control panel.