Skip to content

Minecraft items management API built with FastAPI, MongoDB and Beanie

Notifications You must be signed in to change notification settings

microcraft-alpha/shulker-box

Repository files navigation

Shulker Box

python black wemake-python-styleguide pre-commit Checked with mypy Continuous Integration

📝 Table of Contents

🧐 About

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

🏁 Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

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.

Installing

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 8003, so you can access the documentation via http://localhost:8003/api/docs.

🎈 Usage

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

🔧 Development

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.