GraphQL
application powered by FastAPI
and Strawberry
. Similarly to Shulker Box
, this service uses Beanie
as the ORM in front of MongoDB. The approach is a little different here, since the app does not expose a create endpoint, but instead it consumes events from the other microservices and creates the notifications.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
To get started you need to have Docker
installed and optionally Poetry
, if you want to have virtual environment locally. All the needed commands are available via Makefile
.
First, build the images.
make build
Then, you can just start the containers.
make up
After that, you should be able to see the output from the FastAPI
server. It will be running on port 8004
, so you can access the documentation via http://localhost:8004/api/docs
.
There are also few useful commands to help manage the project.
If you have Poetry
installed, you can run below command to have all the dependencies installed locally.
make install
In case you want to avoid installing anything locally, you can enter server container and run other commands from there.
make enter
To make development smoother, this project supports pre-commit
hooks for linting and code formatting along with pytest
for testing. All the configs can be found in .pre-commit-config.yaml
and pyproject.toml
files.
To install the hooks, run the following command.
pre-commit install
Then you can use the following to run the hooks.
make lint
There is also a command for running tests.
make test
pytest
is configured to clean the database after every test. Tests are also using different sessions to have a clean separation. You can check more fixtures in the conftest.py
file, or the general configuration in the pytest.ini
section.