Spaces:
Runtime error
Deploy Guide: Render (Backend) + Vercel (Frontend)
A complete, copy-paste guide to launch this project using free tiers.
- Frontend: React + Vite → Vercel (static site)
- Backend: FastAPI + Transformers → Render (free web service)
1) Prerequisites
- GitHub repo: https://github.com/rashid714/updated-translator
- Accounts: Render (free), Vercel (free)
Optional (local dev): Node.js 18+, Python 3.11 or 3.13
2) Local run (optional)
# Python env
python3 -m venv .venv
source .venv/bin/activate
pip install -r server/requirements.txt
# Frontend deps
npm install
# Start both (Vite + FastAPI)
npm run dev:all
# Vite: http://localhost:5174
# API: http://127.0.0.1:8000 (GET /health)
Tip: In Host view, click "Preload Model" once to warm the translator.
3) Backend on Render (Free)
Render builds and hosts the FastAPI app. Free plan sleeps when idle; next request wakes it.
Two choices:
A) Blueprint (recommended)
This repo includes render.yaml and runtime.txt.
- Render → New → Blueprint → Connect repo → choose
updated-translator→ Apply - Wait for deploy. First translation may take longer while weights download.
What it sets:
- Build:
pip install -r server/requirements.txt - Start:
uvicorn server.app:app --host 0.0.0.0 --port $PORT - Health Check:
/health - Python: 3.11.9 (via runtime.txt)
B) Manual Web Service
- New → Web Service → connect repo → Branch
main - Root:
.| Runtime: Python - Build:
pip install -r server/requirements.txt - Start:
uvicorn server.app:app --host 0.0.0.0 --port $PORT - Health Check Path:
/health| Plan: Free
After deploy, test:
curl -sS https://<service>.onrender.com/health
# -> {"status":"ok"}
Notes:
- Cold start: free services sleep when idle; first request wakes them.
- First translation after deploy may download model weights; subsequent calls are fast.
4) Frontend on Vercel (Free)
- New Project → Import GitHub →
updated-translator - Framework: Vite
- Build Command:
npm run build| Output:dist - Environment Variables:
VITE_API_URL = https://<service>.onrender.com
- Deploy. Open your Vercel URL (e.g.,
https://updated-translator.vercel.app).
5) Troubleshooting
Tokenizers/torch build errors on Render
- Keep Python 3.11 (runtime.txt).
server/requirements.txtpins versions with prebuilt wheels.
- Keep Python 3.11 (runtime.txt).
502/timeout on first call
- Likely cold start / first-time model download. Wait, then retry. Use “Preload Model”.
CORS errors
server/app.pyenables permissive CORS for demo. If you tighten it, add your Vercel domain.
Speech recording not working
- Some browsers don’t support Web Speech API. Use Manual Input fallback.
Duplicate translation shown
- App suppresses translations equal to the original and avoids saving duplicates.
6) Optional: Single-service Docker on Render (frontend + API + Whisper)
If you prefer one Render service that serves both the UI and the API (and enables Whisper STT), switch to the Docker blueprint:
- Ensure your Render blueprint
render.yamlhas:
services:
- type: web
name: updated-translator
env: docker
dockerfilePath: ./Dockerfile
healthCheckPath: /api/health
envVars:
- key: STT_ENABLED
value: "1"
- key: WHISPER_MODEL
value: "tiny"
Deploy via Render → New → Blueprint → select repo.
Verify:
curl -sS https://<service>.onrender.com/api/health
curl -sS https://<service>.onrender.com/api/provider
Frontend will call same-origin /api/* automatically. Upload control for audio appears when STT is available.
7) Useful endpoints
GET /api/health→{ "status": "ok" }POST /api/translate- Body:
{ "text": "...", "source_language": "ur", "target_language": "en" } - Response:
{ "translated_text": "..." }
- Body:
POST /api/preload- Body:
{ "source_language": "ur", "target_language": "en" } - Response:
{ "ok": true, "model": "Helsinki-NLP/opus-mt-ur-en" }
- Body:
That’s it—Render for the API, Vercel for the UI, both on free plans. If you prefer Hugging Face Spaces for the backend, I can add a Dockerfile-based Space setup as well.