Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

AlphaNodesDev/AlphaPanel

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

🚀 AlphaPanel

A Self-Hosted VPS Manager Dashboard

Node.js Express.js MySQL License

AlphaPanel is a modern, full-stack Node.js application that provides a comprehensive web-based dashboard for managing AWS EC2 VPS instances. Built with scalability and ease of use in mind, it offers a complete solution for VPS hosting providers and system administrators.


🧩 Project Overview

AlphaPanel is a full-stack Node.js application that allows users to manage AWS EC2 VPS instances from a browser-based dashboard. The platform provides:

  • User Management: Account creation and authentication system
  • Credit-Based Provisioning: Server provisioning using a credit system
  • Instance Control: Start, stop, and reboot EC2 instances with real-time status updates
  • Admin Panel: Comprehensive administrative tools for logs, users, and payment management
  • Theme Support: EJS template-based theming system with TailwindCSS
  • Modular Architecture: Clean, maintainable routing and component structure
  • Payment Integration: Razorpay integration for credit purchases
  • Real-time Updates: Live server status monitoring and updates

🔧 Tech Stack

Backend

  • Node.js + Express.js - Server framework
  • MySQL - Database for users, servers, and payments
  • AWS SDK - EC2 instance management
  • Razorpay - Payment processing for credit purchases

Frontend

  • EJS - Server-side templating
  • TailwindCSS - Utility-first CSS framework
  • Theme System - Customizable UI themes

Deployment & DevOps

  • NGINX - Reverse proxy and load balancing
  • Certbot - SSL certificate management
  • PM2 - Process management (recommended)
  • Gotty - Optional browser-based SSH access

⚙️ Installation

Prerequisites

  • Node.js v16 or higher
  • MySQL 8.0+
  • AWS Account with EC2 access
  • Git

1. Clone the Repository

git clone https://github.com/yourname/AlphaPanel.git
cd AlphaPanel

2. Install Dependencies

npm install

3. Configure the MySQL Database

Create a new MySQL database:

CREATE DATABASE alphapanel;

Run the SQL schema:

mysql -u root -p alphapanel < alphapanel.sql

Configure database credentials in db.js:

module.exports = {
  host: "localhost",
  user: "root",
  password: "yourpassword",
  database: "alphapanel"
};

📦 Setup settings.json

Create a settings.json file in the project root with the following configuration:

{
  "port": 3000,
  "theme": "default",
  "aws": {
    "accessKeyId": "YOUR_AWS_ACCESS_KEY_ID",
    "secretAccessKey": "YOUR_AWS_SECRET_ACCESS_KEY",
    "region": "ap-south-1"
  },
  "plans": {
    "small": {
      "instanceType": "t2.micro",
      "price": 5,
      "storage": 20,
      "ram": "1GB",
      "cpu": "1 vCPU"
    },
    "medium": {
      "instanceType": "t2.small",
      "price": 10,
      "storage": 40,
      "ram": "2GB",
      "cpu": "1 vCPU"
    },
    "large": {
      "instanceType": "t2.medium",
      "price": 20,
      "storage": 80,
      "ram": "4GB",
      "cpu": "2 vCPU"
    }
  },
  "creditPackages": {
    "starter": {
      "credits": 50,
      "price": 5,
      "bonus": 0
    },
    "pro": {
      "credits": 100,
      "price": 9,
      "bonus": 10
    },
    "enterprise": {
      "credits": 250,
      "price": 20,
      "bonus": 50
    }
  },
  "paymentMethods": {
    "razorpay": {
      "key_id": "rzp_test_your_key_id",
      "key_secret": "your_secret_key"
    }
  },
  "security": {
    "sessionSecret": "your-secret-session-key",
    "bcryptRounds": 10
  },
  "features": {
    "autoBackup": true,
    "sshAccess": true,
    "monitoring": true
  }
}

🚀 Start the Application

Development Mode

npm run dev
# or
node app.js

Production Mode (with PM2)

npm install -g pm2
pm2 start app.js --name "alphapanel"
pm2 startup
pm2 save

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


🔐 Admin Access

Create an admin user manually in the database:

INSERT INTO users (username, email, password, type, credits, created_at) 
VALUES ('admin', 'admin@yourdomain.com', '$2b$10$hashedpassword', 1, 1000, NOW());

Or use the built-in admin creation endpoint (development only):

curl -X POST http://localhost:3000/create-admin \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","email":"admin@yourdomain.com","password":"securepassword"}'

Admin Panel Features:

  • Dashboard overview at /admin-panel
  • User management at /admin-users
  • Payment logs at /admin-payments
  • System monitoring at /admin-system
  • Live configuration at /admin-config
  • System logs at /admin-logs

🌐 Production Deployment (Ubuntu VPS)

1. Install and Configure NGINX

sudo apt update && sudo apt install nginx

Create NGINX configuration:

sudo nano /etc/nginx/sites-available/alphapanel

Add the following configuration:

server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;

    # Security headers
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-XSS-Protection "1; mode=block" always;
    add_header X-Content-Type-Options "nosniff" always;

    # Main proxy
    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_cache_bypass $http_upgrade;
        proxy_read_timeout 300s;
        proxy_connect_timeout 75s;
    }

    # Static files
    location /public {
        alias /path/to/AlphaPanel/public;
        expires 1y;
        add_header Cache-Control "public, immutable";
    }
}

Enable the configuration:

sudo ln -s /etc/nginx/sites-available/alphapanel /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx

2. SSL Certificate with Certbot

sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
sudo certbot renew --dry-run

3. Firewall Configuration

sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable

📁 Project Structure

AlphaPanel/
├── 📁 routes/              # Express route modules
│   ├── auth.js            # Authentication routes
│   ├── dashboard.js       # User dashboard
│   ├── admin.js          # Admin panel routes
│   ├── api.js            # API endpoints
│   └── payments.js       # Payment processing
├── 📁 views/              # EJS templates
│   ├── 📁 themes/        # Theme directories
│   │   ├── default/      # Default theme
│   │   └── dark/         # Dark theme
│   ├── 📁 partials/      # Reusable components
│   └── 📁 layouts/       # Layout templates
├── 📁 public/             # Static assets
│   ├── 📁 css/           # Stylesheets
│   ├── 📁 js/            # Client-side JavaScript
│   └── 📁 images/        # Images and icons
├── 📁 core/               # Core system modules
│   ├── logger.js         # Logging system
│   ├── broadcast.js      # Real-time updates
│   ├── aws-manager.js    # AWS EC2 operations
│   └── auth-middleware.js # Authentication middleware
├── 📁 config/             # Configuration files
│   ├── db.js             # Database configuration
│   └── aws.js            # AWS SDK configuration
├── 📁 models/             # Data models
│   ├── User.js           # User model
│   ├── Server.js         # Server model
│   └── Payment.js        # Payment model
├── 📁 utils/              # Utility functions
├── 📄 app.js              # Main application file
├── 📄 settings.json       # Application settings
├── 📄 alphapanel.sql          # Database schema
└── 📄 package.json        # Dependencies and scripts

📊 Admin Panel Features

Feature Endpoint Description
Dashboard /admin-panel System overview and statistics
User Management /admin-users View, edit, and manage user accounts
Payment Logs /admin-payments Transaction history and payment analytics
System Monitor /admin-system Server uptime, performance metrics
Configuration /admin-config Live edit settings.json
System Logs /admin-logs View, filter, and download logs
Server Management /admin-servers Manage all EC2 instances

Admin Capabilities

  • 👥 User Management: Create, suspend, or delete user accounts
  • 💰 Credit Management: Add/remove credits from user accounts
  • 📊 Analytics: View system usage and financial reports
  • ⚙️ System Configuration: Hot-reload application settings
  • 🔧 Maintenance Mode: Enable/disable system-wide maintenance
  • 📋 Audit Logs: Track all administrative actions

📝 Logging System

AlphaPanel includes a comprehensive logging system:

Log Storage

  • Logs are stored in the system_logs MySQL table
  • Automatic log rotation and cleanup
  • Configurable log levels (ERROR, WARN, INFO, DEBUG)

Usage

const { logSystemEvent } = require('./core/logger');

// Log system events
logSystemEvent('INFO', 'Server started successfully');
logSystemEvent('ERROR', 'Database connection failed', { error: err.message });
logSystemEvent('WARN', 'High memory usage detected', { usage: '85%' });

Admin Log Management

  • View Logs: /admin-logs
  • Filter by Level: ERROR, WARN, INFO, DEBUG
  • Search: Text-based log searching
  • Export: Download logs as CSV/JSON
  • Real-time: Live log streaming (WebSocket)

🔧 API Documentation

Authentication

All API endpoints require authentication via session cookies or API tokens.

Core Endpoints

Server Management

GET    /api/servers           # List user servers
POST   /api/servers           # Create new server
GET    /api/servers/:id       # Get server details
POST   /api/servers/:id/start # Start server
POST   /api/servers/:id/stop  # Stop server
POST   /api/servers/:id/reboot # Reboot server
DELETE /api/servers/:id       # Delete server

User Management

GET    /api/user/profile      # Get user profile
PUT    /api/user/profile      # Update profile
GET    /api/user/credits      # Get credit balance
POST   /api/user/credits      # Purchase credits

System Status

GET    /api/status            # System health
GET    /api/plans             # Available server plans
GET    /api/regions           # Available AWS regions

🛡️ Security Features

  • Password Hashing: bcrypt with configurable rounds
  • Session Management: Secure session handling
  • CSRF Protection: Cross-site request forgery prevention
  • Input Validation: Comprehensive input sanitization
  • Rate Limiting: API endpoint protection
  • Security Headers: XSS, CSRF, and clickjacking protection
  • Audit Logging: Complete action tracking
  • 2FA Support: Two-factor authentication (optional)

🎨 Theming System

AlphaPanel supports multiple themes:

Creating a Theme

  1. Create a new directory in views/themes/
  2. Copy the default theme structure
  3. Customize CSS and EJS templates
  4. Update settings.json to use the new theme

Available Themes

  • Default: Clean, professional design
  • Dark: Dark mode theme
  • Minimal: Simplified interface
  • Custom: Your branded theme

🔄 Backup and Restore

Automated Backups

# Database backup
mysqldump -u root -p alphapanel > backup_$(date +%Y%m%d_%H%M%S).sql

# Application backup
tar -czf alphapanel_backup_$(date +%Y%m%d_%H%M%S).tar.gz AlphaPanel/

Restore Process

# Restore database
mysql -u root -p alphapanel < backup_20250710_120000.sql

# Restore application
tar -xzf alphapanel_backup_20250710_120000.tar.gz

📈 Performance Optimization

Recommended Settings

  • Node.js Cluster Mode: Utilize all CPU cores
  • Database Connection Pooling: Optimize MySQL connections
  • Caching: Redis for session and data caching
  • CDN: CloudFlare for static asset delivery
  • Monitoring: Prometheus + Grafana for metrics

PM2 Configuration

// ecosystem.config.js
module.exports = {
  apps: [{
    name: 'alphapanel',
    script: 'app.js',
    instances: 'max',
    exec_mode: 'cluster',
    env: {
      NODE_ENV: 'production',
      PORT: 3000
    },
    error_file: './logs/err.log',
    out_file: './logs/out.log',
    log_file: './logs/combined.log',
    time: true
  }]
};

🧪 Testing

Run Tests

npm test                    # Run all tests
npm run test:unit          # Unit tests only
npm run test:integration   # Integration tests
npm run test:coverage      # Coverage report

Test Structure

tests/
├── unit/              # Unit tests
├── integration/       # Integration tests
├── fixtures/          # Test data
└── helpers/           # Test utilities

🤝 Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Development Setup

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and test thoroughly
  4. Commit your changes: git commit -m 'Add amazing feature'
  5. Push to the branch: git push origin feature/amazing-feature
  6. Submit a Pull Request

Code Standards

  • Follow ESLint configuration
  • Write tests for new features
  • Update documentation
  • Use convent

📞 Support & Community


📋 Changelog

See CHANGELOG.md for a detailed history of changes.


📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


👨‍💻 Author

AlphaPanel © 2025 — Developed with ❤️ by CRI

Acknowledgments

  • AWS SDK team for excellent documentation
  • Express.js community for the robust framework
  • All contributors who help improve AlphaPanel

⭐ Star this repository if it helped you! ⭐

Report BugRequest FeatureContribute

Releases

No releases published

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.