Hey everyone! I’m trying to pick the right Python framework for my new project. It’s going to be a CRUD app with an ORM and some chatbot functionality using LLMs. I’ll be using Next.js for the frontend, so I just need a Python API layer.
I’ve been considering these options:
Django Ninja - It looks promising, but I’m concerned about having only one maintainer and a growing list of issues.
FastAPI - I started with this, but now I’m unsure which ORM to adopt. Are SQLModel, Tortoise, or SQLAlchemy as reliable as Django’s ORM?
Django with DRF - This is the classic choice, although I’ve heard it might have issues with async support for LLMs and handling external HTTP requests.
I’ll also be querying data from BigQuery as the app scales. Has anyone used these frameworks for similar projects? Additionally, I’ve come across mentions of Litestar + SQLAlchemy. How does that compare to the options above?
I’ve been using FastAPI extensively for API-focused backends, and it’s been a solid choice. The performance is excellent, and the automatic OpenAPI documentation is a huge time-saver. For ORMs, I’ve had great success with SQLAlchemy. It’s mature, well-maintained, and integrates seamlessly with FastAPI.
One advantage of FastAPI is its native async support, which should work well for your LLM integration. As for BigQuery, there are Python clients available that work nicely with FastAPI’s async paradigm.
While Django is robust, I found it a bit heavyweight for pure API projects. FastAPI’s simplicity and speed make it more suitable for your use case, especially when paired with Next.js on the frontend. Just ensure you’re comfortable with dependency injection and ASGI concepts, as they’re central to FastAPI’s design.
As someone who’s worked on several API-focused projects, I can vouch for FastAPI. It’s been my go-to for the past couple of years, and it’s never let me down. The speed and ease of use are unmatched, especially for CRUD operations.
For the ORM, I’d recommend sticking with SQLAlchemy. It’s battle-tested and works like a charm with FastAPI. I’ve used it to handle complex queries and it scales well, which should be perfect for your BigQuery integration down the line.
One thing to keep in mind - while FastAPI is great, there’s a bit of a learning curve if you’re coming from Django. The dependency injection system takes some getting used to, but once you grasp it, it’s incredibly powerful.
For your LLM functionality, FastAPI’s async support is a godsend. It handles concurrent requests smoothly, which is crucial when dealing with potentially slow LLM operations.
Just a word of caution - make sure you’re comfortable with managing your own project structure. FastAPI gives you a lot of freedom, which is great, but it also means you need to be disciplined about organizing your code as your project grows.
fastapi’s been my go-to for api projects lately. it’s quick to set up and handles async stuff well, which is great for llms. SQLAlchemy’s solid for the orm - reliable and flexible.
Django’s good but can be overkill for just apis. fastapi+SQLAlchemy combo works great with BigQuery too.
just be ready to structure your project yourself. it’s not as opinionated as django.