Kobold Keeper is a powerful, self-hosted API designed to manage and automate dice-rolling tasks for role-playing game (RPG) sessions, focusing primarily on game master (GM) utility. It serves as a backend hub for various tools, allowing GMs to centralize data, run complex dice rolls, and review dice rolling statistics per group, character or even globally.
This project is built with Python and Django Rest Framework (DRF), offering a robust, secure, and scalable foundation for your digital tabletop needs.
- Advanced Dice Roller: Supports complex algebraic expressions, drop/keep logic, and modifiers (e.g., 3d6 + 5, 2d20kh1, 1d8 + 5d6 + 4).
- Roll analytics: Allows users to review their past and present rolls in terms of raw dice breakdown, averages and comparisons versus statistical averages of the standard dice type.
- Secure User Management: Full authentication and authorization via Django's built-in system and JWT.
- Asynchronous Tasks (Celery): Handles long-running or resource-intensive tasks, such as large data exports or complex simulations, without blocking the main API thread.
To run Kobold Keeper locally for development, you'll need Docker and Docker Compose. This setup ensures all dependencies (PostgreSQL database, Redis cache, Celery worker, and Celery Beat scheduler) are managed easily using the docker-compose.dev.yml file.
- Docker and Docker Compose installed on your system.
- A .env file created in the project root (see ExampleEnv for structure).
git clone \[https://github.com/Pooch41/kobold-keeper-api.git\](https://github.com/Pooch41/kobold-keeper-api.git)
cd kobold-keeper-api
Copy the example environment file. This new .env file is already in .gitignore and will never be committed.
cp example.env .env
Execute the following command to build the Docker images and start all services (api, worker, beat, db, redis) in detached mode.
docker-compose \-f docker-compose.dev.yml up \--build \-d
The API will be available @ http://localhost:8000.
API Schema (Swagger UI): http://localhost:8000/api/schema/swagger-ui/
In a separate terminal, run this command to create your local admin account:
docker-compose \-f docker-compose.dev.yml exec api python manage.py createsuperuser
This project uses a two-file system for safe, repeatable deployments.
docker-compose.dev.yml: Used locally to build and push images.docker-compose.yml: Used remotely (on your server) to pull and run images.
After making code changes, you must build the new, secure images and push them to Docker Hub. The .dockerignore file ensures your final images are small and secure (no .env, testing/, or .git files are included).
docker login \--username {your_username}
docker-compose \-f docker-compose.dev.yml build
docker-compose \-f docker-compose.dev.yml push
SSH into your AWS server and run the following commands. These use the server's docker-compose.yml file.
cd /path/to/your/project
docker-compose \-f docker-compose.yml pull
docker-compose \-f docker-compose.yml down
(This will automatically run migrations first)
docker-compose \-f docker-compose.yml up \-d
docker-compose \-f docker-compose.yml exec api python manage.py collectstatic \--noinput
docker image prune
The project uses Pytest for unit and integration testing. Tests are run inside the running api container.
While your local stack is running, open a second terminal and run:
docker-compose \-f docker-compose.dev.yml exec api pytest
The application uses Celery for background processing.
- Worker: The worker service executes tasks asynchronously.
- Beat: The beat service is the scheduler that polls the database for periodic tasks.
To monitor the activity of all services:
docker-compose \-f docker-compose.dev.yml logs \-f
| File | Description |
|---|---|
| api/ | Main Django app for views, serializers, and models. |
| kobold_keeper/ | Core Django project settings, URLs, and Celery setup. |
| testing/ | All pytest and unittest files. |
| Dockerfile | The single, multi-stage build recipe for all app images. |
| docker-compose.dev.yml | Local: Runs the full stack (app, db, redis) and builds images. |
| docker-compose.yml | Remote: Runs the app services only (pulls images). |
| .dockerignore | Security: Prevents secrets, tests, and git history from being built into images. |
We welcome contributions! As an open-source project, your help is invaluable.
- Fork the repository and clone your fork.
- Create your feature branch (git checkout -b feature/new-dice-logic).
- Commit your changes (git commit -am 'Refactor: Improved logic').
- Create a new Pull Request to the main development branch.
We enforce strict quality checks using Pylint. Before submitting a pull request, please ensure your changes pass the quality checks:
docker-compose \-f docker-compose.dev.yml exec api pylint kobold\_keeper api
Kobold Keeper API is released under the MIT License. See the LICENSE file for more details.