SIH-Crop-Yield-API / docs /DEPLOYMENT_GUIDE.md
AshrafGalibSk's picture
Upload folder using huggingface_hub
bbd5f9c verified
|
Raw
History Blame Contribute Delete
2.53 kB
# πŸš€ Free Cloud Deployment for Hackathon
## Quick Deploy Options (FREE)
### 1. Railway.app (RECOMMENDED) ⭐
**Why Railway**: No credit card, easy GitHub integration, fast deployment
**Steps:**
1. **Push to GitHub:**
```bash
git add .
git commit -m "Ready for deployment"
git push origin feature/api-integration
```
2. **Deploy on Railway:**
- Go to https://railway.app
- Click "Deploy from GitHub repo"
- Select your repository
- Railway auto-detects Dockerfile
- Deploy takes 2-3 minutes
3. **Your friend gets URL:**
```
https://your-project.railway.app/predict
```
### 2. Render.com (Alternative)
**Steps:**
1. Create account at https://render.com
2. Connect GitHub repo
3. Choose "Web Service"
4. Auto-deploys from Dockerfile
**URL format:** `https://your-app.onrender.com/predict`
### 3. Fly.io (For Performance)
**Steps:**
```bash
# Install fly CLI
curl -L https://fly.io/install.sh | sh
# Login and deploy
flyctl launch
flyctl deploy
```
---
## 🎯 INSTANT TESTING (No Deployment Needed)
### Option A: ngrok (Fastest for hackathon demo)
```bash
# Terminal 1: Start API
uvicorn test_api:app --host 0.0.0.0 --port 8002
# Terminal 2: Create tunnel
# Download from: https://ngrok.com/download
./ngrok http 8002
# Share the https URL with your friend!
# Example: https://abc123.ngrok.io/predict
```
### Option B: LocalTunnel
```bash
# Install
npm install -g localtunnel
# Start API
uvicorn test_api:app --host 0.0.0.0 --port 8002
# Create tunnel
lt --port 8002 --subdomain your-crop-api
# URL: https://your-crop-api.loca.lt/predict
```
---
## πŸ“± For Your Friend to Test
**Sample curl command:**
```bash
curl -X POST "https://YOUR-DEPLOYED-URL/predict" \
-H "Content-Type: application/json" \
-d '{
"year": 2024,
"state": "Punjab",
"crop": "Rice",
"season": "Kharif",
"area": 10.0,
"production": 25.0,
"rainfall": 1200,
"fertilizer": 75,
"pesticide": 8
}'
```
**Sample Python code:**
```python
import requests
url = "https://YOUR-DEPLOYED-URL/predict"
data = {
"year": 2024,
"state": "Punjab",
"crop": "Rice",
"season": "Kharif",
"area": 10.0,
"production": 25.0,
"rainfall": 1200,
"fertilizer": 75,
"pesticide": 8
}
response = requests.post(url, json=data)
print(response.json())
```
---
## πŸ† Recommended for Hackathon Demo
**FASTEST OPTION**: Use **ngrok** for immediate sharing
**BEST OPTION**: Deploy to **Railway.app** for permanent URL
Both are completely FREE and perfect for hackathons! πŸŽ‰