Skip to content

RonakDarji1997/iptv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

63 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

IPTV Platform - Backend & Admin Dashboard

This is the backend API and admin dashboard for the IPTV platform. The user-facing application is built with Expo React Native (see /expo-rn folder).

Architecture

  • Backend API (Port 2005) - Next.js API routes
  • Admin Dashboard (Port 2005/dashboard) - Next.js web UI for management
  • User App - Expo React Native app (separate folder: /expo-rn)
  • Database - PostgreSQL with Prisma ORM

Getting Started

1. Database Setup

First, set up PostgreSQL and create a database:

# Create database
createdb iptv_platform

# Or using psql
psql -U postgres
CREATE DATABASE iptv_platform;

2. Environment Setup

Create a .env.local file in the root directory:

# Database
DATABASE_URL="postgresql://user:password@localhost:5432/iptv_platform"

# Encryption (generate with: openssl rand -hex 32)
ENCRYPTION_KEY="your-32-byte-hex-key-here"

# JWT Secret (change in production)
JWT_SECRET="your-jwt-secret-key-change-in-production"

# Stalker Portal Configuration (for legacy support)
STALKER_MAC=00:1A:79:XX:XX:XX
STALKER_URL=http://your-portal-url/stalker_portal/
STALKER_BEARER=your_bearer_token
STALKER_ADID=your_adid

3. Install Dependencies

npm install

4. Run Database Migrations

npx prisma migrate dev

5. Run the Development Server

npm run dev

Open http://localhost:2005 with your browser - it will redirect to the admin dashboard.

Admin Dashboard: http://localhost:2005/dashboard

Features

Backend API

  • πŸ” JWT Authentication - Secure user authentication with JSON Web Tokens
  • πŸ‘€ User Management - Register and login users
  • πŸ“‘ Provider Management - Add and manage IPTV providers
  • πŸ‘₯ Profile System - Multiple profiles per user with parental controls
  • πŸ“± Device Management - Register and track TV devices
  • πŸ”„ Content Sync - Automatic content synchronization from Stalker portals
  • πŸ“¦ Snapshot System - Pre-filtered, compressed content snapshots per profile
  • πŸ” Encryption - AES-256-GCM encryption for sensitive credentials
  • 🎬 Stream URLs - Secure streaming link generation

Admin Dashboard

  • πŸ“Š Overview - System statistics and recent activity
  • πŸ“‘ Providers - Manage IPTV providers with auto-handshake
  • πŸ‘€ Profiles - Create profiles with age ratings and types (Admin/Kid/Guest)
  • πŸ“± Devices - View and manage registered devices
  • πŸ”„ Sync Status - Monitor content synchronization

User App (Expo React Native)

See /expo-rn folder for the user-facing mobile/TV application with:

  • Username/password login
  • Profile selection
  • Instant content loading from snapshots
  • Live TV, Movies, Series browsing
  • Video playback

API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login with username/password
  • GET /api/auth/me - Get current user (requires JWT)

Providers

  • GET /api/providers - List all providers
  • POST /api/providers - Add new provider (auto-handshake)
  • PATCH /api/providers/:id - Update provider
  • DELETE /api/providers/:id - Delete provider

Profiles

  • GET /api/profiles?userId=:id - Get user's profiles
  • POST /api/profiles - Create new profile
  • PATCH /api/profiles/:id - Update profile
  • DELETE /api/profiles/:id - Delete profile

Devices

  • GET /api/devices - List all devices
  • POST /api/devices - Register new device

Sync & Snapshots

  • POST /api/sync/:providerId - Trigger content sync
  • GET /api/snapshots/:profileId/latest - Get profile snapshot

Streaming

  • POST /api/stream/link - Get streaming URL

Quick Start Guide

1. Create First User

curl -X POST http://localhost:2005/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","email":"admin@example.com","password":"yourpassword"}'

2. Add Provider (Dashboard)

  1. Visit http://localhost:2005/dashboard/providers
  2. Click "Add Provider"
  3. Enter Stalker portal credentials
  4. System will auto-handshake

3. Create Profile (Dashboard)

  1. Go to /dashboard/profiles
  2. Create profile for your user
  3. Choose type (Admin/Kid/Guest)
  4. Set age rating if needed

4. Sync Content (Dashboard)

  1. Go to /dashboard/sync
  2. Click "Sync Now" for provider
  3. Wait for completion
  4. Snapshots generated automatically

5. Use Expo App

  1. cd expo-rn
  2. npm start
  3. Login with username/password
  4. Select profile
  5. Enjoy!

Security

  • πŸ” JWT Tokens - Secure authentication with 7-day expiry
  • πŸ”’ Password Hashing - bcrypt with 10 rounds
  • πŸ” Credential Encryption - AES-256-GCM for bearer tokens and passwords
  • πŸ”‘ MAC Address Binding - Device validation for streaming
  • ⚠️ Never commit .env.local to version control

Project Structure

/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/              # Backend API routes
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/         # Authentication endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ providers/    # Provider management
β”‚   β”‚   β”‚   β”œβ”€β”€ profiles/     # Profile management
β”‚   β”‚   β”‚   β”œβ”€β”€ devices/      # Device management
β”‚   β”‚   β”‚   β”œβ”€β”€ sync/         # Content synchronization
β”‚   β”‚   β”‚   β”œβ”€β”€ snapshots/    # Snapshot delivery
β”‚   β”‚   β”‚   └── stream/       # Streaming URLs
β”‚   β”‚   β”œβ”€β”€ dashboard/        # Admin dashboard pages
β”‚   β”‚   └── page.tsx          # Root (redirects to dashboard)
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   └── dashboard/        # Dashboard UI components
β”‚   └── lib/
β”‚       β”œβ”€β”€ prisma.ts         # Database client
β”‚       β”œβ”€β”€ jwt.ts            # JWT utilities
β”‚       β”œβ”€β”€ crypto.ts         # AES encryption
β”‚       β”œβ”€β”€ sync-service.ts   # Content sync logic
β”‚       └── stalker-client.ts # Stalker API client
β”œβ”€β”€ expo-rn/                  # User-facing Expo app
β”œβ”€β”€ prisma/
β”‚   └── schema.prisma         # Database schema
└── README.md

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors