Education series · Week

Week 6 — Real backend (FastAPI + SQLite)

One Python file. A real API. Free docs.

📹 Video shipping soon

Drafted + scripted. Recording in queue. Subscribe to the Founder Plan to be notified the moment it lands.

What you'll walk away with

A scene-by-scene walkthrough of every beat in the video. Plain English. Real numbers. Real workflow.

The walkthrough

  1. One Python file. A real API. Free docs.
  2. Education Series · Module 6 · Real Backend with FastAPI + SQLite
  3. Fast · Type hints = validation · Auto docs · Async · Python you already know
  4. One file · No server · ACID · Runs everywhere · Free · 281TB max
  5. api/ · ├── main.py · ├── models.py · ├── db.py · ├── routes/ · └── data/contacts.db
  6. python -m venv .venv then activate
  7. pip install fastapi uvicorn[standard] sqlmodel
  8. from fastapi import FastAPI · app = FastAPI() · @app.get('/') · def root(): return {'ok': True}
  9. uvicorn main:app --reload
  10. Browser at http://localhost:8000/docs showing Swagger UI
  11. class Contact(SQLModel, table=True): id: int = Field(primary_key=True); name: str; email: str; ...
  12. SQLModel.metadata.create_all(engine) on startup
  13. @app.post('/api/contact') · def create(contact: Contact): db.add(contact); db.commit(); ...
  14. Add /api/contact POST and /api/contacts GET routes. SQLModel session, dependency-injected.
  15. def get_session(): with Session(engine) as s: yield s
  16. app.add_middleware(CORSMiddleware, ...)
  17. Try it out
  18. select * from contact
  19. fetch('http://localhost:8000/api/contact', { method: 'POST', body: ... })
  20. Form fills, submit, 200, row appears in SQLite
  21. A send_email helper using Postmark, called after the insert
  22. def list_contacts(api_key: str = Header()): checking against env var
  23. X-API-Key: ...
  24. Same pattern: model, route, validation, insert
  25. ContactCreate (input) vs Contact (DB)
  26. alembic init · alembic revision --autogenerate
  27. import logging · structured logs to a file + console
  28. BackgroundTasks for the email send so the response is fast
  29. /docs now shows every route, every model, every error
  30. flyctl launch then flyctl deploy
  31. flyctl volumes create data -s 1
  32. $0/mo on free tier · $1.94/mo for the volume · still cheaper than Heroku
  33. When: 50+ concurrent writes/sec · multi-region · giant joins
  34. 1. SQL injection · 2. No auth on admin routes · 3. Missing CORS · 4. Logging secrets
  35. Static site → FastAPI → SQLite → Postmark
  36. HOMEWORK: Move ONE Netlify Function to FastAPI. Run it locally. Hit it from your site.
  37. NEXT WEEK: Stripe payments — first paid product

Cut your AI bill 90%+

I built Local Model Dojo so the same kind of bot work that costs $100/mo on the Claude or OpenAI API runs on hardware you already own. Founder pricing locks in for the life of your account.

See Founder pricing → Code LAUNCH30 · 30-day window

← Week 5 — Converting to WordPress (when it makes sense) Week 7 — Stripe payments (accepting money online) →

— Jake Morris · Oklahoma veteran · localmodeldojo.com