Architecture
How KhelaDekho works under the hood — the streaming pipeline from source aggregation to decryption to playback.
The Pipeline
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.
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.
- ▸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.
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.
- ▸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/channelsand/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.