# ๐Ÿš€ Production Deployment Guide ## ๐Ÿ“‹ **Prerequisites** - Salesforce CLI (sf) installed - Python 3.8+ on your server - Access to your Salesforce sandbox ## ๐ŸŽฏ **Step 1: Deploy LWC to Salesforce** ```bash # Make script executable chmod +x deploy-lwc-production.sh # Run deployment ./deploy-lwc-production.sh ``` **Expected Output:** ``` โœ… LWC deployment successful! โœ… Custom objects deployed! โœ… Permission set created! โœ… Lightning App Page created! ``` ## ๐ŸŒ **Step 2: Deploy PDF API to Your Server** ```bash # On your server cd python-pdf-generator # Create virtual environment python3 -m venv venv source venv/bin/activate # Install dependencies pip install -r requirements.txt # Start API server python3 api_server.py ``` **Server will start on:** `http://0.0.0.0:8000` ## ๐Ÿ”ง **Step 3: Configure LWC with Your API URL** Edit `force-app/main/default/lwc/propertyTemplateSelector/propertyTemplateSelector.js`: ```javascript // Change this line pdfApiBaseUrl = 'https://YOUR-ACTUAL-IP:8000/api'; ``` **Replace `YOUR-ACTUAL-IP` with your server's IP address.** ## ๐Ÿ”’ **Step 4: Security Configuration** ### **Firewall Setup:** ```bash # Open port 8000 sudo ufw allow 8000 ``` ### **CORS Configuration (if needed):** Edit `python-pdf-generator/api_server.py`: ```python app.add_middleware( CORSMiddleware, allow_origins=[ "https://tso3--r1.sandbox.lightning.force.com", "https://your-salesforce-domain.com" ], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) ``` ## ๐Ÿงช **Step 5: Test Your Deployment** 1. **Open Salesforce Sandbox:** `https://tso3--r1.sandbox.lightning.force.com` 2. **Login:** `contact+tso3@propertycrm.ae.r1` / `Demo@123` 3. **Search for:** "Property Brochure Generator" 4. **Test the flow:** Template โ†’ Property โ†’ Preview โ†’ Download ## ๐Ÿ“Š **Expected Results** - โœ… LWC loads in Salesforce - โœ… Properties load from your data - โœ… PDF preview generates - โœ… PDF downloads successfully - โœ… All 23+ properties accessible ## ๐Ÿšจ **Troubleshooting** ### **LWC Not Loading:** - Check deployment logs - Verify permission sets - Check user access ### **API Connection Failed:** - Verify IP address in LWC - Check firewall settings - Ensure API server is running ### **No Properties Found:** - Verify `pcrm__Property__c` object exists - Check field permissions - Verify data in sandbox ## ๐Ÿ“ž **Support** For deployment issues: 1. Check Salesforce CLI logs 2. Verify API server status 3. Check browser console for errors 4. Ensure all prerequisites are met --- **๐ŸŽฏ Your system is now production-ready!**