finds.dev← search

// the find

zhanymkanov/fastapi-best-practices

★ 17,617 · updated May 2026

FastAPI Best Practices and Conventions we used at our startup

A battle-tested collection of FastAPI patterns from someone who actually shipped production systems with it. Covers async/sync route semantics, Pydantic usage, dependency injection patterns, and database conventions — the kind of hard-won knowledge that saves you a week of debugging event loop weirdness.

The async vs sync route explanation is the best short treatment of the subject I've seen — it explains threadpool offloading and the GIL interaction for CPU tasks without oversimplifying. The dependency chaining patterns are genuinely good: using FastAPI's dependency cache to avoid redundant DB calls is underused and this shows it clearly. The BackgroundTasks vs task queue decision table is honest about when fire-and-forget will bite you. The AGENTS.md addition is a thoughtful detail — keeping a machine-readable format alongside the human-readable README shows the project is being actively maintained.

It's a flat Markdown file, not code — you can't run the examples or verify they work together. The SQL-first section mixes SQLAlchemy 2.0 API with the old `encode/databases` library without being upfront about which you should actually use in a new project today. There's nothing on error handling strategy, which is where most FastAPI apps accumulate inconsistent behavior. No coverage of WebSockets, streaming responses, or file uploads despite those being common FastAPI use cases where the async rules bite people hardest.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →