# Server Setup and Configuration

Complete guide to installing, configuring, and launching VibesEZ-Laptop on your server.

## Pre-Launch Checklist

Verify all components before going live.

### Database

* [ ] Database created successfully
* [ ] Tables imported correctly from `install/vibesez_crypto.sql`
* [ ] No SQL errors in console
* [ ] Can create test wallets
* [ ] oxmysql running before VibesEZ-Laptop resource

### Server

* [ ] Resource in correct folder structure
* [ ] fxmanifest.lua valid and complete
* [ ] Load order correct in server.cfg (oxmysql first, VibesEZ-Laptop after frameworks)
* [ ] No startup errors
* [ ] Resource shows online status

### Framework Integration

* [ ] QBCore item added (if using QBCore)
* [ ] Laptop item image present
* [ ] Pre-installed apps configured in `config/apps.lua`
* [ ] Item properties correct
* [ ] No conflicts with other resources

### Web UI

* [ ] Laptop UI loads without errors
* [ ] UI responsive and styled correctly
* [ ] All apps display properly
* [ ] No console JavaScript errors
* [ ] Keyboard controls work (ESC to close)

### Crypto Economy

* [ ] Economy mode selected in `config/crypto.lua`
* [ ] Currencies configured
* [ ] Pool seeded (if using Liquidity mode)
* [ ] Test wallets created
* [ ] Test transfers work

### Features

* [ ] Notifications working
* [ ] Settings apply properly
* [ ] Notes save correctly
* [ ] Tasks creating without errors
* [ ] Calculator functioning
* [ ] Transfers processing
* [ ] Transaction history tracking

## Initial Installation

### 1. Database Setup

Import the database schema:

```bash
# For MySQL 5.7+
mysql -u your_user -p your_database < install/vibesez_crypto.sql
```

Verify tables were created:

```sql
SELECT TABLE_NAME FROM information_schema.TABLES 
WHERE TABLE_SCHEMA = 'your_database' 
AND TABLE_NAME LIKE 'crypto%' OR TABLE_NAME LIKE 'app_%';
```

Should show tables for wallets, transactions, app data, and inventory.

### 2. Folder Structure

Place the resource in your `resources/` directory:

```
resources/
├── VibesEZ-Laptop/
│   ├── client/
│   ├── server/
│   ├── web/
│   ├── config/
│   ├── fxmanifest.lua
│   └── ...
```

### 3. Server Configuration

Edit your `server.cfg`:

```lua
# Load dependencies FIRST
ensure oxmysql
ensure qb-core  # or your framework

# Load VibesEZ-Laptop after all dependencies
ensure VibesEZ-Laptop
```

### 4. Resource Configuration

Edit `config/apps.lua`:

```lua
Config = {
    Debug = false,
    Enabled = true,
    CheckVersion = true,
    Locale = 'en'
}

Config.Framework = {
    Type = 'qbcore',        -- 'qbcore', 'esx', or 'custom'
    UseQBInventory = true,
    UseQBNotify = true,
    ItemName = 'laptop'
}

Config.PreinstalledApps = {
    {
        id = 'notes',
        label = 'Notes',
        defaultInstalled = true,
        pinned = true
    },
    {
        id = 'tasks',
        label = 'Tasks',
        defaultInstalled = true,
        pinned = true
    },
    {
        id = 'calculator',
        label = 'Calculator',
        defaultInstalled = true,
        pinned = false
    },
    {
        id = 'crypto',
        label = 'Crypto',
        defaultInstalled = true,
        pinned = true
    },
    {
        id = 'settings',
        label = 'Settings',
        defaultInstalled = true,
        pinned = false
    }
}
```

### 5. Cryptocurrency Configuration

Edit `config/crypto.lua`:

```lua
Config.Crypto = {
    Enabled = true,
    EconomyMode = 'static',  -- Choose: static, controlled, simulated, liquidity
    DefaultCurrency = 'BTC',
    
    Currencies = {
        BTC = {
            name = 'Bitcoin',
            symbol = 'BTC',
            basePrice = 50000,
            maxSupply = 1000000  -- For controlled mode
        },
        ETH = {
            name = 'Ethereum',
            symbol = 'ETH',
            basePrice = 3000,
            maxSupply = 10000000
        },
        SERVER = {
            name = 'Server Coin',
            symbol = 'SERVER',
            basePrice = 100
        }
    }
}

Config.Economy = {
    MinTransfer = 1,
    MaxTransfer = 999999999,
    TransactionFee = 0,           -- 0 for no fee, or percentage like 0.01
    FeeDestination = nil,         -- nil to burn fees, or address to collect
    DailyLimitPerPlayer = nil,    -- nil for unlimited
    MonthlyLimitPerPlayer = nil
}
```

### 6. Optional Dongle Configuration

If using USB dongle system, edit `config/dongle.lua`:

```lua
Config.Dongle = {
    Enabled = false,  -- Set to true to enable dongle mode
    Dongle = {
        itemName = 'laptop_dongle',
        label = 'Laptop Dongle'
    }
}
```

## Core Configuration Reference

### General Settings

```lua
Config.Debug = false              -- Enable debug logging
Config.Enabled = true             -- Enable/disable resource
Config.CheckVersion = true        -- Check for updates
Config.Locale = 'en'             -- Language setting
```

### Performance Settings

```lua
Config.Performance = {
    MaxPlayers = 128,
    CacheDuration = 3600,         -- Cache expiry in seconds
    DatabasePoolSize = 10,
    OptimizeUI = true
}
```

### Feature Flags

```lua
Config.Features = {
    Notes = true,
    Tasks = true,
    Crypto = true,
    Sharing = true,               -- Share notes/tasks with other players
    Notifications = true,
    OfflineTransfers = true,      -- Allow transfers to offline players
    ExternalApps = true
}
```

### Database Configuration

If not using standard oxmysql, configure:

```lua
Config.Database = {
    Driver = 'oxmysql',
    Host = 'localhost',
    Port = 3306,
    Username = 'your_user',
    Password = 'your_password',
    Database = 'your_db',
    PoolSize = 10,
    Timeout = 5000
}
```

### Security Settings

```lua
Config.Security = {
    EncryptSensitive = true,      -- Encrypt wallets/transactions
    DataRetention = 30,           -- Days to keep deleted data
    LogTransactions = true,       -- Log all transfers
    LogAdminActions = true
}
```

### Appearance

```lua
Config.Appearance = {
    DefaultTheme = 'dark',        -- 'dark', 'light', or 'auto'
    DefaultFontSize = 'normal',   -- 'small', 'normal', 'large'
    AllowThemeChange = true,
    AllowFontResize = true
}
```

### Admin Commands

```lua
Config.AdminCommands = {
    Enabled = true,
    Prefix = '/',
    Commands = {
        'addcrypto',
        'removecrypto',
        'resetwallet',
        'checkbalance'
    }
}
```

## Testing

### Creating Test Wallets

From server console:

```lua
exports['VibesEZ-Laptop']:AddCrypto(identifier, 'BTC', 1000, 'Test funds')
```

Or use admin command:

```
/addcrypto [playerid] BTC 1000 "Starting funds"
```

### Verify Each Component

**Notes App:**

* [ ] Create, edit, delete notes
* [ ] Share with another player
* [ ] Archive/unarchive

**Tasks App:**

* [ ] Create task
* [ ] Mark complete
* [ ] Set recurring task
* [ ] Set reminder

**Calculator:**

* [ ] Basic operations work
* [ ] Scientific mode available

**Settings:**

* [ ] Theme changes apply
* [ ] Font sizes adjust
* [ ] Notifications toggle

**Crypto Wallet:**

* [ ] All currencies display
* [ ] Balances correct
* [ ] Can view transaction history
* [ ] Test 2-player transfer
* [ ] Transaction appears in history

### Performance Testing

With multiple players connected:

1. Spawn 10+ test players
2. Each opens laptop simultaneously
3. Each performs actions (notes, tasks, transfers)
4. Monitor server FPS (should remain above 29)
5. Check for memory leaks
6. Verify database remains responsive

**Target Metrics:**

* Server FPS: No drop below 29
* Client FPS: No drop below 50
* Database query time: Under 100ms
* Transfer processing: Under 1 second
* App launch: Under 2 seconds

## Pre-Launch Communication

### Prepare Player Documentation

Create:

* Player guide pointing to the documentation
* FAQ specific to your server
* Explanation of your economy mode
* Support contact information
* Rules about cryptocurrency transfers
* Ban policy for exploits

### Announce to Players

Before launch announce:

* New feature availability
* Where to find documentation
* How to use the basic features
* Support contact information
* Expected behavior and limitations

## Backup and Recovery

### Create Initial Backup

Backup before launch:

```bash
# Database backup
mysqldump -u your_user -p your_database > backup_pre_launch.sql

# Config backup
cp -r config/ backup_config/

# Full resource backup
cp -r ./ ../VibesEZ-Laptop_backup/
```

### Backup Strategy

**Daily backups:**

* Automatic database dumps
* Config file copies
* Before major changes

**Weekly backups:**

* Secure offsite storage

**Monthly backups:**

* Archive for long-term retention

### Recovery Procedure

If database corrupted:

```bash
mysql -u your_user -p your_database < backup_pre_launch.sql
```

## Monitoring and Health

### Daily Health Checks

* [ ] Resource online and responding?
* [ ] Database accessible and performant?
* [ ] No critical errors in console?
* [ ] Normal player activity level?
* [ ] Transfers processing successfully?

### Weekly Health Checks

* [ ] Performance degradation present?
* [ ] Database size growing normally?
* [ ] Any player reports of issues?
* [ ] Backup timestamps current?
* [ ] Log files under control?

### Performance Metrics to Monitor

* Number of concurrent active players
* Database query times
* Transfer success/failure rate
* Resource restart frequency
* Error rate and types
* Player activity levels

## Troubleshooting Initial Setup

### Resource Won't Start

**Check:**

1. oxmysql running first
2. Dependencies loaded before VibesEZ-Laptop
3. No typos in fxmanifest.lua
4. All required files present
5. Console for specific error messages

**Solution:** Restart resource, check server console for errors.

### Can't Connect to Database

**Check:**

1. Database exists
2. Tables imported successfully
3. Credentials correct in config
4. oxmysql configured correctly
5. Database user has required permissions

**Solution:** Verify database setup, test connection manually.

### UI Won't Load

**Check:**

1. Web files present and accessible
2. NUI enabled on server
3. No JavaScript errors in console
4. CORS properly configured
5. No port conflicts

**Solution:** Check browser console (F8 in game), restart resource.

### Transfers Not Working

**Check:**

1. Crypto enabled in config
2. Test wallets created
3. Database accepting queries
4. Economy mode configured
5. Sufficient test funds

**Solution:** Verify crypto configuration, test with admin commands.

## Optimization Tips

* Set `CacheDuration` appropriately for your server (3600 seconds = 1 hour)
* Disable unused features in Config.Features
* Regularly archive old transaction history
* Monitor database size and optimize queries
* Use `OptimizeUI = true` for servers with 100+ players
* Adjust `DatabasePoolSize` based on max players

## Moving to Production

Before going live:

1. All checklist items complete
2. All features tested thoroughly
3. Comprehensive documentation ready
4. Backup procedures established
5. Admin team trained
6. Monitoring set up
7. Player communication plan executed
8. Rollback procedures documented


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://vibesez.gitbook.io/vibesez/docs/laptop/for-administrators/setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
