Step-by-step instructions for deploying the Spiritual AI Guide to production using completely free hosting providers.
| Component | Platform | Cost | URL Pattern |
|---|---|---|---|
| Frontend (Next.js 14) | Vercel | Free | your-project.vercel.app |
| Backend (FastAPI) | Render | Free tier | spirtual-chatbot-api.onrender.com |
| Vector DB (ChromaDB) | Baked into Docker image | — | — |
| LLM | OpenAI API | ~$0.02/query | External API |
Render is the recommended backend platform for the free tier because it natively supports Dockerfile deployments and has a generous free tier for Web Services.
Render will build your project using Dockerfile.railway (kept for legacy naming rules but works perfectly on Render). This Dockerfile explicitly looks for your data/ folder and bakes it into the cloud server.
- Run
python scripts/ingest_notes.pylocally to ensure yourdata/embeddings/folder is up to date. - Open your
.gitignorefile and comment out# data/so that Git tracks the database. - Commit and push the
datafolder to GitHub.
- Go to render.com and sign in with GitHub.
- Click New + → Blueprint.
- Connect your GitHub repository:
FrancescoCavina02/Spiritual-chatbot. - Render will auto-detect the
render.yamlfile located in the root of the repository and instantly set up your FastAPI backend using the Docker container. - Click Apply.
Render will automatically prompt you for variables or you can go to your new Web Service → Environment, and fill in:
| Variable | Value | Required |
|---|---|---|
OPENAI_API_KEY |
sk-... your OpenAI key |
Yes |
CORS_ORIGINS |
https://your-project.vercel.app |
Yes (after Vercel deploy) |
Render will take around 5 minutes to build the container (downloading Python packages). Note: Render restricts Free tier instances to 512MB RAM, which your CPU-only PyTorch setup is optimized to safely run under!
Health check: Visit https://your-backend-name.onrender.com/health — you should see:
{
"status": "healthy",
"services": {
"chromadb": "operational (1,772 chunks indexed)",
"embeddings": "operational (sentence-transformers/all-MiniLM-L6-v2, 384D)",
"llm": "1 provider(s) active: openai"
}
}Netlify is the absolute easiest platform for deploying Next.js applications. It requires zero configuration and has a much simpler environment variable interface than Vercel.
- Go to netlify.com and sign up with GitHub.
- Click Add new site → Import an existing project.
- Authorize GitHub and select your repository:
FrancescoCavina02/Spiritual-chatbot. - Netlify will auto-detect Next.js 14.
- Set the Base directory to
frontend. - Leave the build command and publish directory as their defaults.
Before clicking deploy, click on Add environment variables:
- Click New variable.
- Key:
NEXT_PUBLIC_API_URL - Value:
https://spiritual-chatbot-api.onrender.com(Your Render backend URL) - Click Deploy site.
Netlify takes ~2 minutes to build the Next.js app. Once finished, you will receive a free public URL (e.g., https://spiritualchatbot1.netlify.app). You can customize this domain name in Site settings → Domain management.
Go back to Render → Web Service → Environment → Update CORS_ORIGINS to your new Netlify URL:
CORS_ORIGINS=https://your-custom-name.netlify.app
Redeploy the Render service via the manual deploy button using "Clear build cache & deploy".
| Variable | Description | Required | Default |
|---|---|---|---|
OPENAI_API_KEY |
OpenAI API key for GPT-4 Turbo | Yes | — |
CORS_ORIGINS |
Comma-separated allowed origins (e.g., https://your-app.netlify.app) |
Yes | localhost only |
PORT |
Server port (Render maps this natively) | Auto | 8000 |
| Variable | Description | Required | Default |
|---|---|---|---|
NEXT_PUBLIC_API_URL |
Backend Render URL | Yes | http://localhost:8000 |
| Problem | Likely Cause | Solution |
|---|---|---|
| Render Build OOM (Out of Memory) | PyTorch consuming RAM | The requirements.txt is hardcoded to --extra-index-url https://download.pytorch.org/whl/cpu to avoid this. Ensure it stays at the top of the file! |
| CORS error in browser | CORS_ORIGINS not set |
Add Netlify URL to Render CORS_ORIGINS variable |
| Slow first response | Render Free Tier Sleep | Render free tier spins down after 15m of inactivity. The first request takes ~50 seconds to wake the server up. Subsequent requests are instant. |