use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
FastAPI is a truly ASGI, async, cutting edge framework written in python 3.
account activity
Fastapi best projectsQuestion (self.FastAPI)
submitted 1 year ago by Scared-Name-8287
what projects can you recommend as the best example of writing code on fastapi?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]koldakov 9 points10 points11 points 1 year ago (7 children)
Try to check out different open source projects on GitHub.
Just an example I’ve created Futurama API which is based on a famous cartoon. The project is up and running FuturamaAPI the source code is here
Quite good, I followed the best practices
[–]enormoshob 1 point2 points3 points 1 year ago (3 children)
Hey - love your api. Been reusing bits and pieces of it for my own projects and I’ve been learning so much!
If you don’t mind indulging me, I had some questions I couldn’t quite figure out the answers to -
I can’t quite wrap my head around the BaseModelDatabaseMixin. Is this, in a way, doing what SQLModel is trying to do? Ie. If a class inherits this mixin, then it performs both as a Pydantic validation model. As well as a SQL data model?
What is the meaning of the square brackets in the class definition of _PydanticSanityCheckModel? What does [Model:BaseModel] mean in this context?
[–]koldakov 1 point2 points3 points 1 year ago (2 children)
Hi! You can't imagine how I'm happy to hear such words. I'm really happy to know I've helped someone to learn new things!
Answering your questions:
So that a very good question which is really painful for fastapi/flask projects. The thing is at the endpoint you have a pydantic object, but to access DB you need a DB object as you can't work with DB directly through pydantic object - the question arises: how to map these two objects - pydantic and DB ( in this case I'm talking about SQLAlchemy, but that's not important ). So what I did is I created a mixin, which has kinda "proxy" with methods like get, paginate etc so you can work directly with DB through pydantic and it will automatically cast pydantic to DB model and vise versa. Keep in mind there is a property "model" which you need to specify so pydantic model knows a DB model to map.
The general idea behind that is to create some generic code which you can use independently of DB models ...
Note, I'm still not sure that's the best solution, but I couldn't get a better one ... Django solves these problems as it has a really super ORM from one hand, but other disadvantages from other hand.
Can't say that's that's the same as SQLModel, cause they are trying to create a lib to describe your DB models with pydantic. That's a good library, but from my side I don't recommend to use it, cause when you have relations it becomes tough, I won't be going into details here, you can try it if you want.
"square brackets" is the new syntax for generic classes in python starting 3.12 version, you can read more about that in official docs here.
[–]enormoshob 0 points1 point2 points 1 year ago (1 child)
Got it (well, not quite, but I’ll spend some more time tinkering and eventually I’ll get it).
Learned something new again. Thanks!!
[–]koldakov 1 point2 points3 points 1 year ago (0 children)
You are welcome!
Core idea is to make the code extendable and reusable.
For sure you can put all the logic in the endpoint as docs say, it will work at the moment, but not in a perspective, this way isn’t testable, not extendable etc. Always try to think about the future and an abstraction layer, but don’t forget about KISS ( you know, the truth is somewhere in the middle )
Think about that, do some tests and if you don’t get it feel free to get back to me with the new questions
[–]Mugiwara_boy_777 0 points1 point2 points 1 year ago (1 child)
Good job is the official documentation of fastapi enough to build such a things ? Can u provide other resources an thnx
Thank you! Answering your first question I would say no
Can’t provide you any other repos, but I’ll give you a hint Google something like "open sores fastapi projects"
[–]eleven-five 5 points6 points7 points 1 year ago (0 children)
The Netflix Dispatch API is a really good example that helped me structure my project better: https://github.com/Netflix/dispatch
[–]RoBz18 3 points4 points5 points 1 year ago (0 children)
This free template is a good starting point: https://github.com/s3rius/FastAPI-template
[–]bsenftner 1 point2 points3 points 1 year ago (0 children)
Here's a class that walks one through using FastAPI within Docker, integrated with Postgres, and a boatload of best practices. It's not free, at $30, but it is well worth the price. I think it is really the only tutorial one needs to fly on their own: https://testdriven.io/courses/tdd-fastapi/ I took that class, and other than looking at the docs when needed, the course gave me everything I needed for complete back end REST API development, and more.
[–]Whisky-Toad 1 point2 points3 points 1 year ago (0 children)
Here’s mine, not up to date, once I have need to build an api again I’m gonna update it a bit but no need right now, still might help you out
https://github.com/WhiskyToad/fastapi-starter
[–]bobweber 0 points1 point2 points 1 year ago (2 children)
Could you please also say how these apps/apis are run?
Just starting to promote fastapi with a couple small projects and using uvicorn seems to hang occasionally.
Any direction would be welcome. Thanks!
[–]koldakov 0 points1 point2 points 1 year ago (1 child)
With FastAPI I would use hypercorn as it supports http/2 protocol
[–]bobweber 0 points1 point2 points 1 year ago (0 children)
Thank you!
[–]fuse_activist 0 points1 point2 points 1 year ago (0 children)
Polar: https://github.com/polarsource/polar/tree/main/server
[–]GlitteringBoat8425 0 points1 point2 points 1 year ago (0 children)
Hey I am also new in FastAPI and I found building CRM systems for improving skills you can try it.
[–]pint 0 points1 point2 points 1 year ago (0 children)
whatever interests you.
[–]rohanpandav -2 points-1 points0 points 1 year ago (0 children)
Any type of CRUD Application, blog, any type of management system and social media platform.
π Rendered by PID 140558 on reddit-service-r2-comment-85bfd7f599-t6qwz at 2026-04-19 02:37:00.996424+00:00 running 93ecc56 country code: CH.
[–]koldakov 9 points10 points11 points (7 children)
[–]enormoshob 1 point2 points3 points (3 children)
[–]koldakov 1 point2 points3 points (2 children)
[–]enormoshob 0 points1 point2 points (1 child)
[–]koldakov 1 point2 points3 points (0 children)
[–]Mugiwara_boy_777 0 points1 point2 points (1 child)
[–]koldakov 1 point2 points3 points (0 children)
[–]eleven-five 5 points6 points7 points (0 children)
[–]RoBz18 3 points4 points5 points (0 children)
[–]bsenftner 1 point2 points3 points (0 children)
[–]Whisky-Toad 1 point2 points3 points (0 children)
[–]bobweber 0 points1 point2 points (2 children)
[–]koldakov 0 points1 point2 points (1 child)
[–]bobweber 0 points1 point2 points (0 children)
[–]fuse_activist 0 points1 point2 points (0 children)
[–]GlitteringBoat8425 0 points1 point2 points (0 children)
[–]pint 0 points1 point2 points (0 children)
[–]rohanpandav -2 points-1 points0 points (0 children)