Skip to content

AlphaNodesDev/AlphaPanel

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 Bug β€’ Request Feature β€’ Contribute

Releases

No releases published

Packages

No packages published