tinytechbureau.com/content/blog/api-design-and-frameworks.md
2024-07-15 16:16:08 +02:00

47 lines
2.1 KiB
Markdown

---
title: "Python developer's introduction to designing an API and choosing your framework(s)"
date: 2024-06-30T09:00:00-07:00
draft: true
tags:
- "django"
- "FastAPI"
---
This article is written for anyone currently evaluating how to choose an API Framework (FastAPI, django-ninja etc.) and wondering how to setup a project from scratch, using SQLAlchemy or Django for ORM.
We're focusing on choice and preferences. The objective is to make something that's confusing/annoying/energy-draining feel more comfortable and go from frozen 🥶 to cruising 🚄.
Ingredients:
1. Open up your own design doc/enhancement proposal and start writing
2. Establish your method
3. Choose components for evaluation
4. tl;dr Conclusion
One of the reasons why it's good to have this approach, is that most ORMs and API frameworks can be decoupled. But it's good to narrow down your search from the beginning. If you already have a strong preference for SQLAlchemy or Django, you should be comfortable with that choice.
## The method
At the beginning, you should decide what criteria are important for your project:
* Do you want to build a prototype?
* Should others from your team participate in the evaluation?
* What should be the final outcome?
In my experience, it's worked great to do the following:
* An evaluation of any current setup and needs together with others from the team.
* Opening a draft design doc to capture all decisions and observations.
* Writing prototypes and doing small demos.
## Components for evaluation
## More resources
## Our findings
* You will have to do more work with SQLAlchemy and FastAPI. For instance, database session management, migrations, test rollbacks etc. We didn't identify any benefits of having this control.. it seems to just add work. These things are built into Django for good reasons.
* Async support is definitely a strength of FastAPI. However, whether that is actually of value is highly dependent on the problem being solved, as the async structures may be perceived as a negative impact on readability, adding efforts to development and testing.