A full-stack IPTV admin panel for managing devices, channels, and news for AlKarma TV. This application allows administrators to manage devices, their permissions, channels, and news content, with appropriate APIs for client devices.
- React.js - Frontend library for building user interfaces
- React Router - For client-side routing
- React Bootstrap - UI component library
- Formik & Yup - Form handling and validation
- Axios - HTTP client for API requests
- React Icons - Icon library
- React-Toastify - For displaying notification messages
- Node.js - JavaScript runtime
- Express - Web framework for Node.js
- SQLite3 - Lightweight, serverless database
- Multer - For handling file uploads (channel logos)
- CORS - For cross-origin resource sharing
- Dashboard - Overview of system stats, expiring devices, and recent actions
- Devices Management - CRUD operations for devices, activation codes, and permissions
- Channels Management - CRUD operations for channels with logo uploads
- News Management - CRUD operations for news articles
- Client APIs - APIs for device registration, activation, and content delivery
AlKarma-TV/
├── client/ # Frontend React application
│ ├── public/ # Static files
│ └── src/ # React source code
│ ├── components/ # Reusable components
│ ├── pages/ # Page components
│ ├── services/ # API services
│ └── utils/ # Utility functions
├── server/ # Backend Node.js application
│ ├── controllers/ # API controllers (future implementation)
│ ├── models/ # Database models (future implementation)
│ ├── routes/ # API routes
│ ├── uploads/ # Folder for channel logos
│ ├── database.sqlite # SQLite database file
│ └── index.js # Server entry point
└── README.md # Project documentation
- Node.js (v16.x or higher)
- npm (v8.x or higher)
- PM2 (Process Manager) for running in production
-
Clone the repository
git clone https://your-repository-url/AlKarma-TV.git cd AlKarma-TV -
Install dependencies
npm install -g pm2 cd server && npm install && cd ../client && npm install && cd ..
-
Start both server and client with PM2
pm2 start ecosystem.config.js
This will:
- Start the server at http://localhost:5000
- Start the client at http://localhost:3000
- Monitor both processes
-
View logs
pm2 logs
-
Stop all processes
pm2 stop all
-
Clone the repository
git clone https://your-repository-url/AlKarma-TV.git cd AlKarma-TV -
Install backend dependencies
cd server npm install -
Start the backend server
npm run dev
This will start the server at http://localhost:5000
-
Install frontend dependencies (in a separate terminal)
cd AlKarma-TV/client npm install -
Start the frontend development server
npm start
This will start the client at http://localhost:3000
-
Build the React frontend
cd client npm run build -
Prepare the server for production
cd ../server npm install --production
- Ubuntu Server (18.04 LTS or higher)
- Node.js (v16.x or higher)
- npm (v8.x or higher)
- PM2 (Process Manager for Node.js applications)
-
Install Node.js and npm
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - sudo apt-get install -y nodejs -
Install PM2 globally
sudo npm install pm2 -g
-
Clone the repository on the server
git clone https://your-repository-url/AlKarma-TV.git cd AlKarma-TV -
Install dependencies and build for production
# Install server dependencies cd server npm install --production cd .. # Install and build client cd client npm install npm run build cd ..
-
Create production ecosystem file Create a file named
ecosystem.production.config.js:module.exports = { apps: [ { name: 'alkarma-tv-server', script: 'server/index.js', env_production: { NODE_ENV: 'production', PORT: 5000 }, instances: 1, autorestart: true, watch: false, max_memory_restart: '1G' } ] };
-
Setup Nginx to serve static files and proxy API requests
Install Nginx:
sudo apt install nginx
Create a new Nginx site configuration:
sudo nano /etc/nginx/sites-available/alkarma-tv
Add the following configuration:
server { listen 80; server_name your_domain_or_IP; # Serve React static files location / { root /path/to/AlKarma-TV/client/build; try_files $uri /index.html; expires 1d; add_header Cache-Control "public, max-age=86400"; } # Proxy API requests location /api { proxy_pass http://localhost:5000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } # Serve uploaded files location /uploads { proxy_pass http://localhost:5000; sendfile on; tcp_nopush on; tcp_nodelay on; } }
Enable the site and restart Nginx:
sudo ln -s /etc/nginx/sites-available/alkarma-tv /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl restart nginx
-
Start the server with PM2
pm2 start ecosystem.production.config.js --env production
-
Setup PM2 to start on boot
pm2 startup pm2 save
-
Setup automatic database backup (optional but recommended) Create a backup script:
mkdir -p /path/to/AlKarma-TV/backups nano /path/to/AlKarma-TV/backup.sh
Add the following content:
#!/bin/bash DATE=$(date +%Y%m%d_%H%M%S) cp /path/to/AlKarma-TV/server/database.sqlite /path/to/AlKarma-TV/backups/database_$DATE.sqlite # Keep only the 10 most recent backups ls -tp /path/to/AlKarma-TV/backups/ | grep -v '/$' | tail -n +11 | xargs -I {} rm -- /path/to/AlKarma-TV/backups/{}
Make the script executable:
chmod +x /path/to/AlKarma-TV/backup.sh
Add it to crontab to run daily:
(crontab -l 2>/dev/null; echo "0 0 * * * /path/to/AlKarma-TV/backup.sh") | crontab -
-
View logs:
pm2 logs alkarma-tv-server
-
Restart the application:
pm2 restart alkarma-tv-server
-
Monitor the application:
pm2 monit
-
Update the application:
cd /path/to/AlKarma-TV git pull cd client npm install npm run build cd ../server npm install --production pm2 restart alkarma-tv-server
- URL:
/api/client/check-device - Method:
POST - Body:
{ "duid": "DEVICE_UNIQUE_ID" } - Response:
- If device is active: Returns device info, allowed channels, and news
- If device is expired: Returns device info, FTA/Local channels, and news
- If device is disabled: Returns device info and a message
- If device is not found: Returns error message
- URL:
/api/client/register-device - Method:
POST - Body:
{ "device_name": "Device Owner Name" } - Response:
- Returns the newly created device info with DUID and activation code
- URL:
/api/client/activate-device - Method:
POST - Body:
{ "duid": "DEVICE_UNIQUE_ID", "activation_code": "1234" } - Response:
- If successful: Returns device info with active status
- If invalid code: Returns error message
The admin panel APIs include CRUD operations for devices, channels, and news. These are accessible through the admin panel interface.
This project is proprietary and confidential. Unauthorized copying, modification, distribution, or use of this software is strictly prohibited.
For support and inquiries, please contact the project maintainer.