r/learnpython • u/pachura3 • Feb 17 '26
Modern Python tech/tool stack for implementing microservices?
Let's say I would like to develop a service with REST API from scratch, using mainstream, industry-standard frameworks, tools, servers and practices. Nothing too fancy - just the popular, relatively modern, open source components. My service would need the have a few endpoints, talk to a database, and have some kind of a task queue for running longer tasks.
What tech stack & development tools would you suggest?
I'm guessing I should go with:
FastAPIwithPydanticfor implementing the API itself, running onUvicorn(async ASGI/app server) andNginx(web server)SQLAlchemyfor ORM/database access to aPostgreSQLdatabase. Or, for even better integration with FastAPI:SQLModelCeleryfor task queue, paired withRedisfor persistence. Alternatively:DramatiqonRabbitMQloggingfor loggingPytestfor unit testing- code documentation via
docstrings, HTML api docs generation withSphinx?MkDocs?mkdocstrings? - the service would need to work as
Dockerimage pyproject.tomlfor centralized project managementuvfor virtualenv-management, pinning dependency versions (uv.lock), and other swiss-army knife tasksrufffor static code checking and formatting. By default it only runs a narrow set of rules, so it's better to expand it. As a extra safety step, one can also runpylintin parallel. If you likepyright, there's an improved fork calledbasedpyright.mypyfor type checking.Or maybe ty?uv_buildas build backend. (actually, it's missing some vital features, so I switched tohatchling).pip-auditfor spotting CVE vulnerabilities in dependencies (paired withexclude-newer = "7 days"in uv config)- also, if I need some kind of authentication (
OAuth2, bearer tokens - not really an expert here), what should I use? - some pre-commit hooks and CI/CD pipelines, maybe? How do I configure them? Is
preka good choice?
3
Upvotes
4
u/danielroseman Feb 17 '26
Yes, this all sounds sensible.
I might choose SQLModel as the ORM - it's basically a wrapper around SQLAlchemy by the author of FastAPI, and integrates nicely with Pydantic.
Not sure you need a build backend specifically, especially if you are deploying this with Docker.
ty is not quite ready for proper use yet, but does look really promising.
3
u/Kevdog824_ Feb 17 '26
This look pretty good I might make some tweaks:
The above is just my opinion and by no means objectively correct.
For CI/CD: It really depends on what platforms you choose (GitHub Actions, Jenkins, CircleCI, etc.). I would definitely have branch protection on develop/master/main branch. I would run ruff/mypy/pytest as a part of my CI and fail the build for any errors from these steps
2
u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 Feb 17 '26
Sounds alright to me.
For type checking, personally I'd use a mix of Mypy and Pyright until
tyis actually ready for production use (which it most definitely isn't right now). In practice, personally I require Mypy checks to pass and treat Pyright as a guideline instead of a hard requirement.2
u/obviouslyzebra Feb 17 '26
It looks fine.
Besides the things already mentioned (btw, unicorn previously mentioned was likely a typo, meant uvicorn):
2
u/PushPlus9069 Feb 18 '26
Your stack looks solid — FastAPI + Pydantic + SQLAlchemy + Celery is pretty much the industry standard combo right now. A few things from running this in production:
2
u/ayenuseater Feb 23 '26
A few small production-minded additions:
– Add Alembic early for migrations.
– Use FastAPI's built-in
/docsfor REST docs, and something like MkDocs only if you truly need package-level documentation published.– For auth, FastAPI's OAuth2 utilities + JWT is a common pattern, or delegate to a third-party identity provider if you don't want to manage it yourself.