Simple FastAPI application that manages Minecraft items. This time I wanted to build the project around MongoDB database and Beanie ORM. For more information about the code structure please visit my another Minecraft-related FastAPI project, Monster Spawner. If you want to see how my DDD structure eventually looks like, I highly encourage to check the last microservice under this organization, Oak Signs
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 buildThen, you can just start the containers.
make upAfter that, you should be able to see the output from the FastAPI server. It will be running on port 8003, so you can access the documentation via http://localhost:8003/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 installIn case you want to avoid installing anything locally, you can enter server container and run other commands from there.
make enterTo 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 installThen you can use the following to run the hooks.
make lintThere is also a command for running tests.
make testpytest 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.