01.Executive Summary
Traditional chess dashboards render analytics in heavy monolithic pages that degrade client performance and increase DOM size. The official FIDE rating database serves as the source of truth, yet lacks clean structural endpoints for developers.
FIDE Analytics resolves this by acting as a high-performance scraping pipeline, edge database cache, and modular React interface. In our latest refactor, we split the application into decoupled client-side components and isolated complex widgets (rating history charts and game statistics) onto dedicated player pages.
“Our core engineering goal is to query FIDE profiles, compile historical progress charts, aggregate White vs. Black game performance, and store them securely at the edge. Moving history and statistics to dynamic player routes reduces initial bundle size and provides a focused analytical environment.”
02.Modular System Architecture
By refactoring our codebase to use shadcn with base-ui primitives, we replaced a 1000-line monolithic file with clean, reusable components:
Dashboard Components
The homepage dashboard houses the RankingList component for sorting standard categories and the PlayerProfileCard displaying core statistics and links.
Dynamic Player Route
Opening `/player/[id]` renders the selected player profile card along with HistoryChart (Recharts ratings progress) and StatsCard (White/Black win percentages).
This modular architecture allows components to fetch their own revalidated cache segments dynamically on Cloudflare Pages workers using OpenNext.
03.The Scraping Engine
At the heart of the service is the parsing component inside lib/scraper.ts. Using the Cheerio parser, the backend reads raw HTML and executes document traversals using jQuery-style selectors.
// Fetch and parse FIDE ranking list
import * as cheerio from 'cheerio'
export async function scrapeTopList(listType: string) {
const url = `https://ratings.fide.com/a_top.php?list=${listType}`
const response = await fetch(url, { headers: COMMON_HEADERS })
const html = await response.text()
const $ = cheerio.load(html)
const players = []
$('table.top_recors_table tr').each((_, element) => {
const rankSpan = $(element).find('.rank_span')
if (rankSpan.length === 0) return
const rank = parseInt(rankSpan.text().trim(), 10)
const nameLink = $(element).find('a')
const name = nameLink.text().trim()
const fideId = parseInt(nameLink.attr('href')?.match(/profile\/(\d+)/)?.[1] || '0', 10)
players.push({ rank, fideId, name })
})
return players
}04.Caching & Edge D1
Scraping external assets dynamically on every HTTP request induces latency and increases the risk of being rate-limited by target hosts. FIDE Analytics implements a double-sided caching pattern:
Database Persistence (D1)
Every player detail sheet, win-draw-loss stats log, and historical chart table retrieved is parsed and saved permanently in the Cloudflare D1 SQL tables. If subsequent requests land within a threshold, D1 satisfies queries immediately.
Forced Sync Revalidation
API endpoints support bypass queries, and the frontend dashboard includes a re-validate action button. This instructs the worker to bypass local cached SQL blocks, retrieve hot FIDE logs, refresh SQLite tables, and return fresh records.
05.Multi-Theme Architecture
To offer superior customizability, the UI integrates a theme provider supporting 6 color variants: **Light**, **Dark**, and the four **Catppuccin** variants (**Latte**, **Frappé**, **Macchiato**, **Mocha**).
Instead of using standard client-only hooks that trigger style re-renders, the provider integrates an inline SSR hydration script in the HTML head tag that reads from localStorage and immediately injects the active class into `document.documentElement` during initial render.
Tailwind CSS v4 custom variables map these theme colors to semantic utilities (like `bg-card`, `text-foreground`, `border-border`, and `stroke-chart-1`), keeping our CSS stylesheet compact and performant.
06.Developer API
We provide clean, public REST API routes. All endpoints return structural JSON payloads, optimized for application builders and integrations.
/api/list?list=openReturns the FIDE Top 100 list players of a specific rating category (e.g. open, women, juniors).
/api/profile?id=1503014Returns comprehensive profile metrics, ratings, active/all-time world rankings, and historical progress coordinates of a chess player in a single consolidated response.
Was this documentation post helpful?
We rely on community inputs to refine architectural articles.