# URVault Server - Windows Installation Guide

## System Requirements

- Windows 10/11 or Windows Server 2016+
- 4GB RAM minimum (8GB recommended)
- 50GB free disk space minimum
- Node.js 18+ (will be installed if not present)
- MySQL 8.0+ (will be installed if not present)

## Quick Installation

### Option 1: Automated Installation (Recommended)

1. **Download** the `urvault-windows-installer.zip` package
2. **Extract** to a folder (e.g., `C:\URVault`)
3. **Right-click** `install.bat` and select "Run as Administrator"
4. **Follow** the on-screen prompts
5. **Open** your browser to `http://localhost:3000` to complete setup

### Option 2: Manual Installation

1. Install Node.js 18+ from https://nodejs.org
2. Install MySQL 8.0+ from https://dev.mysql.com/downloads/mysql/
3. Extract URVault package
4. Run `setup-database.bat` as Administrator
5. Run `install-service.bat` as Administrator
6. Open browser to `http://localhost:3000`

## Installation Steps (Detailed)

### Step 1: Prerequisites

The installer will check for and install:
- Node.js 18.x LTS
- MySQL 8.0
- Required system dependencies

### Step 2: Database Setup

The installer will:
- Create MySQL database `urvault`
- Create database user with secure password
- Run database migrations
- Initialize storage directories

### Step 3: Service Installation

The installer will:
- Install URVault as a Windows Service
- Configure auto-start on boot
- Set up logging to `C:\ProgramData\URVault\logs`
- Configure firewall rules (port 3000)

### Step 4: First-Time Setup

1. Open browser to `http://localhost:3000`
2. Complete the setup wizard:
   - Create admin account
   - Configure storage limits
   - Verify database connection
3. Start using URVault!

## Service Management

### Start Service
```cmd
net start URVaultServer
```

### Stop Service
```cmd
net stop URVaultServer
```

### Restart Service
```cmd
net stop URVaultServer && net start URVaultServer
```

### Check Service Status
```cmd
sc query URVaultServer
```

## Configuration Files

- **Service Config**: `C:\Program Files\URVault\config\`
- **Database Config**: `C:\Program Files\URVault\.env`
- **Storage**: `C:\ProgramData\URVault\backups\`
- **Logs**: `C:\ProgramData\URVault\logs\`

## Troubleshooting

### Service Won't Start

1. Check logs: `C:\ProgramData\URVault\logs\error.log`
2. Verify MySQL is running: `sc query MySQL80`
3. Check firewall: `netsh advfirewall firewall show rule name="URVault"`
4. Restart service: `net stop URVaultServer && net start URVaultServer`

### Can't Access Web Interface

1. Check service status: `sc query URVaultServer`
2. Verify port 3000 is not in use: `netstat -ano | findstr :3000`
3. Check firewall rules
4. Try accessing via `http://127.0.0.1:3000`

### Database Connection Failed

1. Verify MySQL is running: `sc query MySQL80`
2. Check credentials in `.env` file
3. Test connection: `mysql -u urvault -p urvault`
4. Re-run database setup: `setup-database.bat`

## Uninstallation

1. Run `uninstall.bat` as Administrator
2. Optionally delete data: `C:\ProgramData\URVault`
3. Optionally remove MySQL database: `DROP DATABASE urvault;`

## Firewall Configuration

The installer automatically configures Windows Firewall to allow:
- Inbound TCP port 3000 (Web Interface)
- Inbound TCP port 3306 (MySQL - local only)

For external access, you may need to:
1. Configure router port forwarding
2. Set up static IP or DDNS
3. Consider using HTTPS with SSL certificate

## Security Recommendations

1. **Change default MySQL password** after installation
2. **Use strong admin password** during setup wizard
3. **Enable Windows Firewall** and restrict access
4. **Keep system updated** with Windows Update
5. **Regular backups** of URVault data directory
6. **Monitor logs** for suspicious activity

## Support

For issues or questions:
- Check logs: `C:\ProgramData\URVault\logs\`
- Review documentation: `C:\Program Files\URVault\docs\`
- GitHub Issues: https://github.com/yourorg/urvault/issues
