Python and FastAPI for Spring Boot Engineers
This is an introductory guide to help you transition from Java and Spring Boot to Python and the Python equivalents to Spring Boot.
Part 1: the basics.
- Set up a modern Python project: the uv toolchain, mapped from Maven and Gradle.
- Map the Java language to Python: types, records, pattern matching, collections, Streams, exceptions, and resources.
- Structure and test your code: packages, imports, and pytest, mapped from Maven modules and JUnit.
Part 2: what Spring Boot provides.
- Replace Spring Boot's conveniences: dependency injection, configuration, validation, and persistence, each mapped to a Python library.
Part 3: from Spring Web to FastAPI.
- Build a REST API with FastAPI: controllers, DTOs, parameters, injection, and exception handling.
- Add persistence and run the service: SQLAlchemy wired into FastAPI, async handlers, and running the app.
Before you start
You'll need a working terminal and permission to install software. Everything installs through uv, so you don't need a system Python first.