r/FastAPI • u/Ok-Platypus2775 • Jan 25 '26
Question FastAPI production architecture: modular design and dependency injection best practices
I am new to FastAPI. I have previously worked with Django and DRF. Django feels very well organized and mature, but in my experience it can be slow in some areas and has noticeable performance bottlenecks for certain workloads.
Because of that, I want to give FastAPI a serious try. I am looking for guidance on production level FastAPI architecture.
Specifically:
- How to structure a FastAPI project in a modular way
- Best practices for dependency injection
- How people organize routers, services, and database layers in real world apps
- Any common pitfalls when moving from Django/DRF to FastAPI
If you have examples, repo links, or lessons learned from running FastAPI in production, I would really appreciate it.
58
Upvotes
View all comments
Show parent comment
1
u/gbrennon Jan 27 '26
But anyone is forcing u to use drf like other people.
In most of companies that i did work and was using drf they were not doing the classical crud drf 💃
We had messages(events, commands or queries) we had dusiness logic extracted and decoupled from django and we were not doing that anti pattern common for rails and django that u end up with fat actvie record models.
Models were extracted from database models to decouple from the framework and database models were just related to data persistence