- Environments (dev / staging / production)
- Recap: what's an API
- Architecture
- Frontend vs. Backend vs. Database
Repo (main branch):
- Intro
- Code → see branch "feat/model-deployment"
- Run api → see readme (on branch "feat/model-deployment")
- See API documentation http://localhost:8000/docs
- Test API locally (Postman)
- Deploy on Render.com
- Sign-in
- New "Web Service"
- Select the repository (may need to grant permissions)
- Environment: Python
- Root Directory
- leave blank
- Build Command:
- pip install -r requirements.txt
- Start Command:
- Example:
uvicorn api.main:app --host 0.0.0.0 --port $PORT - Explanation: "uvicorn my_dir.my_subdir.main:app" tells Uvicorn where to find your FastAPI app by following the Python module path (my_dir → my_subdir → main.py) and running the app object defined there.
- Example:
- Set environment variables (if needed)
- e.g. API keys, database URLs, secrets...
- Select "Instance Type"
- Limitations of the free tier:
- Free instances spin down after periods of inactivity.
- Ephemeral file system (SQLite will not work, since it stores the data in files; can use PostgreSQL)
- https://render.com/docs/free#free-web-services
- A Free web service spins down after 15 minutes of no inbound traffic (HTTP requests or WebSocket messages). - The next request automatically spins it back up, but startup typically takes about one minute, so the first request is noticeably slower. - Paid instance types do not spin down. - Limitations of the free tier:
- Test API in production (Postman)
- Debugging & reading errors
- Discuss: how can we do if we have more than 1 model.
- Implement the Frontend (e.g., React app)
- Deploy the Frontend (e.g., Vercel)