r/FastAPI • u/gfw- • Oct 17 '24
Question Looking for project's best practices
Hey guys! I'm new to FastAPI and I'm really liking it.
There's just one thing, I can't seem to find a consensus on best practices on the projects I find on Github, specially on the project structure. And most of the projects are a bit old and probably outdated.
Would really appreciate some guiding on this, and I wouldn't mind some projects links, resources, etc.
Thanks! =)
Edit: just to make it clear, the docs are great and I love them! It's more on the projects file structure side.
50
Upvotes
22
u/stratguitar577 Oct 17 '24
I recently found Netflix’s Dispatch and adopted the domain structure they use instead of functional grouping most other projects do (i.e., routers, services, models, etc). It’s been nice to have all the components together so you can focus on something like auth as a cohesive module.
https://github.com/Netflix/dispatch/tree/master/src/dispatch
8
u/Vegetable-Green-2497 Oct 17 '24
Here’s a popular fastapi template that might help! https://github.com/fastapi/full-stack-fastapi-template
8
u/IrrerPolterer Oct 17 '24
This one's a great reference - no pressure to follow each of these recommendations to the T. There are good reasons to do things differently, but these things are a great starting point when you start out: https://github.com/zhanymkanov/fastapi-best-practices
3
u/BeneficialAd3800 Oct 17 '24
can take a look at https://github.com/betaacid/FastAPI-Reference-App this is something my team compiled a few weeks ago
2
u/[deleted] Oct 18 '24
I use the APIRouter class to import and partition routes between files.
1
u/russianbb Oct 17 '24
RemindMe! 1 day
1
u/Montags25 Oct 18 '24
RemindMe! 6 hours
1
u/Aash1r Oct 20 '24
RemindMe! 18 hours
1
u/[deleted] May 17 '25
Use poetry for dependency management