# LocalLendables v0.89 Shared Hosting Deployment Guide

## Overview
Step-by-step guide for deploying LocalLendables v0.89 on shared hosting providers (cPanel, Plesk, etc.).

## Shared Hosting Compatibility
✅ **Pre-compiled JavaScript** - No TypeScript compilation required
✅ **Standard Node.js** - Works with basic Node.js 18+ hosting
✅ **PostgreSQL Support** - Compatible with shared PostgreSQL databases
✅ **File Upload Support** - Standard file upload capabilities
✅ **Memory Optimized** - Reduced memory footprint for shared environments

## cPanel Deployment Steps

### 1. Upload Files
1. Download and extract `js-deployment-v089.zip`
2. Upload all contents to your domain's public_html folder via File Manager
3. Ensure folder structure matches:
   ```
   public_html/
   ├── server/
   ├── templates/
   ├── public/
   ├── shared/
   ├── package.json
   ├── app.js
   └── .env
   ```

### 2. Database Setup
1. Create PostgreSQL database in cPanel
2. Note: database name, username, password, host
3. Import `locallendables_v089_database.sql` via phpPgAdmin or command line
4. Verify 14 demo users and 50+ items imported successfully

### 3. Environment Configuration
Create `.env` file with your database details:
```env
DATABASE_URL=postgresql://username:password@localhost:5432/database_name
SESSION_SECRET=your_unique_session_secret_32_chars
PORT=5000
NODE_ENV=production
MAX_FILE_SIZE=5242880
MEMORY_LIMIT=256MB
```

### 4. Node.js App Setup
1. In cPanel Node.js Selector:
   - **Node.js Version**: 18.x or 20.x
   - **Application Root**: public_html
   - **Application Startup File**: app.js
   - **Application URL**: your-domain.com

2. Install dependencies:
   ```bash
   npm install
   ```

3. Start application in cPanel interface

### 5. Verification
1. Visit your domain
2. Should see LocalLendables demo homepage
3. Test login with demo users (click any avatar)
4. Verify all features work: browsing, messaging, loan requests

## Alternative Hosting Providers

### Plesk Hosting
1. Use "Node.js" extension
2. Upload files to `httpdocs/`
3. Configure database connection
4. Set startup file to `app.js`

### VPS/Cloud Hosting
1. Use standard Linux deployment steps
2. Install Node.js 18+ and PostgreSQL
3. Upload files and configure as above
4. Use PM2 for process management

## Memory Optimization Features
- **Reduced Dependencies**: Minimal package set for shared hosting
- **Efficient Caching**: Smart static asset caching
- **Memory Limits**: Configured for 256MB environments
- **Connection Pooling**: Optimized database connections

## File Structure Verification
After upload, verify these key files exist:
- ✅ `app.js` (main application file)
- ✅ `package.json` (dependencies)
- ✅ `server/storage.js` (database functions)
- ✅ `templates/` (HTML templates)
- ✅ `public/` (static assets)
- ✅ `locallendables_v089_database.sql` (database dump)

## Common Shared Hosting Issues
1. **Node.js Version**: Ensure 18+ is selected
2. **Database Host**: May be different from 'localhost'
3. **File Permissions**: Set executable permissions on app.js
4. **Memory Limits**: Contact host if 256MB isn't sufficient
5. **Port Configuration**: Some hosts require specific ports

## Performance Optimization
- All static assets cached appropriately
- Database connections pooled efficiently
- File uploads optimized for shared storage
- Memory usage monitored and limited

## Support
- Check hosting provider's Node.js documentation
- Verify PostgreSQL version compatibility
- Monitor error logs in cPanel Error Logs section