Skip to content

Instantly share code, notes, and snippets.

@luisjunco
Last active July 20, 2026 10:33
Show Gist options
  • Select an option

  • Save luisjunco/24a87def7fdde66a62e1a6cbdf74e7a6 to your computer and use it in GitHub Desktop.

Select an option

Save luisjunco/24a87def7fdde66a62e1a6cbdf74e7a6 to your computer and use it in GitHub Desktop.

Machine Learning - Model Deployment Demo - STEPS WE'LL FOLLOW

Intro to Deployment

  • Environments (dev / staging / production)
  • Recap: what's an API
  • Architecture
    • Frontend vs. Backend vs. Database

Initial setup

Repo (main branch):

Implement an API with FastAPI

  • 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.
    • Set environment variables (if needed)
      • e.g. API keys, database URLs, secrets...
    • Select "Instance Type"
      • Limitations of the free tier:
      - 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.
      
  • Test API in production (Postman)
  • Debugging & reading errors
  • Discuss: how can we do if we have more than 1 model.

Frontend

  • Implement the Frontend (e.g., React app)
  • Deploy the Frontend (e.g., Vercel)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment