SETUP_GUIDE
Installation
How to install and run the KhelaDekho Next.js frontend and FastAPI backend locally for development.
1. Backend Setup (FastAPI)
Clone the backend repository, create a virtual environment, and install the Python dependencies.
system.out
$
# Navigate to backend directory
cd kheladekho-api
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Copy environment variables template
cp .env.example .env2. Frontend Setup (Next.js)
Navigate to the frontend directory, install NPM packages, and prepare your environment variables.
system.out
$
# Navigate to frontend directory
cd KhelaDekho
# Install dependencies
npm install
# Copy environment variables template
cp .env.example .env.local3. Environment Configuration
Now that you have copied the templates, edit your .env (Backend) and .env.local (Frontend) files.CRITICAL: Ensure KHELADEKHO_SECRET_KEY is exactly the same in both files.
Backend Specific (.env)
system.out
$
# ==========================================
# KhelaDekho Backend Configuration Template
# ==========================================
# Cryptographic HMAC-SHA256 Signing Key (Required in Production)
# This key MUST match the one configured on the Next.js frontend.
# Generate a secure key using: openssl rand -hex 32
KHELADEKHO_SECRET_KEY=your-hmac-secret-key-here
# Upstream Scraper Target URL
KHELADEKHO_TARGET_URL=your-target-url-here
# Central Cache Store (Falls back to local memory if omitted)
KHELADEKHO_REDIS_URL=redis://localhost:6379/0
# General Server Configurations
KHELADEKHO_DEBUG=false
KHELADEKHO_LOG_LEVEL=INFO
# Cache TTL Configurations (Seconds)
KHELADEKHO_MATCH_CACHE_TTL=120
KHELADEKHO_CHANNEL_CACHE_TTL=120
# Connection & Scraper Request Timeouts/Retries
KHELADEKHO_REQUEST_TIMEOUT=30.0
KHELADEKHO_MAX_RETRIES=3
# Rate Limiter Configuration (Requests Per Minute)
KHELADEKHO_RATE_LIMIT_RPM=30Frontend Specific (.env.local)
system.out
$
# ===========================================
# KhelaDekho Frontend (Next.js) Configuration
# ===========================================
# --- KhelaDekho Decryption API ---
# URL pointing to your backend (FastAPI server or Cloudflare Worker)
KHELADEKHO_API_URL=https://your-api.workers.dev
# HMAC-SHA256 Secret Key (Must match backend KHELADEKHO_SECRET_KEY)
KHELADEKHO_SECRET_KEY=your-hmac-secret-key-here
# --- Client-Side API Override (Optional) ---
# Override backend API URL inside the browser client (e.g. for localhost debugging)
NEXT_PUBLIC_API_URL=
# --- Telegram Contact Form ---
# Get your bot token from @BotFather on Telegram
TELEGRAM_BOT_TOKEN=your-telegram-bot-token-here
# Get your chat ID (message @userinfobot on Telegram)
TELEGRAM_CHAT_ID=your-telegram-chat-id-here
# --- GitHub Integration (Optional) ---
# Personal Access Token (PAT) to fetch repository metadata
GITHUB_TOKEN=ghp_your-github-token-here
# --- Google Analytics 4 (Optional) ---
# Measurement ID for GA4 property (e.g. G-XXXXXXXXXX)
# If empty, analytics scripts and tracking are disabled entirely
NEXT_PUBLIC_GA_MEASUREMENT_ID=G-XXXXXXXXXX4. Start Services
Open two separate terminal windows to run both servers simultaneously.
Terminal 1 (Backend)
system.out
$
cd kheladekho-api
source venv/bin/activate
uvicorn app.main:app --reload --port 8000Terminal 2 (Frontend)
system.out
$
cd KhelaDekho
npm run dev5. Verify Installation
> Open your browser and navigate to http://localhost:3000. You should see the KhelaDekho lobby. If the backend is running properly, the live matches and channels will populate automatically.