The API use the Hexagonal Architecture pattern that I have explained in my blog (Ranked high in Google for hexagonal architecture in python keywords)
https://www.workflows.guru/blogs/hexagonal-architecture-implemented-in-python
Using Hexagonal Architecture in this API have many benefits:
- Separation between domain logic and external dependencies
- Easy testing: In memory classes to mock external dependencies
- Easy swapping of dependencies: Switching DB or switching Email providers requires zero domain changes
docker-compose up --build
You could visit the swagger at: http://localhost:8000/docs#
This app was tested with Python 3.13.0
To run test in docker:
docker-compose run --rm api pytest
Or in your local env
Install uv if it's not installed:
curl -LsSf https://astral.sh/uv/install.sh | sh
Run pytest
uv run pytest
or
uv venv
uv sync
uv run pytest
A lot of cool feature and enhancement could be done to make this little app production ready (list not exhaustive and some of this feature could be handled by external component like proxies, side cars ...):
- Add migration strategy
- Add Rate limiting
- Brute-force protection
- Add Observability (instrumentation for tracing and monitoring)
- Enhance logging
- Add health check