SETUP_GUIDE

Installation

How to install and run the KhelaDekho Next.js frontend and FastAPI backend locally for development.

Lobby Lounge

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 .env

2. 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.local

3. Environment Configuration

Now that you have copied the templates, edit your .env.local (Frontend) file.

Worker (wrangler.toml / Cloudflare Dashboard)
system.out
$
# Set in wrangler.toml under [vars]:
V1_HOME_URL=https://your-v1-provider.example
V2_HOME_URL=https://your-v2-provider.example
V4_HOME_URL=https://your-v4-provider.example
# XKEY is a secret: wrangler secret put XKEY
Frontend (.env.local)
system.out
$
# --- Backend API ---
KHELADEKHO_API_URL=https://your-api.workers.dev
XKEY=your-xkey-here

# --- Telegram Contact Form ---
TELEGRAM_BOT_TOKEN=your-telegram-bot-token-here
TELEGRAM_CHAT_ID=your-telegram-chat-id-here

# --- GitHub (Optional) ---
GITHUB_TOKEN=

# --- Google Analytics 4 (Optional) ---
NEXT_PUBLIC_GA_MEASUREMENT_ID=

4. 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 8000
Terminal 2 (Frontend)
system.out
$
cd KhelaDekho
npm run dev

> The backend also ships as a Cloudflare Worker (the production API). To run it instead of FastAPI, start the Wrangler dev server and point the frontend at it via KHELADEKHO_API_URL=http://localhost:8787.

Alternative Backend (Cloudflare Worker)
system.out
$
cd KhelaDekho-API/worker
npm install
npm run dev        # http://localhost:8787
# deploy: npm run deploy  (set XKEY via: wrangler secret put XKEY)

5. 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.