Based on Domain-Driven Design and Event-Driven architecture, and using the following technologies
- web framework: Connexion
- server workers: Gunicorn with Uvicorn worker
- ORM: SQLAlchemy
- database migration tool: Alembic
- message queue: pika
- python: version >=
3.11 - pyenv: https://github.com/pyenv/pyenv
- pyenv-virtualenv: https://github.com/pyenv/pyenv-virtualenv
pyenv virtualenv new-service
pyenv activate new-service
pip install pip wheel setuptools -U
pip install -r requirements_local.txtcd /path/to/new-servicepython /path/to/ddd-service-example/copy_tool.py initpip install -r requirements.txt -r requirements_local.txt -r requirements_test.txt- update setting in
app/config.pydatabase_urlpostgres_schemarabbitmq_exchange_namerabbitmq_consumer_name
python /path/to/ddd-service-example/copy_tool.py add bounded_context_name- start coding
- value object
- event
- entity
- use case
- orm
- repository
- controller
- event handler
- handler
- swagger (openapi)
python /path/to/ddd-service-example/copy_tool.py add_message_queue_handler exchange_name- start coding
- payload
- exchange handler
app/message_queue_consumer.py
- use
database_username,database_passwordinapp/config.pyto create local PostgreSQL database
# if database_username is `postgres`
brew install postgresql@15
brew services start postgresql@15
createuser -P -d postgres
createdb -O "postgres" defaultmake build-migration message='migration message'make migrate-database
docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 -e RABBITMQ_DEFAULT_USER=root -e RABBITMQ_DEFAULT_PASS=1234 rabbitmq:management
- server:
make local-run - mq consumer:
make local-run-consumer
- select the Debugging icon > Run and Debug