r/FastAPI • • Feb 24 '26

Question FastAPI best practices

41 Upvotes

Hello! I am writing a simple web server using FastAPI but I am struggling trying to identify which are the best practices for writing clean, testable code.

Background
I come from multiple years of programming in Java, a strongly OOP oriented language. I've already made the mistake in the past to write Python code as if it were Java and quickly learned that not everything works for every language. Things are intended to be written a specific way.

For what I know, FastAPIs are not intended to be written using Python's OOP but plain functions.

Problem
The problem that I am facing is that I don't see any mechanism for having proper dependency injection when writing an API. A normal layout for a project would be something like:

  • router files, with annotated methods that defines the paths where the API is listening to.

  • main app that defines the FastAPI object and all the involved routers.

Let's say that my business logic requires me to access a DB. I could directly have all the code required in my router to create a connection to the DB and get the data I need. However, a good practice is to inject that DB connection into the router itself. That improves testability and removes the responsibility of the router to know anything related to how to connect to a DB, separating concerns.
Now, the way FastAPI suggest to do that is by using the `Depends` annotation. The problem with that, is that it requires me to provide the function that will return the object I need. If the dependant knows the function that instantiates the dependency, then there is no inversion of control whatsoever. Even if the function is a getter from a DI container of something like that, I have to be able to inject the container itself into the router's file.

I know that I can use the `dependencies_overrides` method from the FastAPI but that looks to be only for testing.

So, which is the best way for achieving this? The router should never know how to instantiate a DB connection, ever.

EDIT
So, after more reading and testing, this is what I ended up doing. Thanks u/mwon for pointing in the right direction.

service.py

class Service:
  def __init__(self, database):
    self._database = database

  def do_something(self):
    //Business logic for the service, maybe involving DB access

router.py


my_router = APIRouter(
    prefix="/some_path",
)

@my_router.get("/test")
async def get_test(service: Annotated[Service, Depends(get_service)]):
  return service.do_something()

def get_service(request: Request):
  return request.app.state.service

app.py

@asynccontextmanager
async def lifespan(app: FastAPI)
  database = CreateDatabase()
  service = Service(database)
  
  app.state.service = service
  yield
  database.close()

app = FastAPI(lifespan=lifespan)
app.include_router(my_router)

This way, all my business logic in service.py is independent and can be properly unit tested. I can create instances of Service providing mocked databases and I don't require anything related to FastAPI. You can use the override_dependencies option for Integration Testing if you needed to. But that is fine because the idea is to have a running FastAPI at that point, maybe mock or fake simple behaviors to avoid having to spin up a full system.

Yes, the router also "decides" where to get Service instances from, but it's not in charge of their lifecycle. Those are injected to it via the app state.

Also, I can keep a single instance of the DB for the whole app and don't need to create a new one per request.


r/FastAPI • • Mar 18 '25

Question Scalable FastAPI project structure

41 Upvotes

I'm really interested about how you structure you fastAPI projects.

Because it's really messy if we follow the default structure for big projects.

I recently recreated a fastapi project of mine with laravel for the first time, and i have to admit even though i don't like to be limited to a predefined structure, it was really organized and easily manageable.

And i would like to have that in my fastapi projects


r/FastAPI • • Feb 01 '25

Question Polling vs SSE vs Websockets: which approach use the least workers?

41 Upvotes

I have a FastAPI app running on Ubuntu EC2, using uvicorn, behind NGINX proxy. The Ec2 is m5a.xlarge there: 4 vCPUs. The server is running 2 FastAPI apps, a staging application and a production application. They're both the same app, different copies and different URLs for staging and production. There are also 2 cron jobs, to do background processing when needed.

According to StackOverflow, we can only run 1 worker per VCPU, as such I have 2 workers for the production application and 2 workers for the staging application. This is an internal tool used by 30 employees at most but the background process cron is handling hundreds of files per day.

The application has 2 sections, a section similar to a chat section, I'm using Websockets there. Websockets is running fine, no complaints.

The second section is a file processing section is where the problems are. The file processing mechanism has multiple stages, the entire process might take an hour, therefore I was asked to send the results of every stage as soon as it ends, for this I used SSE, and I was asked to show them the progress every few minutes, so they know at what stage the process is now and how much time is remaining. For this I used polling, I keep a text file with the current stage and I poll every 10 seconds.

Now the CPU usage is always high, sometimes the progress doesn't show on the frontend in production, and many other issues.

I wish I had done it all in Websockets, since websockets always works fine with FastAPI. Now I'm in the process of removing polling and just use SSE,

I just wonder, with regards to FastAPI workers, which approach requires the least numbers of workers and CPU usage?

As for why I'm using 2 workers, it's because when I used one, the client complained that the app is slow, so now I have one for the UI, handling the UI and uploads and one for the other tasks.

You'll also ask me, why aren't you handling everything in the cronjob and sending everything by mail? I'm already doing that and that is working fine, but sometimes the client doesn't want to wait for an email, they don't want to enter in the queue and wait their turn, sometimes they want just fast file processing.


r/FastAPI • • Oct 07 '21

Announcement Three new FastAPI releases: support for Trio with AnyIO ✨

41 Upvotes

Three new FastAPI releases in a row! πŸŽ‰

The highlight is support for Trio via AnyIO ✨

Read the new docs about running FastAPI with Trio and Hypercorn here: https://fastapi.tiangolo.com/deployment/manually/#hypercorn-with-trio

πŸ”– FastAPI 0.68.2 has no breaking changes, upgrades the ranges of all the dependencies to help make migrations smooth.

It's an independent release so that you can migrate gradually. In case there's a breaking change in the next ones, you can still benefit from this.

πŸ”– FastAPI 0.69.0 upgrades Starlette to 0.15.0, with support for Trio.

It's now based on AnyIO, the same as Starlette, so it's compatible with asyncio and Trio.

FastAPI with Trio and Hypercorn docs: https://fastapi.tiangolo.com/deployment/manually/#hypercorn-with-trio

πŸ”– FastAPI 0.70.0 upgrades Starlette to 0.16.0, the latest version, with several bug fixes.

Also in an independent release to facilitate smooth upgrades.

πŸ€“ Shoutouts to:

Alex GrΓΆnholm, for AnyIO

Jordan Speicher, for the big migration to AnyIO in Starlette

Thomas Grainger for the migration to AnyIO in FastAPI


r/FastAPI • • Mar 13 '26

pip package My attempt at building a Pydantic-native async ORM

40 Upvotes

Hey everyone! One thing that always bugged me with FastAPI: Pydantic does a great job validating data and not letting garbage through. But the moment you bring in an ORM, you're back to separate models with their own rules, and that whole validation contract breaks apart.

I personally don't vibe with SQLAlchemy, just not my style, no hate. And existing alternatives either wrap it (SQLModel) or bring their own model system (Tortoise). I wanted something where the Pydantic model IS the database model. One class, one contract, validation on the way in and on the way out.

So I tried to build what I think an async ORM could look like in 2026. Django-style query API because I think it's one of the best. Explicit, no lazy loading, no magic, you see exactly what hits the database. Type stubs generated automatically so your IDE knows every field and lookup. Rust core for SQL generation and pooling so you don't pay for the convenience in performance.

Every ORM needs at least a basic admin panel, so I built that too. Auto-generates CRUD, search, filters, export from your models. Works with FastAPI, Litestar, Sanic, Quart, Falcon.

Here's everything:

Just pip install oxyde, that's it. The Rust core (oxyde-core) ships as pre-built wheels for Linux, macOS, and Windows, so no Rust toolchain needed.

It's v0.5, beta. Would love to hear your thoughts, ideas, criticism, whatever. If something is missing or feels off, I want to know about it.


r/FastAPI • • Jan 27 '26

Question How to actually utilize FastAPI (Django β†’ FastAPI transition pain)

40 Upvotes

Hey, People of Reddit πŸ‘‹

We’ve been a Django-first team for ~5 years, very comfortable with Django’s patterns, conventions, and batteries-included ecosystem. Recently, due to a shift toward GenAI-heavy workloads, we moved most of our backend services to FastAPI.

The problem we’re facing:
We feel like we’re still writing Django, just inside FastAPI.

Unlike Django, FastAPI doesn’t seem to have a strong β€œstandard way” of doing things. Project structures, DB patterns, async usage, background jobs β€” everyone seems to be doing it their own way. That flexibility is powerful, but it’s also confusing when you’re trying to build large, long-lived, production-grade systems.

What we’re specifically looking for:

1. Project structure & architecture

  • Recommended production-grade FastAPI project structures

  • How teams organize:

    • routers

    • services/business logic

    • DB layers

    • shared dependencies

  • Any de facto standards you’ve seen work well at scale

2. Async, how to actually use it properly

This is our biggest pain point.

Coming from Django, we struggle with:

  • When async truly adds value in FastAPI

  • When it’s better to stay sync (and why)

  • How to actually leverage FastAPI’s async strengths, instead of blindly making everything async def

  • Real-world patterns for:

    • async DB access

    • async external API calls

    • mixing sync + async safely

  • Common anti-patterns you see teams fall into with async FastAPI

3. Background tasks & Celery

Our setup is fully Dockerized, and usually includes:

  • FastAPI service

  • MCP service

  • Celery + Celery Beat

Issues we’re running into:

  • Celery doesn’t work well with async DB drivers

  • Unclear separation between:

    • FastAPI background tasks

    • Celery workers

    • async vs sync DB access

  • What’s the recommended mental model here?

4. ORM & data layer

  • Is there an ORM choice that gives strong structure and control, closer to Django ORM?

  • We’ve used SQLAlchemy / SQLModel, but are curious about:

    • better patterns

    • alternatives

    • or β€œthis is the least-bad option, here’s how to use it properly.”

5. Developer experience

  • Is there anything similar to django-extensions shell_plus in the FastAPI world?

  • How do you:

    • introspect models

    • test queries

    • debug DB state during development?

Overall, we’re trying to:

Stop forcing Django mental models onto FastAPI
and instead use FastAPI the way it’s meant to be used

If you’ve:

  • Migrated from Django β†’ FastAPI

  • Built large FastAPI systems in production

  • Or have strong opinions on async, architecture, ORMs, or background jobs

  • Have Resources or experience that addresses this problem

We’d really appreciate your insights πŸ™

Thanks!


r/FastAPI • • Jan 11 '26

Tutorial Bookstore API Guide

40 Upvotes

πŸ”₯ Update 12.01 18:20 GMT+5

πŸš€ Major Update: Production-Ready Python FastAPI Course - Now with Database Migrations & Better Structure!

Hey r/FastAPI! πŸ‘‹

I'm excited to share a major update to my free, open-source Python development course! After receiving amazing feedback from the community, I've made significant improvements that make this even more production-ready and beginner-friendly.

This is NOT an advertisement - just sharing valuable learning resources with the community! πŸŽ“

πŸ†• What's New in v2.0:

πŸ—„οΈ Professional Database Migrations with Alembic

  • βœ… Version-controlled schema changes - No more create_all() hacks!

  • βœ… Safe production deployments - Rollback capabilities for peace of mind

  • βœ… Team collaboration - Sync database schemas across developers

  • βœ… Custom migration manager - Easy-to-use Python script for all operations

# Professional database management
python development/scripts/migrate.py status
python development/scripts/migrate.py create "Add user preferences" --autogenerate
python development/scripts/migrate.py upgrade

πŸ“ Completely Reorganized Project Structure

  • 🎯 Clean root directory - No more file chaos!

  • πŸ“¦ Logical organization - Everything has its place

  • πŸš€ Deployment-focused - All deployment configs in one place

  • πŸ“š Developer-friendly - Tools and examples organized properly

bookstore-api/
β”œβ”€β”€ πŸ“ deployment/         # Docker, K8s, configs
β”œβ”€β”€ πŸ“ development/        # Scripts, examples, tools  
β”œβ”€β”€ πŸ“ documentation/      # Comprehensive guides
β”œβ”€β”€ πŸ“ requirements/       # Organized dependencies
└── πŸ“ archive/           # Legacy files

🎯 Enhanced Learning Experience

  • πŸ“– Progressive roadmap - 6 different learning paths based on your goals

  • ⚑ 30-second setup - Get started immediately

  • πŸ› οΈ Better tooling - Enhanced scripts and automation

  • πŸ“š Comprehensive docs - Step-by-step guides for everything

πŸ”₯ What's Still Included (Production-Ready Features):

πŸ—οΈ Enterprise-Grade Architecture

  • FastAPI with async/await and automatic OpenAPI docs

  • SQLAlchemy 2.0 with proper relationship management

  • Pydantic v2 for bulletproof data validation

  • JWT Authentication with secure token handling

  • Database migrations with Alembic (NEW!)

πŸ§ͺ Comprehensive Testing (95%+ Coverage)

  • Unit tests - Core functionality validation

  • Integration tests - API endpoint testing

  • Property-based tests - Hypothesis for edge cases

  • Performance tests - Load testing with Locust

  • Security tests - Automated vulnerability scanning

🐳 Production Deployment Stack

  • Multi-stage Docker builds - Optimized for production

  • Kubernetes manifests - Auto-scaling and high availability

  • Docker Compose - Both dev and production environments

  • Nginx load balancer - SSL termination and routing

πŸ“Š Monitoring & Observability

  • Prometheus - Metrics collection and alerting

  • Grafana - Beautiful dashboards and visualization

  • Loki - Centralized log aggregation

  • Structured logging - JSON format with request tracing

πŸ”„ CI/CD Pipeline

  • GitHub Actions - Automated testing and deployment

  • Multi-environment - Staging and production workflows

  • Security scanning - Bandit, Safety, Semgrep integration

  • Automated releases - Version management and tagging

🎯 Perfect Learning Paths:

πŸš€ Quick Explorer (5 minutes)

Just want to see it work? One command setup!

πŸ“± API User (30 minutes)

Learn to integrate with professional APIs

πŸ‘¨β€πŸ’» Developer (2 hours)

Understand and modify production-quality code

🏭 Production User (1 hour)

Deploy and monitor in real environments

☸️ DevOps Engineer (3 hours)

Master the complete infrastructure pipeline

πŸŽ“ Learning Path (Ongoing)

Use as comprehensive Python/DevOps curriculum

πŸ’‘ What Makes This Special:

βœ… Real production patterns - Not toy examples
βœ… Database migrations - Professional schema management (NEW!)
βœ… Clean architecture - Organized for scalability (NEW!)
βœ… Multiple learning paths - Choose your adventure (NEW!)
βœ… Complete CI/CD - From commit to production
βœ… Security-first - Best practices built-in
βœ… Monitoring ready - Observability from day one
βœ… Interview prep - Discuss real architecture in interviews

πŸ› οΈ Tech Stack:

Backend: FastAPI, SQLAlchemy, Pydantic, Alembic
Database: PostgreSQL, Redis
Deployment: Docker, Kubernetes, Nginx
Monitoring: Prometheus, Grafana, Loki
Testing: pytest, Hypothesis, Locust
CI/CD: GitHub Actions

⚑ Quick Start:

# 30-second setup
git clone https://github.com/f1sherFM/bookstore-api-course.git
cd bookstore-api-course
cd deployment/docker && docker-compose up -d

# API docs: http://localhost:8000/docs
# Grafana: http://localhost:3000

πŸ“Š Project Stats:

  • πŸ“ˆ 95%+ test coverage - Comprehensive quality assurance

  • πŸ—οΈ Production-ready - Used in real deployments

  • πŸ”„ Professional migrations - Alembic integration (NEW!)

  • πŸ“ Clean structure - Organized for teams (NEW!)

  • πŸš€ 6 learning paths - Something for everyone (NEW!)

  • πŸ“š Complete documentation - Every feature explained

  • πŸ”’ Security hardened - Best practices implemented

πŸŽ“ Learning Outcomes:

By the end, you'll have:

  • Built a scalable, monitored API from scratch

  • Mastered database migrations and schema management

  • Learned production deployment with Docker/K8s

  • Implemented comprehensive testing strategies

  • Set up monitoring and observability

  • Created a portfolio project for interviews

πŸ”— Links:

GitHub: https://github.com/f1sherFM/bookstore-api-course
Quick Start: Check QUICK_START.md in the repo
Documentation: Browse documentation/ directory

πŸ™ Community:

This project has grown thanks to community feedback! Special thanks to everyone who suggested improvements.

If you find this useful:

  • ⭐ Star the repo - Helps others discover it

  • πŸ› Report issues - Help make it better

  • πŸ’‘ Suggest features - What would you like to see?

  • 🀝 Contribute - PRs welcome!


Remember: This is a learning resource, not a commercial product. Everything is free and open-source!

What do you think of the new improvements? Any features you'd like to see added? πŸ€”


r/FastAPI • • Jul 26 '25

pip package Built a simple middleware to redirect potential intruders to '10 hours of' videos

40 Upvotes

This was originally inspired by a Nick Craver (previous architect lead at StackOverflow) tweet in 2018. Thought I would port it over to FastAPI since it was simple and fun. The CI on this was particularly fun, as I've added a weekly check for broken YouTube links. Let me know your thoughts, cheers.

https://github.com/nickatnight/fastapi-spam


r/FastAPI • • Dec 20 '24

Question Why does fastapi official example repo uses everything sync and not async?

40 Upvotes

While in here, I see recommendations to go for only async, even db sessions in example repo is sync engine and people here recommending async?


r/FastAPI • • Jun 17 '24

Question Full-Stack Developers Using FastAPI: What's Your Go-To Tech Stack?

40 Upvotes

Hi everyone! I'm in the early stages of planning a full-stack application and have decided to use FastAPI for the backend. The application will feature user login capabilities, interaction with a database, and other typical enterprise functionalities. Although I'm primarily a backend developer, I'm exploring the best front-end technologies to pair with FastAPI. So far, I've been considering React along with nginx for the server setup, but I'm open to suggestions.

I've had a bit of trouble finding comprehensive tutorials or guides that focus on FastAPI for full-stack development. What tech stacks have you found effective in your projects? Any specific configurations, tools, or resources you'd recommend? Your insights and any links to helpful tutorials or documentation would be greatly appreciated!


r/FastAPI • • Jan 25 '23

Other What do you think Tiangolo has lined up for us? πŸ€“

Post image
40 Upvotes

r/FastAPI • • Feb 09 '26

pip package Tortoise ORM 1.0 release with migrations support

39 Upvotes

I know many people using fast-api use tortoise as orm, to minimise boilerplate code and to have more django-like experience.
For many years people using tortoise had one big limitation - migrations support in tortoise was lacking, which pushed users to use Alembic together with SQLAlchemy for full-fledged migrations support.

Tortoise did have migrations support via the Aerich library, but it came with a number of limitations: you had to connect to the database to generate migrations, migrations were written in raw SQL, and the overall coupling between the two libraries was somewhat fragile - which didn’t feel like a robust, reliable system.

The new release includes a lot of additions and fixes, but I’d highlight two that are most important to me personally:

  • Built-in migrations, with automatic change detection in offline mode, and support for data migrations via RunPython and RunSQL.

  • Convenient support for custom SQL queries using PyPika (the query builder that underpins Tortoise) and execute_pypika, including returning typed objects as results.

Thanks to this combination of new features, Tortoise ORM can be useful even if you don’t want to use it as an ORM: it offers an integrated migrations system (in my view, much more convenient and intuitive than Alembic) and a query builder, with minimal additional dependencies and requirements for your architecture.

You can see example project for fast-api with tortoise and migrations at

{github}/tortoise/tortoise-orm/tree/develop/examples/fastapi (sorry for not linking directly, afraid of reddit auto-ban)

Try it out yourself, create issues, contribute through PRs


r/FastAPI • • Oct 29 '25

feedback request Feedback on pragmatic FastAPI architecture

39 Upvotes

Here's my take on a pragmatic and AI-friendly FastAPI architecture: https://github.com/claesnn/fastapi-template/tree/main .

Features

  • Async endpoints

  • Async SQLAlchemy

  • Alembic migrations

  • Feature folder structure

  • Nested bi-directional Pydantic schemas

  • Struclog structured logging

  • Pytest testing of API layer

  • UV for dependencies

  • CORS

  • Status and health checkpoints

  • Pydantic_settings with .env loading

  • Typed pagination with TypedDict and Generics

  • Filtering and ordering

  • Basic Bearer authentication (would add JWK with PyJWKClient in corporate apps)

  • Explicit transaction handling in routes with service level flush

Omits

  • Repository: I'm using plain SQLAlchemy and add a model function if getter/setter functionality is demanded

  • Service interfaces: Whilst it decouples better; it seems overkill to add to all services. Would definitively add on demand.

  • Testcontainers: Additional complexity and in my experience, testing goes from 0.5 seconds to 8+ seconds when testcontainers are introduced

  • Unit tests: To keep test amount controllabe, just test the API layer

Anyways, I'm looking for feedback and improvement options.


r/FastAPI • • May 12 '25

Question Favorite FastAPI tutorial?

39 Upvotes

Apologies if this question is repetitive, and I genuinely do understand the annoyance this questions can cause.

I've been doing a bit of googling, and after a few purchases on udemy and youtube videos, I feel like I'm not really finding something that I want, yet.

I was wondering if anyone here could recommend me a tutorial that can teach me Fast API at a 'industry standard practice' level? A lot of tutorials that I've come across have been very educational, but also don't apply standard practices, or some don't even use a database and instead store everything in memory.

I understand the docs are where it's really at, but I can't sit still with reading. Videos / courses tend to hold my attention for longer periods of time.

Thank you so much.


r/FastAPI • • Nov 01 '21

pip package AuthenticationX is here πŸš€βœ¨

39 Upvotes

Add a Fully registration and authentication or authorization system to your FastAPI project. AuthX is designed to be as customizable and adaptable as possible.

Note: This is a beta version of AuthX.

Features πŸ”§

  • Support Python 3.8+.

  • Extensible base user model.

  • Ready-to-use register, login, reset password, and verify e-mail routes.

  • Ready-to-use Social login and Oauth2 routes. (now with Google, Facebook)

    • Soon with Microsoft, Twitter, Github, etc.

    • Ready-to-use social OAuth2 login flow

  • Tested Project on Docker.

  • Dependency callable to inject current user in route

  • Pluggable password validation

    • Using Captcha Service.

  • Using Email Service. (SMTP)

  • Extensible Error Handling

  • High-level API to manage users, roles, and permissions

  • Using Redis as a session store & cache.

  • Customizable database backend:

  • Multiple customizable authentication backends:

    • JWT authentication backend included

    • Soon to be included Cookie authentication backend

  • Full OpenAPI schema support, even with several authentication backends.

  • ProductHunt: https://producthunt.com/posts/authx

  • Documentation: https://authx.yezz.codes

  • Repository: https://github.com/yezz123/AuthX


r/FastAPI • • Jul 29 '26

Question Looking for Advice on a Clean FastAPI Backend Architecture for an E-learning Platform

38 Upvotes

Hi everyone,

I'm currently building a fairly large e-learning platform using FastAPI,it's my first project, and before I go too far with development, I'd like to make sure my backend architecture is well designed, scalable, and maintainable.

The project will include features such as:

  • User authentication and authorization (JWT, roles: Admin, Teacher, Student, Parent)

  • Courses and modules

  • Lessons (videos, PDFs, quizzes)

  • Assignments and submissions

  • Exams and grading

  • Progress tracking

  • Notifications

  • Payments/subscriptions (later)

  • File uploads

  • Discussion/comments

  • Certificates

  • REST API (possibly GraphQL in the future)

I'm planning to use:

  • FastAPI

  • SQLAlchemy 2.0

  • Alembic

  • PostgreSQL

  • Pydantic v2

  • JWT Authentication

At the moment, I'm trying to decide on the best project structure. I've seen many different approaches:

  • Traditional layered architecture

  • Clean Architecture

  • Domain-Driven Design (DDD)

  • Hexagonal Architecture

  • Vertical Slice Architecture

  • Feature-based architecture

I'd like to avoid ending up with a project that's difficult to maintain as it grows.

My questions

  1. Which architecture would you recommend for a medium-to-large FastAPI project like this?

  2. How would you organize the folders and modules?

  3. Where should business logic live?

  4. How do you separate models, schemas, services, repositories, and dependencies without creating unnecessary complexity?

  5. Are there any open-source FastAPI projects that you consider good examples of clean architecture?

I'm looking for an architecture that is:

  • Easy to maintain

  • Easy to test

  • Scalable

  • Production-ready

  • Follows FastAPI and Python best practices

If you have an example repository or folder structure that you've used successfully, I'd really appreciate it.

Thank you!


r/FastAPI • • Feb 18 '26

Question Dependency Injection in FastAPI

38 Upvotes

Are you usually satisfied with the built-in dependency injection or are you using an additional DI-Library. If using an additional one, which is the best one?


r/FastAPI • • Jan 12 '26

Question Beginner FastAPI projects recommendation

38 Upvotes

Hi there,

I'm a beginner learning fastapi from fastapi official tutorial / user guide. It's really a great guide written in beginner friendly language. I think I've done 1/3 of this tutorial.

I'm learning stuff but I think it's not sticking. I need to build stuff with these concepts and tools I learn so that they can stick in my head.

I just want you guys to list some projects recommendations which increase in complexity one by one so that i actually get to practice more of FastAPI.

Also, if you can, please also write how many days each project should typically take so I can judge myself against and get clearer perspective.

Thanks a lot for your time!

Edit: I forgot to mention that right now, I'm preferring sqlite (because I know some of it) and SQLModel. Maybe later I'll learn SQLAlchemy.


r/FastAPI • • Jul 17 '25

Tutorial Developing a Real-time Dashboard with FastAPI, Postgres, and WebSockets

Thumbnail
testdriven.io
37 Upvotes

r/FastAPI • • Mar 18 '25

Question SQLModel vs SQLAlchemy in 2025

37 Upvotes

I am new to FastAPI. It is hard for me to choose the right approach for my new SaaS application, which works with PostgreSQL using different schemas (with the same tables and fields).

Please suggest the best option and explain why!"


r/FastAPI • • Oct 21 '24

Hosting and deployment What do you use to host FastAPI?

37 Upvotes

I found that using vercel you can start for free ! before I was using digital ocean which was easy too to set up but started at 5$/month


r/FastAPI • • May 19 '23

pip package Propan - is a new python framework for building messaging services

37 Upvotes

Hello everyone!

I have accumulated a critical mass of stuffed bumps in the development of RabbitMQ based services. The amount of boilerplate forced me to drag the same code from project to project. So I decided to put all this code in a separate package, spice it up with a small pinch of FastAPI concepts and scale my experience to other message brokers.

The only purpose of the framework is to make interaction with message brokers as simple and comfortable as possible: one decorator, launch via the CLI - and your application is ready to production.

Please take a look at the project and give me your feedback: maybe you have some ideas for improvement. Also, I really need your help as a developers, as it becomes difficult for me alone with a project of this scale.

https://github.com/Lancetnik/Propan


r/FastAPI • • Jun 09 '26

feedback request My first messenger

36 Upvotes

Hey everyone! I built a full-stack messenger for my family β€” I'm 13

Hi! I've posted here a couple of times before, and the feedback was always helpful. This time I think I built something I'm genuinely proud of.

The backstory:Β I'm from Russia, and messengers keep getting blocked here β€” so I just built my own. A private messenger + social feed for my family.

DragramΒ β€” what's inside:

  • FastAPI + PostgreSQL + Redis + WebSockets

  • React + TypeScript frontend

  • Real-time chat, image/video/audio messages with a proper media player

  • End-to-end encryption keys per chat

  • Android app via Capacitor (same codebase β†’ native APK)

  • Deployed on Railway with Docker + Nginx + S3

Wrote all backend myself. Any feedback on architecture or code quality is very welcome!


r/FastAPI • • Mar 11 '26

feedback request Added TaskIQ and Dramatiq to my FastAPI app scaffolding CLI tool. Built one dashboard that works across all worker backends.

36 Upvotes

Hey r/FastAPI - back in December I shared a CLI that scaffolds FastAPI apps with modular components: https://www.reddit.com/r/FastAPI/comments/1pdc89x/i_built_a_fastapi_cli_that_scaffolds_full_apps/

The response was incredible, and your feedback shaped what I built next:

  • "Isn't ARQ in maintenance mode? What about TaskIQ?"

  • "When I moved from Django + Celery to Async FastAPI I also checked out Dramatiq to pair with it. Not nearly as full featured as celery, but certainly still a great product and easy enough to work with."

I spent the last 3 months adding exactly what you asked for. You can now choose ARQ, TaskIQ, or Dramatiq at initialization based on your actual needs.

But supporting multiple backends created an operational problem.

Each worker system has its own monitoring solution - TaskIQ has taskiq-dashboard, ARQ has arq-dashboard, Dramatiq has dramatiq_dashboard. That's great for single-backend projects, but when you support all three, your users would have to learn different tools depending on which backend they chose.

Since Overseer (the stack's control plane) already monitors your database, cache, auth services, and scheduler, I needed worker monitoring that integrated consistently with the rest of the system.

I needed the PydanticAI of worker dashboards - one interface that works regardless of what's running underneath.

So I built unified real-time worker dashboards directly into Overseer that work universally across all three backends.

The architecture:

  • Workers publish standardized lifecycle events to Redis Streams (regardless of backend)

  • Overseer consumes via XREAD BLOCK and streams updates via SSE

  • Real-time monitoring integrates with the existing health checks and alerts

  • UI updates every ~100ms so it doesn't freeze under heavy load

It comes pre-configured as part of the stack:

uvx aegis-stack init my-project --components "worker[taskiq]"

You can see it running live at https://sector-7g.dev/dashboard/

Links:

What other worker backends should I look at supporting?

For the record, I did a long, long hard look at Celery, just couldn't make it work without having to either build my own sync/async bridge (like what Dramatiq has in its middleware layer), or having sync/async versions of methods that work with both celery, but other async stuff in the project. I haven't used Celery since 2015, not sure about the internals anymore, and just didn't want to risk it. Thought, I keep hearing something about a Celery 6 with built in async support. It's a huge ecosystem with a lot of users, I just can't do it now.

I've also been looking at this: https://github.com/tobymao/saq

I don't want to add more worker backends just for the sake of adding another bullet point, but if I'm missing anything, let me know. Also, suggestions on the actual dashboard itself are greatly appreciated.