Skip to content

yashranaway/vmrentals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

44 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RenVM - Virtual Machine Rental System

A decentralized platform that enables users to rent virtual machines from other users globally, powered by Stellar blockchain payments and ZeroTier networking.

🎯 Overview

RenVM provides a secure, global marketplace for renting compute resources. Hosts can monetize their hardware, and renters can access VMs anywhere in the world through a simple CLI interface.

πŸ—οΈ Architecture

graph TB
    subgraph "Host Machine"
        A[setup-renvm.sh] --> B[Docker Container]
        A --> C[ZeroTier Network]
        A --> D[monitor-containers.sh]
        D --> E[Activity Logs API]
    end
    
    subgraph "Backend Services"
        F[Express API] --> G[NeonDB Database]
        F --> H[JWT Auth]
        F --> I[Payment Processing]
    end
    
    subgraph "User Interface"
        J[CLI Application] --> K[VM Selection]
        J --> L[Payment Flow]
        K --> F
        L --> M[Freighter Wallet]
    end
    
    B --> N[ZeroTier IP]
    N --> O[Global SSH Access]
    
    M --> P[Stellar Blockchain]
    P --> Q[Transaction Verification]
Loading

πŸ“‹ System Components

1. Host Setup (setup-renvm.sh)

Automated script that prepares a host machine for renting out VMs:

  • Detects system specs (CPU, RAM, GPU, OS)
  • Installs Docker if needed
  • Installs and configures ZeroTier
  • Builds and starts VM containers
  • Registers host with backend API
  • Sets up automatic monitoring

Usage:

./setup-renvm.sh

2. Monitoring System (monitor-containers.sh)

Continuous monitoring that tracks container status and logs activity:

  • Runs every 15 minutes
  • Updates database with container status
  • Logs uptime and activity events
  • Handles graceful shutdowns
  • Automatic database updates

Usage:

# One-time check
./monitor-containers.sh --check

# Continuous monitoring
./monitor-containers.sh --watch

3. Backend API (backend/)

RESTful API built with Node.js and Express:

  • Authentication: JWT-based user authentication
  • VM Management: CRUD operations for virtual machines
  • Payment Processing: Stellar blockchain integration
  • Activity Logging: Track container uptime and status changes
  • Database: PostgreSQL (NeonDB) for persistent storage

API Endpoints:

GET    /api/vms              # List all available VMs
GET    /api/vms/:id          # Get VM details
PUT    /api/vms/:id/status   # Update VM status (monitoring)
GET    /api/vms/:id/logs     # Get activity logs
POST   /api/vms/:id/rent     # Rent a VM
POST   /api/auth/register    # Register new user
POST   /api/auth/login       # User login

4. CLI Application (cli/)

Rust-based command-line interface for renters:

  • Browse available VMs
  • Select and rent VMs
  • Process Stellar payments
  • Receive SSH credentials
  • Clean, intuitive interface

Features:

  • Sorted VM listings by ID
  • Prices in USD and XLM
  • Payment verification on Stellar testnet
  • One-command SSH access

Usage:

./cli.sh

5. Payment System (payments/)

Stellar blockchain payment integration:

  • Freighter wallet extension support
  • Real-time payment verification
  • XLM/USD conversion tracking
  • Secure payment processing

6. Frontend (frontend/)

React-based web interface:

  • Landing page with features
  • Pricing information
  • User and host dashboards
  • Modern, responsive design

πŸš€ Quick Start

For Hosts

  1. Clone the repository:

    git clone https://github.com/yourusername/vmrentals
    cd vmrentals
  2. Run the setup script:

    ./setup-renvm.sh
  3. Enter credentials when prompted:

    • Email
    • Password
  4. That's it! Your machine is now listed and available for rent.

For Renters

  1. Install dependencies (if needed):

    cd cli
    cargo build --release
  2. Run the CLI:

    ./cli.sh
  3. Select a VM and pay:

    • Browse available VMs
    • Choose rental duration
    • Send payment via Freighter
    • Receive SSH credentials

πŸ’° Payment Flow

sequenceDiagram
    participant User
    participant CLI
    participant Freighter
    participant Stellar
    participant Backend
    
    User->>CLI: Select VM
    CLI->>User: Show payment details
    User->>Freighter: Send payment
    Freighter->>Stellar: Execute transaction
    User->>CLI: Type 'done'
    CLI->>Stellar: Verify payment
    Stellar->>CLI: Payment confirmed
    CLI->>User: Display SSH credentials
Loading

πŸ“Š Database Schema

Tables

users

  • Stores host and renter information
  • Tracks system specifications
  • Manages authentication

vms

  • VM hardware specifications
  • Current status and pricing
  • Ownership and rental information

vm_activity_logs

  • Tracks container status changes
  • Records uptime
  • Event logging for monitoring

vm_rentals

  • Rental transactions
  • Duration and costs
  • Active/inactive status

transactions

  • Payment records
  • Stellar transaction IDs
  • Transaction status

πŸ”’ Security Features

  • Container Isolation: Read-only filesystem, non-root user
  • Network Security: ZeroTier VPN for encrypted connections
  • Payment Verification: Blockchain-based payment validation
  • JWT Authentication: Secure API access
  • Activity Monitoring: Real-time status tracking

🌐 ZeroTier Network

  • Network ID: a09acf0233f929f2
  • Global connectivity
  • Encrypted VPN tunnels
  • Automatic IP assignment
  • No port forwarding required

πŸ› οΈ Development

Prerequisites

  • Node.js 18+
  • Rust 1.70+
  • Docker
  • ZeroTier
  • Freighter wallet extension

Backend Setup

cd backend
npm install
cp env.example .env
# Edit .env with your DATABASE_URL
npm start

CLI Development

cd cli
cargo build --release
cargo run

πŸ“ Key Features

  • βœ… Automated Host Setup: Single script to get started
  • βœ… Global Connectivity: ZeroTier for worldwide access
  • βœ… Real-time Monitoring: 15-minute status updates
  • βœ… Blockchain Payments: Stellar network integration
  • βœ… Activity Logging: Complete uptime tracking
  • βœ… Secure Containers: Read-only filesystem, isolated
  • βœ… Clean CLI: Intuitive user interface
  • βœ… Auto-Scaling: Dynamic pricing based on specs

πŸ“ˆ Monitoring

Monitor your containers with built-in tracking:

# View logs
tail -f /tmp/renvm-monitor.log

# Check status (Linux)
systemctl status renvm-monitor

# Manual check
./monitor-containers.sh --check

🀝 Contributing

Contributions welcome! Please read our contributing guidelines first.

πŸ“„ License

MIT License - see LICENSE file for details

πŸ™ Acknowledgments

  • Stellar Network for blockchain infrastructure
  • ZeroTier for global networking
  • Docker for containerization
  • Freighter for wallet integration

Built with ❀️ by the RenVM Team

About

VM Rentals

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •