harshkumar27/data-analysis-agent
0
1 2# π **TDS Project 2 Data Analyst β Railway Deployment Guide**3 4Easily deploy your **AI-powered Data Analyst Agent** to **Railway** in minutes.5Follow these steps and your app will be live with a public URL.6 7---8 9## β
**Whatβs Already Set Up**10 11The repo includes all necessary Railway config files:12 13| File | Purpose |14| --------------- | --------------------------------------------- |15| `.env` | Stores environment variables (e.g., API keys) |16| `Dockerfile` | Defines container build |17| `railway.json` | Railway deployment configuration |18| `Procfile` | Tells Railway how to start the app |19| `runtime.txt` | Python version specification |20| `.dockerignore` | Files to ignore during Docker build |21 22---23 24## π **1. Configure Environment Variables**25 26Create a `.env` file in your project root and add your details:27 28```env29# Google Gemini API Keys (Add 1β10 keys for load balancing if you don't have multiple key just paste your one key in all variable)30gemini_api_1=your_api_key_here31gemini_api_2=your_api_key_here32gemini_api_3=your_api_key_here33gemini_api_4=your_api_key_here34gemini_api_5=your_api_key_here35gemini_api_6=your_api_key_here36gemini_api_7=your_api_key_here37gemini_api_8=your_api_key_here38gemini_api_9=your_api_key_here39gemini_api_10=your_api_key_here40LLM_TIMEOUT_SECONDS=24041 42```43> β **if you don't have multiple gemini key just copy one key in all. but my recommendation is used atleast two different key for fallback mechanism to work properly44---45> β **Never commit your `.env` file** to GitHub. Add it to `.gitignore`.46 47---48 49## π€ **2. Push Code to GitHub**50 51```bash52cd /path/to/project53git init54git add .55git commit -m "Initial commit with Railway deployment config"56git remote add origin https://github.com/your-username/your-repo.git57git push -u origin main58```59 60---61 62## π **3. Deploy to Railway**63 64### **Option A β Dashboard**65 661. Visit [railway.app](https://railway.app)672. Sign in with GitHub683. **New Project β Deploy from GitHub**694. Select your repo705. Railway will auto-deploy71 72### **Option B β CLI**73 74```bash75npm install -g @railway/cli76railway login77railway init78railway link79railway up80```81 82---83 84## π **4. Add Environment Variables in Railway**85 861. Go to your Railway project872. Click **Variables**883. Add your Gemini keys & settings exactly as in `.env`89 90---91 92## π§ͺ **5. Test Locally**93 94```bash95source venv/bin/activate # Windows: venv\Scripts\activate96uvicorn app:app --host 0.0.0.0 --port 800097```98 99Visit: **[http://localhost:8000](http://localhost:8000)**100 101---102 103## π³ **6. (Optional) Test with Docker**104 105```bash106docker build -t tds-data-analyst .107docker run -p 8000:8000 --env-file .env tds-data-analyst108```109 110---111 112## β **Environment Variable Reference**113 114| Variable | Description | Default | Required |115| ------------------------------ | ---------------------- | ---------------- | -------------- |116| `gemini_api_1`......`gemini_api_10` | Google Gemini API keys | β | β
(at least 1 but make copy of it in all variable) |117| `LLM_TIMEOUT_SECONDS` | LLM Max Time for task | 240 | β |118| `PORT` | App port | 8000 | β |119 120---121 122## π **Troubleshooting**123 124**Common Issues**125 126* `Module not found` β Check `requirements.txt`127* Port conflict β Use Railwayβs `PORT` variable in architecture => project=> setting => networking => edit =>select default port (uvicorn)128* API key errors β Ensure keys are correct in Railway Variables129* Build fails β See Railway build logs130 131**View Logs**132 133```bash134railway logs135```136 137---138 139## π **Helpful Links**140 141* π [Railway Docs](https://docs.railway.app)142* π€ [Google AI Docs](https://ai.google.dev)143 144---145 146 