Build a FastAPI App. Then Make It Production-Ready.

Two free courses, one project. Build a REST API from scratch, then add tests, logging, atomic writes, and error handling.

AndreiAndrei·March 3, 2026·5 min read

Most FastAPI tutorials end at "it works." You have endpoints. They return JSON. You test them manually and everything looks fine.

Nobody shows you what happens next. How do you test it automatically? What happens when the server crashes mid-save? How does a frontend call your API from a browser? How do you configure your app for different environments without changing the code?

These aren't advanced topics. They're the baseline for any API that someone besides you will actually use. But they're scattered across blog posts, Stack Overflow answers, and "best practices" lists that assume you already know the context.

So I built two courses that teach the full arc - from zero to production-ready - on a single project.

The project: an expense tracker API

Both courses build the same thing: a personal expense tracker API with FastAPI. Six endpoints - create, list, filter, get, update, delete - plus a summary endpoint and JSON file persistence. It's small enough to finish in a few hours, complex enough to hit real problems.

The first course builds it. The second course hardens it. Same codebase, same file, continuous progression.

Course 1: Build a REST API with FastAPI

This course starts from "what is an API" and ends with a working expense tracker. Seven lessons, 34 chapters. You don't need prior FastAPI experience.

Here's what you build, one endpoint at a time:

  • How APIs work - what HTTP methods mean, what JSON looks like, how requests and responses flow. Plus a Pydantic model with date validation.
  • Create an expense - your first POST endpoint, request validation, auto-generated unique identifiers. You open Swagger UI in the browser and see it work.
  • List and filter - GET with optional query parameters. Filter expenses by category.
  • Get and delete - path parameters, 404 error handling, removing items from storage.
  • Update - PATCH with partial updates. Only change the fields you send.
  • Persistence - save expenses to a JSON file so they survive server restarts. Load on startup, save on every change.
  • Polish - a GET /summary endpoint that calculates spending totals by category. The capstone.

Every chapter adds about four lines of code. You write them, the platform checks them, you move on. No videos, no slides, no "follow along." Just instructions on one side, an editor on the other.

Starting the server and testing your POST endpoint in the browser - a terminal chapter from Course 1.

By the end, you have a working API. And that's exactly where most tutorials stop.

Course 2: Harden Your FastAPI

This course picks up the same expense tracker and adds everything it needs for production. Three lessons, 22 chapters.

Lesson 1: Test Your API. Ten chapters on testing. Not "you should write tests" - the actual how. Unit tests for your date validator. Endpoint tests with TestClient (no running server needed). Tests for every CRUD operation. Tests for error cases - 404s, validation failures, bad inputs. The key insight: test your custom logic, not framework internals. FastAPI parsing JSON correctly is already battle-tested. Your validation rules are not.

Writing unit tests for the date validator - instructions on the left, multi-file editor with test_main.py on the right.

Lesson 2: Middleware & Reliability. What middleware is and how it works. Request logging that captures method, path, status code, and response time for every request. Atomic file writes - because json.dump() directly to a file will lose your data if the app crashes mid-save. CORS headers so a frontend can actually call your API from a browser.

Rewriting save_expenses to use atomic file writes - the content explains the corruption problem, the editor shows the fix.

Lesson 3: Configuration & Error Handling. Why hardcoded file paths break when you deploy. Pydantic's BaseSettings for reading typed configuration from .env files. A global exception handler that catches any unhandled error, logs the full traceback for you, and returns a clean JSON response to the client - no stack traces leaking to users.

Replacing hardcoded values with a Settings class - environment-based configuration with Pydantic's BaseSettings.

By the end, your expense tracker has a test suite, logging, crash-safe persistence, cross-origin support, environment config, and error handling. Same six endpoints. Now production-ready.

What comes next

Your API is tested, configured, and handles errors gracefully. But it still saves everything to a JSON file. That works for a personal project - until you need to search expenses by date range, generate monthly reports, or handle multiple users.

The next course in this path swaps the JSON file for a real database with SQLite and SQLModel. Same expense tracker, same codebase, a much more powerful backend. It's currently being built.

Why this approach

After years of building coding courses, one thing became obvious: developers want to build something that works today, not watch forty hours of video to maybe build something next month.

Every DevGuild course produces a concrete thing. If a student can't point to something they built, the course failed. That's the bar.

These two courses give you a working, production-hardened API in about seven hours of hands-on coding. Everything is free. No paywall, no trial period.

Start with Course 1: Build a REST API with FastAPI →

Already know FastAPI basics? Jump straight to Course 2: Harden Your FastAPI →

Questions, feedback, or course requests? Find me on Twitter.

  • Andrei
Andrei
Andrei

Founder of DevGuild. I build tools for developers and write about Python, AI, and web development.

@RealDevGuild