SYS_ARCHITECTURE

Architecture

How KhelaDekho works under the hood — the streaming pipeline from source aggregation to decryption to playback.

Lobby Lounge

The Pipeline

data_flow
Client RequestX-Key AuthProvider Scrape / Edge ProxyCached JSONScores / HLS / DASH
Layer 01

Frontend UI (Next.js)

The presentation layer is built with Next.js and Tailwind CSS. It focuses on a premium, glassmorphic aesthetic while rendering live scores and sports channels. API requests carry the shared xkey, injected server-side so it never ships in client bundles.

system.out
$
// V1 serves live scores from the configured provider
const scores = await getGoalScores();          // GET /api/v1/scores
// competitions[].matches[] -> teams, score, status, period
Layer 02

FastAPI Gateway

The same API is available as a Python FastAPI app and a Cloudflare Worker. Both validate the shared xkey, use an in-memory TTL cache with stampede protection, and fetch upstream data concurrently over HTTPX / fetch.

Key Features
  • Single X-Key Auth — One shared key guards every endpoint (proxy routes exempt).
  • TTL Caching — Provider responses are cached briefly to reduce upstream load.
  • Rate Limiting — The contact form has a per-IP rate limit (3 requests/minute). API endpoints have no rate limiting.
Layer 03

Streaming Servers (V2 / V3 / V4 / V5)

For channel streams, Cloudflare Workers proxy HLS/DASH segments from source CDNs and rewrite manifests to bypass CORS and Referer checks. ClearKey DRM parameters are passed through to the player for supported channels.

The Live Matches page offers four servers
  • V2 & V4 — channel providers proxied through the backend API (/api/v2/*, /api/v4/*).
  • V5 — match-first API with ?sport=football (default) and ?sport=cricket. The Cricket page (/cricket) is locked to V5 with no server switcher. Also provides DLHD 24/7 TV channel list (/api/v5/tv/channels and /api/v5/tv/channel/:id/stream). The Live TV page sources from V5 DLHD channels (878+ channels with auto-categorization). On channel selection, the stream URL is resolved on demand and proxied through /api/v5/proxy.
  • V3 — a self-hosted playlist (M3U8 or JSON) stored in Cloudflare KV and managed from the admin panel. Served by the frontend route /api/playlist, which merges sources, de-duplicates channels, and applies per-channel overrides. Used as a fallback data source for the Live TV page when V5 is unavailable.