Skip to content

Latest commit

 

History

History
309 lines (221 loc) · 6.14 KB

File metadata and controls

309 lines (221 loc) · 6.14 KB

SMM Panel Setup Guide

This guide will help you set up and run the complete SMM Panel application.

Prerequisites

Before you begin, make sure you have the following installed:

  • Node.js (v18 or higher)
  • PostgreSQL (v12 or higher)
  • Redis (v6 or higher)
  • npm or yarn
  • Git

Quick Start

1. Environment Setup

First, clone and set up the backend:

cd smm-panel

# Install backend dependencies
npm install

# Set up environment variables
cp .env.example .env

Edit the .env file with your configuration:

NODE_ENV=development
PORT=5000

# Database
DATABASE_URL="postgresql://username:password@localhost:5432/smm_panel?schema=public"

# JWT
JWT_SECRET=your_super_secret_jwt_key_change_this_in_production
JWT_EXPIRE=30d

# Redis
REDIS_HOST=localhost
REDIS_PORT=6379

# Stripe (optional for payments)
STRIPE_SECRET_KEY=your_stripe_secret_key
STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret

# Admin credentials
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=changethisinproduction123

API_RATE_LIMIT=100

2. Database Setup

# Generate Prisma client
npm run prisma:generate

# Run database migrations
npm run prisma:migrate

# Seed the database with sample data
npm run prisma:seed

3. Start Backend Server

# Development mode
npm run dev

# Production mode
npm run build
npm start

The backend will be available at http://localhost:5000

4. Frontend Setup

In a new terminal, set up the frontend:

cd frontend

# Install frontend dependencies
npm install

# Start development server
npm run dev

The frontend will be available at http://localhost:3000

Default Credentials

After running the seed script, you can use these credentials:

Admin Account:

  • Email: admin@smmpanel.com
  • Password: admin123

Test User Account:

  • Email: user@test.com
  • Password: admin123

API Endpoints

The backend provides the following main endpoints:

Authentication

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login
  • POST /api/auth/forgot-password - Password reset request

Services

  • GET /api/services - List all services
  • GET /api/services/:id - Get service details
  • POST /api/services - Create service (Admin only)

Orders

  • GET /api/orders - Get user orders
  • POST /api/orders - Place new order
  • GET /api/orders/:id - Get order details

Admin

  • GET /api/admin/dashboard - Admin dashboard stats
  • GET /api/admin/users - List users
  • GET /api/admin/orders - List all orders

Payments

  • POST /api/payments/stripe/create-payment-intent - Create payment

Database Schema

The application uses PostgreSQL with the following main tables:

  • users - User accounts and authentication
  • services - SMM services with pricing
  • orders - User orders and status
  • transactions - Payment and balance history
  • api_providers - External service providers

Features

User Features

✅ User registration and authentication ✅ Service browsing and filtering ✅ Order placement and tracking ✅ Balance management ✅ Payment integration (Stripe ready) ✅ Order refill requests

Admin Features

✅ User management ✅ Service management ✅ Order monitoring ✅ Balance adjustments ✅ Dashboard analytics

Technical Features

✅ JWT authentication ✅ Role-based access control ✅ Rate limiting ✅ Input validation ✅ Error handling ✅ Responsive design ✅ TypeScript support

Configuration

Backend Configuration

Key configuration files:

  • .env - Environment variables
  • prisma/schema.prisma - Database schema
  • src/app.ts - Main application file

Frontend Configuration

Key configuration files:

  • .env.local - Frontend environment variables
  • tailwind.config.js - Tailwind CSS configuration
  • next.config.ts - Next.js configuration

Development

Adding New Services

  1. Use the admin panel to add services through the UI
  2. Or use the API directly:
curl -X POST http://localhost:5000/api/services \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
  -d '{
    "name": "Instagram Followers",
    "category": "Followers",
    "platform": "INSTAGRAM",
    "price": 2.5,
    "minQuantity": 100,
    "maxQuantity": 10000
  }'

Database Management

# View data in Prisma Studio
npm run prisma:studio

# Reset database (careful!)
npx prisma migrate reset

# Generate new migration
npx prisma migrate dev --name your_migration_name

Testing

# Test API endpoints
curl http://localhost:5000/health

# Test authentication
curl -X POST http://localhost:5000/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"emailOrUsername": "admin@smmpanel.com", "password": "admin123"}'

Production Deployment

Environment Variables

Make sure to set these in production:

NODE_ENV=production
DATABASE_URL="postgresql://prod_user:prod_pass@localhost:5432/smm_panel_prod"
JWT_SECRET="your_production_jwt_secret_very_long_and_secure"
REDIS_HOST="your_redis_host"
STRIPE_SECRET_KEY="sk_live_your_live_stripe_key"

Build Commands

# Backend
npm run build

# Frontend
cd frontend && npm run build

Process Management

Use PM2 or similar for process management:

npm install -g pm2
pm2 start npm --name "smm-backend" -- start

Troubleshooting

Common Issues

Database Connection Error:

  • Check PostgreSQL is running
  • Verify DATABASE_URL is correct
  • Ensure database exists

Redis Connection Error:

  • Check Redis is running
  • Verify REDIS_HOST and REDIS_PORT

Port Already in Use:

  • Change PORT in .env file
  • Kill process using the port

Frontend API Connection:

  • Verify NEXT_PUBLIC_API_URL in frontend/.env.local
  • Check backend is running on correct port

Logs

Backend logs are output to console. In production, consider using a logging service.

Support

For issues and questions:

  1. Check this documentation
  2. Review the code comments
  3. Check the GitHub issues (if applicable)

Security Notes

  • Change default passwords immediately
  • Use strong JWT secrets in production
  • Enable HTTPS in production
  • Regularly update dependencies
  • Monitor for security vulnerabilities