|
| 1 | +# Deployment Guide |
| 2 | + |
| 3 | +This guide explains how to deploy the **Stellar Goal Vault** project: |
| 4 | + |
| 5 | +- **Backend → Render** |
| 6 | +- **Frontend → Vercel** |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## Backend Deployment (Render) |
| 11 | + |
| 12 | +### 1. Create a Render Web Service |
| 13 | +- Go to https://render.com |
| 14 | +- Click **New → Web Service** |
| 15 | +- Connect your GitHub repository |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +### 2. Configure the Service |
| 20 | + |
| 21 | +- **Root Directory:** `backend` *(update if your backend folder name differs)* |
| 22 | + |
| 23 | +- **Build Command:** |
| 24 | +```bash |
| 25 | +npm install && npm run build |
| 26 | +``` |
| 27 | +Start Command: |
| 28 | +```bash |
| 29 | +npm start |
| 30 | +``` |
| 31 | +### 3. Environment Variables |
| 32 | + |
| 33 | +Add the following variables in Render: |
| 34 | +```env |
| 35 | +PORT=3000 |
| 36 | +ALLOWED_ASSETS=USDC,XLM,ARS |
| 37 | +SOROBAN_RPC_URL=https://soroban-testnet.stellar.org:443 |
| 38 | +CONTRACT_ID=your_contract_id |
| 39 | +``` |
| 40 | +### 4. Database Notes |
| 41 | + |
| 42 | +This project uses SQLite (`better-sqlite3`), which is file-based. |
| 43 | + |
| 44 | +- SQLite does NOT persist reliably on Render |
| 45 | +- Data may reset on redeploy |
| 46 | + |
| 47 | +Recommended: |
| 48 | +Use a hosted database for production: |
| 49 | + |
| 50 | +- PostgreSQL (Neon, Supabase) |
| 51 | +- MongoDB Atlas |
| 52 | + |
| 53 | +### 5. Deployment Tips |
| 54 | +- Ensure your Soroban contract is deployed before running backend |
| 55 | +- Keep your `CONTRACT_ID` secure |
| 56 | +- Confirm API is accessible after deployment |
| 57 | + |
| 58 | + |
| 59 | +## Frontend Deployment (Vercel) |
| 60 | + |
| 61 | +### 1. Import Project |
| 62 | +- Go to https://vercel.com |
| 63 | +- Click Add New Project |
| 64 | +- Import your GitHub repository |
| 65 | + |
| 66 | +### 2. Configure Project |
| 67 | +- Root Directory: `frontend` (update if different) |
| 68 | + |
| 69 | +Build Command: |
| 70 | +```bash |
| 71 | +npm run build |
| 72 | +``` |
| 73 | +Output Directory: |
| 74 | +```bash |
| 75 | +dist |
| 76 | +``` |
| 77 | + |
| 78 | +### 3. Environment Variables |
| 79 | +Add: |
| 80 | +```env |
| 81 | +VITE_API_URL=https://your-backend-url.onrender.com |
| 82 | +``` |
| 83 | + |
| 84 | +### 4. Deploy |
| 85 | + |
| 86 | +Click Deploy and wait for build to complete. |
| 87 | + |
| 88 | +## Connecting Frontend to Backend |
| 89 | +- Deploy backend first |
| 90 | +- Copy backend URL from Render |
| 91 | +- Set it as `VITE_API_URL` in Vercel |
| 92 | +- Redeploy frontend if needed |
| 93 | + |
| 94 | + |
| 95 | +## Troubleshooting |
| 96 | +Backend not responding |
| 97 | +- Check logs in Render dashboard |
| 98 | +- Confirm environment variables are set correctly |
| 99 | + |
| 100 | +Frontend not calling API |
| 101 | +- Verify `VITE_API_URL` is correct |
| 102 | +- Ensure backend allows CORS requests |
| 103 | + |
| 104 | +Data not persisting |
| 105 | +- This is due to SQLite |
| 106 | +- Switch to a hosted database for production |
| 107 | + |
| 108 | +## Summary |
| 109 | +- Backend runs on Render using Node.js + Express |
| 110 | +- Frontend runs on Vercel using Vite + React |
| 111 | +- Environment variables must be configured correctly |
| 112 | +- SQLite is suitable for development but not production |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | + |
0 commit comments