This repository contains the Gyrinx Django application - a gang management tool
for Necromunda. The code for this application is in the gyrinx
directory.
📚 Full Documentation - Technical overview, architecture, and development guides.
Before getting started, you'll need:
- Python 3.12+ - Use pyenv to manage versions
- Docker with Compose - For the database
- Git - For version control
# Clone and enter the repository
git clone [email protected]:gyrinx-app/gyrinx.git && cd gyrinx
# Set up Python environment
python -m venv .venv && . .venv/bin/activate
pip install --editable .
# Configure the application
manage setupenv
# Set up frontend toolchain
nodeenv -p && npm install && npm run build
# Start the database and run migrations
docker compose up -d && manage migrate
# Run the application
manage runserverVisit http://localhost:8000 to see the application.
There's a devcontainer configured in this repo which should get you up and running too, perhaps via a Codespace.
The Django manage.py file (in scripts/) is added to your shell by
setuptools, so you can just use manage from anywhere:
manage shellThe Quick Start above gets you running fast. For more detailed steps:
-
Clone the repository:
git clone [email protected]:gyrinx-app/gyrinx.git cd gyrinx
-
Make sure you're using the right Python version:
python --version # should be >= 3.12If you use
pyenv, we have a.python-versionfile. If you have pyenv active in your environment, this file will automatically activate this version for you. -
Create and activate a virtual environment:
python -m venv .venv && . .venv/bin/activate
-
Install the project in editable mode so you can use the
managecommand:pip install --editable .setuptoolswill handle installing dependencies. -
You should then be able to run Django
managecommands. This one will set up your.envfile:manage setupenv
With that run, you'll have a
.envfile with a random and uniqueSECRET_KEYandDJANGO_SUPERUSER_PASSWORD:cat .env
-
Next, set up the frontend toolchain:
Get
nodeenv(installed bypipearlier) to install node and npm in the virtual env.nodeenv -p
Check it has worked (you might need to
deactivatethen. .venv/bin/activate):which node # should be /path/to/repo/.venv/bin/node which npm # should be /path/to/repo/.venv/bin/npm
-
Install the frontend dependencies:
npm install
-
Build the frontend:
npm run build
-
Install the pre-commit hooks:
Before making any changes, make sure you've got pre-commit hooks installed.
pre-commitis installed by pip.pre-commit install
-
Make sure your virtual environment is active &
piphas up-to-date dependencies:. .venv/bin/activate pip install --editable .
-
Start the database (Postgres) and pgadmin:
docker compose up -d
-
Run the migrations:
manage migrate
-
Run the application:
manage runserver
You can also run the application itself within Docker Compose by passing
--profile app, but this will not auto-reload the static files.
The Python toolchain installs nodeenv which is then used to install node and
npm so we have a frontend toolchain.
To continuously rebuild the frontend (necessary for CSS updates from SASS):
npm run watchTo run the test suite, we also use Docker (so there is a database to talk to):
./scripts/test.shFor faster test execution using parallel workers:
./scripts/test.sh --parallel
# or
./scripts/test.sh -pYou can also run tests directly with pytest for more control:
# Run tests in parallel (requires pytest-xdist)
pytest -n auto
# Run tests with database reuse (faster for repeated runs)
pytest --reuse-db
# Combine both for maximum speed
pytest -n auto --reuse-dbYou can also use the pytest-watcher:
ptw .To create a new empty migration file for doing data migration:
manage makemigrations --empty contentYou can debug the SQL that Gyrinx is running using the Django Debug Toolbar that is installed.
You can also enable SQL logging by setting the SQL_DEBUG variable:
SQL_DEBUG=True
To test Gyrinx locally, you are really limited unless you have the content library data available. This is because the content library is what provides the data for the Gyrinx application to work with.
The content library is managed by the Gyrinx content team in production, and is what makes Gyrinx useful.
Gyrinx uses a custom-ish data export/import process to manage content library data from production, so you can test locally.
Note
This process is only available for trusted developers and admins.
- Export: Run the
gyrinx-dumpdataCloud Run job in production to export content to thegyrinx-app-bootstrap-dumpbucket - Import: Download
latest.jsonfrom the bucket and usemanage loaddata_overwrite latest.jsonto replace local content data
This process ensures we have access to the latest production content library. See docs/operations/content-data-management.md for details.