Awesome
hexagonal-architecture-python
This project was created as an example for my blog post https://blog.szymonmiks.pl/p/hexagonal-architecture-in-python/
I encourage you to read the article first before checking the code.
This is for educational purposes only and the code is not production-ready.
Intro
I created a project that uses FastAPI and follows the hexagonal architecture rules.
This project is a simplified gym management software. We have such functionalities like:
- Gym Clients
- create a gym client
- change client's personal data
- archive a client
- export all clients as a CSV or JSON file to S3 or Dropbox storage
- Gym Passes
- create a gym pass
- pause a gym pass
- renew a gym pass
- check if gym pass is active
- Gym Classes (CRUD)
- create a gym class
- delete a gym class
- modify a gym class
- list all gym classes sorted by time and day of the week
Project structure
Stack
- Python 3.10
- FastAPI
- MongoDB
Prerequisites
Make sure you have installed all the following prerequisites on your development machine:
Setup
- Install dependencies:
$ poetry install
- Setup pre-commit hooks before committing:
$ poetry run pre-commit install
Running app locally
- In the main project's directory create a new
.env
file and copy all variables fromexample.env
there. - Run
docker-compose up -d
- Go to
src/app.py
and run the app
Tests
$ poetry run pytest
or
$ make tests