Our great sponsors
FastAPI Best Practices and Conventions we used at our startup
Full stack, modern web application generator. Using FastAPI, PostgreSQL as database, Docker, automatic HTTPS and more.
I would encourage you to take a look at this repo: https://github.com/tiangolo/full-stack-fastapi-postgresql This is a boilerplate of an application made with fastapi, prepared by the creator of the fastapi himself. You can even set it up yourself locally and have a look how it’s organised. I know it has a lot of different services included, but I find the fastapi part itself to be well thought. Inside the api directory you can notice another folder named api_v1, so you can have multiple versions of your API routes when needed, with the general code in other places that is more generic and can be reused in all your different API versions. The schemas are separated from the models and models itself have different classes depending on what you would actually like to do with the data. The migrations are managed with alembic based on schemas rather than models itself. The settings are a python class that implicitly reads the .env file in your project’s directory. And many, many other interesting patterns to explore. Too much to write in one comment to be honest.
Write Clean Python Code. Always.. Sonar helps you commit clean code every time. With over 225 unique rules to find Python bugs, code smells & vulnerabilities, Sonar finds the issues while you focus on the work.
A framework for managing and maintaining multi-language pre-commit hooks.
The last suggestion is down at the bottom you have to use linters. I would recommend adding pre-commit hooks to run those linters. You'll still need to include linters in your CICD pipeline, but if you can setup a pre-commit config and include it in the readme's development instructions, people can catch these issues before they make the initial commit and before wasting CICD cycles. This tip is more for structured organizations - when we onboard a new developer, we pretty much make it one of their first tasks to setup their environment, then make a useless change and merge request so they can validation the pre-commit linters, the pipeline, etc. The MR/PR itself will get closed, but should provide a view of the process.
FastAPI framework, high performance, easy to learn, fast to code, ready for production
Regarding 16. I had lots of issues with Background Tasks when using Middleware. As in https://github.com/tiangolo/fastapi/issues/3859. Has this been fixed? Doesn't look like it
Is there any open source project that uses FasAPI?
8 projects | reddit.com/r/FastAPI | 25 Apr 2023
How to build a scalable project file structure for a beginner.
3 projects | reddit.com/r/FastAPI | 10 Mar 2023
Creating a webpage for data entry
1 project | reddit.com/r/learnpython | 28 Jan 2023
migrating a LARGE flask api to kotlin+spring boot. any advice ?
1 project | reddit.com/r/Kotlin | 16 Jul 2022
Ask HN: I just got my first job and I need to learn faster and better
1 project | news.ycombinator.com | 8 Mar 2022