Skip to content
Nicholas Salim
Back to work

API-driven stats dashboard

WarRoomStats

Clan, war and player stats for Clash of Clans, pulled live from the official game API and cached so pages stay quick.

WarRoomStats home page

What makes it different

  • One cache for every request

    Every API call goes through a single cache boundary, with a lifetime set per endpoint and a short one for failures. Different spellings of the same clan tag share one cache entry and one upstream call.

    • Next.js Cache Components
    • cacheLife
  • Pages that stream in

    Each page sends its layout straight away and streams the slower stats in as they arrive, so nothing waits on the slowest call.

    • React Suspense
    • Streaming
  • Nothing unchecked reaches a page

    Every API response is validated against a schema. Errors come back as typed results, so each page shows a specific message instead of crashing.

    • Zod
    • TypeScript
  • The API token stays on the server

    The API client is server-only, so the token never reaches the browser. Each visitor's IP is rate limited before requests reach the API.

    • server-only
    • Proxy rate limiting
  • Built and tested without the real API

    A fixture mode serves recorded API data, so development and end-to-end tests run without a token. The build refuses to ship to Vercel with fixtures switched on.

    • Playwright
    • Fixtures
  • Checked on every push

    GitHub Actions runs unit tests, type checks and lint on every push.

    • GitHub Actions
    • Vitest
  • Next.js
  • REST API
  • Caching
  • Playwright
Next projectReGear