|
| 1 | +# 🚀 Portfolio Tracker Deployment Guide |
| 2 | + |
| 3 | +This guide will help you deploy your Portfolio Tracker application to production. |
| 4 | + |
| 5 | +## 📋 Prerequisites |
| 6 | + |
| 7 | +1. **Supabase Account** - [Sign up here](https://supabase.com) |
| 8 | +2. **Finnhub API Key** - [Get free API key here](https://finnhub.io/register) |
| 9 | +3. **GitHub Account** - Your code is already there |
| 10 | +4. **Render Account** - [Sign up here](https://render.com) (for backend) |
| 11 | +5. **Vercel Account** - [Sign up here](https://vercel.com) (for frontend) |
| 12 | + |
| 13 | +## 🎯 Deployment Strategy |
| 14 | + |
| 15 | +- **Frontend (React/Vite)** → **Vercel** |
| 16 | +- **Backend (Express.js)** → **Render** |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +## 🔧 Step 1: Backend Deployment (Render) |
| 21 | + |
| 22 | +### 1.1 Create Supabase Project |
| 23 | + |
| 24 | +1. Go to [supabase.com](https://supabase.com) and sign in |
| 25 | +2. Click "New Project" |
| 26 | +3. Choose your organization |
| 27 | +4. Enter project name: `portfolio-tracker` |
| 28 | +5. Enter a database password (save this!) |
| 29 | +6. Choose a region close to your users |
| 30 | +7. Click "Create new project" |
| 31 | + |
| 32 | +### 1.2 Get Supabase Credentials |
| 33 | + |
| 34 | +1. In your Supabase dashboard, go to **Settings > API** |
| 35 | +2. Copy these values: |
| 36 | + - **Project URL**: `https://your-project-id.supabase.co` |
| 37 | + - **anon public key**: `eyJ...` (starts with eyJ) |
| 38 | + - **service_role key**: `eyJ...` (starts with eyJ) |
| 39 | + |
| 40 | +### 1.3 Get Finnhub API Key |
| 41 | + |
| 42 | +1. Go to [finnhub.io/register](https://finnhub.io/register) |
| 43 | +2. Sign up for a free account |
| 44 | +3. Copy your API key from the dashboard |
| 45 | + |
| 46 | +### 1.4 Deploy Backend to Render |
| 47 | + |
| 48 | +1. Go to [render.com](https://render.com) and sign up/login |
| 49 | +2. Click **"New +"** → **"Web Service"** |
| 50 | +3. Connect your GitHub repository: `HackStyx/portfolio-tracker` |
| 51 | +4. Configure the service: |
| 52 | + |
| 53 | + **Basic Settings:** |
| 54 | + - **Name**: `portfolio-tracker-backend` |
| 55 | + - **Environment**: `Node` |
| 56 | + - **Region**: Choose closest to your users |
| 57 | + - **Branch**: `main` |
| 58 | + - **Root Directory**: `backend` |
| 59 | + - **Build Command**: `npm install` |
| 60 | + - **Start Command**: `npm start` |
| 61 | + - **Plan**: Free |
| 62 | + |
| 63 | +5. **Add Environment Variables** (click "Advanced" → "Add Environment Variable"): |
| 64 | + |
| 65 | + ``` |
| 66 | + NODE_ENV=production |
| 67 | + PORT=5000 |
| 68 | + FINNHUB_API_KEY=your_finnhub_api_key_here |
| 69 | + SUPABASE_URL=https://your-project-id.supabase.co |
| 70 | + SUPABASE_KEY=your_supabase_service_role_key_here |
| 71 | + ``` |
| 72 | + |
| 73 | +6. Click **"Create Web Service"** |
| 74 | + |
| 75 | +7. **Wait for deployment** (usually 2-5 minutes) |
| 76 | + |
| 77 | +8. **Copy your backend URL** (e.g., `https://portfolio-tracker-backend-abc123.onrender.com`) |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +## 🌐 Step 2: Frontend Deployment (Vercel) |
| 82 | + |
| 83 | +### 2.1 Deploy Frontend to Vercel |
| 84 | + |
| 85 | +1. Go to [vercel.com](https://vercel.com) and sign up/login |
| 86 | +2. Click **"New Project"** |
| 87 | +3. Import your GitHub repository: `HackStyx/portfolio-tracker` |
| 88 | +4. Configure the project: |
| 89 | + |
| 90 | + **Build Settings:** |
| 91 | + - **Framework Preset**: Vite |
| 92 | + - **Root Directory**: `./` (leave empty) |
| 93 | + - **Build Command**: `npm run build` |
| 94 | + - **Output Directory**: `dist` |
| 95 | + - **Install Command**: `npm install` |
| 96 | + |
| 97 | +5. **Add Environment Variables** (click "Environment Variables"): |
| 98 | + |
| 99 | + ``` |
| 100 | + VITE_SUPABASE_URL=https://your-project-id.supabase.co |
| 101 | + VITE_SUPABASE_ANON_KEY=your_supabase_anon_key_here |
| 102 | + VITE_API_BASE_URL=https://your-render-backend-url.onrender.com/api |
| 103 | + ``` |
| 104 | + |
| 105 | +6. Click **"Deploy"** |
| 106 | + |
| 107 | +7. **Wait for deployment** (usually 1-3 minutes) |
| 108 | + |
| 109 | +8. **Copy your frontend URL** (e.g., `https://portfolio-tracker-abc123.vercel.app`) |
| 110 | + |
| 111 | +--- |
| 112 | + |
| 113 | +## ⚙️ Step 3: Configure Supabase Settings |
| 114 | + |
| 115 | +### 3.1 Update Site URL |
| 116 | + |
| 117 | +1. Go to your Supabase dashboard |
| 118 | +2. Navigate to **Authentication > Settings** |
| 119 | +3. Update **Site URL** to your Vercel frontend URL: |
| 120 | + ``` |
| 121 | + https://your-frontend-url.vercel.app |
| 122 | + ``` |
| 123 | + |
| 124 | +### 3.2 Add Redirect URLs |
| 125 | + |
| 126 | +1. In the same Authentication settings |
| 127 | +2. Add these **Redirect URLs**: |
| 128 | + ``` |
| 129 | + https://your-frontend-url.vercel.app/dashboard |
| 130 | + https://your-frontend-url.vercel.app/ |
| 131 | + http://localhost:5173/dashboard |
| 132 | + http://localhost:5173/ |
| 133 | + ``` |
| 134 | + |
| 135 | +### 3.3 Enable Email Confirmation (Recommended) |
| 136 | + |
| 137 | +1. In Authentication settings |
| 138 | +2. Enable **"Enable email confirmations"** |
| 139 | +3. This ensures users verify their email before accessing the app |
| 140 | + |
| 141 | +--- |
| 142 | + |
| 143 | +## 🧪 Step 4: Test Your Deployment |
| 144 | + |
| 145 | +### 4.1 Test Backend |
| 146 | + |
| 147 | +1. Visit your backend URL: `https://your-backend-url.onrender.com/api/health` |
| 148 | +2. You should see a response indicating the server is running |
| 149 | + |
| 150 | +### 4.2 Test Frontend |
| 151 | + |
| 152 | +1. Visit your frontend URL: `https://your-frontend-url.vercel.app` |
| 153 | +2. Try creating a new account |
| 154 | +3. Test the login functionality |
| 155 | +4. Navigate through the dashboard |
| 156 | + |
| 157 | +### 4.3 Test API Integration |
| 158 | + |
| 159 | +1. Sign in to your app |
| 160 | +2. Try adding stocks to your watchlist |
| 161 | +3. Check if stock data loads correctly |
| 162 | +4. Test the news and calendar features |
| 163 | + |
| 164 | +--- |
| 165 | + |
| 166 | +## 🔍 Troubleshooting |
| 167 | + |
| 168 | +### Common Issues |
| 169 | + |
| 170 | +#### Backend Issues |
| 171 | + |
| 172 | +1. **"Module not found" errors** |
| 173 | + - Check that all dependencies are in `backend/package.json` |
| 174 | + - Verify the build command is correct |
| 175 | + |
| 176 | +2. **"Environment variable not set" errors** |
| 177 | + - Double-check all environment variables in Render dashboard |
| 178 | + - Make sure there are no extra spaces |
| 179 | + |
| 180 | +3. **"Port already in use" errors** |
| 181 | + - Render automatically sets the PORT environment variable |
| 182 | + - Make sure your code uses `process.env.PORT` |
| 183 | + |
| 184 | +#### Frontend Issues |
| 185 | + |
| 186 | +1. **"Invalid API key" errors** |
| 187 | + - Verify your Supabase anon key is correct |
| 188 | + - Check that environment variables are set in Vercel |
| 189 | + |
| 190 | +2. **"CORS errors"** |
| 191 | + - Backend should already be configured for CORS |
| 192 | + - Check that your frontend URL is allowed |
| 193 | + |
| 194 | +3. **"Authentication not working"** |
| 195 | + - Verify Supabase site URL and redirect URLs |
| 196 | + - Check browser console for detailed errors |
| 197 | + |
| 198 | +#### Database Issues |
| 199 | + |
| 200 | +1. **"Table not found" errors** |
| 201 | + - Run the database migrations in Supabase |
| 202 | + - Check the SQL editor in Supabase dashboard |
| 203 | + |
| 204 | +2. **"RLS policy errors"** |
| 205 | + - Verify Row Level Security policies are set up |
| 206 | + - Check the authentication is working properly |
| 207 | + |
| 208 | +--- |
| 209 | + |
| 210 | +## 📊 Monitoring |
| 211 | + |
| 212 | +### Render Monitoring |
| 213 | + |
| 214 | +1. Go to your Render dashboard |
| 215 | +2. Click on your backend service |
| 216 | +3. Monitor logs, performance, and uptime |
| 217 | + |
| 218 | +### Vercel Monitoring |
| 219 | + |
| 220 | +1. Go to your Vercel dashboard |
| 221 | +2. Click on your project |
| 222 | +3. Monitor deployments, performance, and analytics |
| 223 | + |
| 224 | +### Supabase Monitoring |
| 225 | + |
| 226 | +1. Go to your Supabase dashboard |
| 227 | +2. Monitor database usage, API calls, and authentication |
| 228 | + |
| 229 | +--- |
| 230 | + |
| 231 | +## 🔄 Updating Your Deployment |
| 232 | + |
| 233 | +### Backend Updates |
| 234 | + |
| 235 | +1. Push changes to your GitHub repository |
| 236 | +2. Render will automatically redeploy |
| 237 | +3. Monitor the deployment logs |
| 238 | + |
| 239 | +### Frontend Updates |
| 240 | + |
| 241 | +1. Push changes to your GitHub repository |
| 242 | +2. Vercel will automatically redeploy |
| 243 | +3. Monitor the deployment status |
| 244 | + |
| 245 | +--- |
| 246 | + |
| 247 | +## 🎉 Success! |
| 248 | + |
| 249 | +Your Portfolio Tracker is now live! |
| 250 | + |
| 251 | +- **Frontend**: `https://your-frontend-url.vercel.app` |
| 252 | +- **Backend**: `https://your-backend-url.onrender.com` |
| 253 | +- **Database**: Supabase dashboard |
| 254 | + |
| 255 | +### Next Steps |
| 256 | + |
| 257 | +1. **Customize your app** - Update branding, colors, and features |
| 258 | +2. **Add more features** - Implement additional portfolio tracking features |
| 259 | +3. **Monitor performance** - Keep an eye on usage and performance |
| 260 | +4. **Scale up** - Upgrade plans as your user base grows |
| 261 | + |
| 262 | +--- |
| 263 | + |
| 264 | +## 📞 Support |
| 265 | + |
| 266 | +If you encounter issues: |
| 267 | + |
| 268 | +1. Check the troubleshooting section above |
| 269 | +2. Review the deployment logs in Render/Vercel |
| 270 | +3. Check the browser console for frontend errors |
| 271 | +4. Review Supabase logs for backend errors |
| 272 | +5. Check the GitHub repository for updates |
| 273 | + |
| 274 | +**Happy deploying! 🚀** |
0 commit comments