Skip to content

The engine behind PRUNplanner.org, the comprehensive empire and base planning tool.

License

Notifications You must be signed in to change notification settings

PRUNplanner/backend

Repository files navigation

PRUNplanner Backend

The engine behind PRUNplanner.org, the comprehensive empire and base planning tool.


While the Frontend handles all your planning, this backend is the "brains of the operation". It provides a robust REST API for orchestrating all your planning, empire building and market data needs.

🚀 Features

  • Comprehensive Game-Data Mapping: Deep integration with FIO providing an accurate database of all in-game planets, materials, recipes, and buildings for high-fidelity planning.
  • Market Intelligence: CXPC data synchronization with automated VWAP and trading datapoint calculations for pinpoint pricing accuracy across all operations.
  • Persistent Empire & Plan Storage: Robust backend for managing complex multi-plan configurations and user-specific CX preferences.
  • Unified Auth & User Management: Secure handling of user profiles and preferences via a multi-tier authentication system supporting BasicAuth, JWT, and persistent API Tokens.
  • Asynchronous Data Synchronization: High-performance task workers that continuously fetch and update site, warehouse, ship, and storage data to mirror live in-game states.
  • High-Efficiency REST API: Clean, stateless endpoints featuring minimized payload serialization to ensure lightning-fast response times and low bandwidth overhead.

Stack

  • Python 3.12
  • Django with Django Rest Framework
  • Celery for task orchestration
  • Redis as cache and Celery backend
  • PostgreSQL database
  • Resend to handle communications via email

🛠 Developer Setup

Docker

You can run the backend locally with Docker / Docker Compose with the entrypoint.sh ensuring migrations did run. This will start a PostgreSQL database, Redis, the Django backend as well as a Celery worker. There won't be any game data, but the admin interface allows to import it easily.

To create yourself a local superuser for Django, run the following command:

docker compose exec backend uv run backend/manage.py createsuperuser

Console

PRUNplanner uses uv for Python 3.12 package and virtual environment management. See uv installation documentation on how to get started.

Run in terminal if you have PostgreSQL database and Redis instance available and configured in the .env file or start them separately and point the Django towards it.

# Install packages
uv sync

# Django
uv run backend/manage.py runserver

# Celery Worker + Beat
uv run --env-file .env celery -A core --workdir=backend worker -l INFO
uv run --env-file .env celery -A core --workdir=backend beat -l INFO  --scheduler django_celery_beat.schedulers:DatabaseScheduler

Via overmind and Procfile

Packages must be installed and available as overmind executes multiple uv run command in separate processes. Create yourself a Procfile and use the following commands. Database and Redis must be available and defined in your .env file.

web: uv run backend/manage.py runserver
worker: uv run --env-file .env celery -A core --workdir=backend worker -l INFO
beat: uv run --env-file .env celery -A core --workdir=backend beat -l INFO  --scheduler django_celery_beat.schedulers:DatabaseScheduler
# start all
overmind start

# start dedicated processes
overmind start -l web,worker,beat

# to restart, send from another terminal in that folder
overmind restart

About

The engine behind PRUNplanner.org, the comprehensive empire and base planning tool.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages