This project is based on a blog post where I talk about the concept of using code to design an API. For this example, I use FastAPI as the web framework and Pydantic for the models. This lets me write terse Python code and get OpenAPI and an API with it.
I've separated the code into different layers.
- Core models (domain layer)
- Data models (database layer)
- Resource models (API layer)
This is similar to a Hexagonal Architecture, Onion Architecture, or Functional Core, Imperative Shell.