No description
  • Python 94.5%
  • Dockerfile 4.9%
  • Shell 0.6%
Find a file
McNieps e8f0386782
Some checks failed
/ deploy (push) Failing after 5s
Separate DB credentials, remove db service from prod compose
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 18:12:53 +02:00
.forgejo/workflows Separate DB credentials, remove db service from prod compose 2026-05-12 18:12:53 +02:00
app Changed random field for battle_record and run 2026-05-03 22:03:11 +02:00
scripts Added pre-commits and doc rewriting 2026-05-04 00:25:08 +02:00
tests Cleaned repo, rename test to tests. 2026-05-03 19:46:42 +02:00
.dockerignore Initial server implementation: models, auth, aerich config 2026-05-02 23:47:28 +02:00
.env.example Added pre-commits and doc rewriting 2026-05-04 00:25:08 +02:00
.gitignore Added pytest and ruff to pipeline + small lint fixes 2026-05-03 15:18:48 +02:00
.pre-commit-config.yaml Added test to pre-commits and removed it from pipeline. 2026-05-04 00:28:43 +02:00
CLAUDE.md Added pre-commits and doc rewriting 2026-05-04 00:25:08 +02:00
docker-compose.prod.yml Separate DB credentials, remove db service from prod compose 2026-05-12 18:12:53 +02:00
docker-compose.test.yml Switch from pip to uv. Updated all modules, included tortoise 1.x (no more aerich, tortoise migrate now) 2026-05-03 17:55:04 +02:00
docker-compose.yml Initial server implementation: models, auth, aerich config 2026-05-02 23:47:28 +02:00
Dockerfile Added optional dependencies install (pytest) during the test job 2026-05-03 18:15:37 +02:00
entrypoint.sh Switch from pip to uv. Updated all modules, included tortoise 1.x (no more aerich, tortoise migrate now) 2026-05-03 17:55:04 +02:00
PLAN.md Added pre-commits and doc rewriting 2026-05-04 00:25:08 +02:00
pyproject.toml Added pre-commits and doc rewriting 2026-05-04 00:25:08 +02:00
README.md Switch from pip to uv. Updated all modules, included tortoise 1.x (no more aerich, tortoise migrate now) 2026-05-03 17:55:04 +02:00
TODO.md Added pre-commits and doc rewriting 2026-05-04 00:25:08 +02:00
uv.lock Added pre-commits and doc rewriting 2026-05-04 00:25:08 +02:00

Autobattler Server

FastAPI server for an async autobattler game. The server owns all run state — the Godot client sends actions and replays deterministic battle logs returned by the server.

Stack

  • FastAPI + Uvicorn
  • Tortoise ORM + Aerich (migrations)
  • PostgreSQL (JSONB for squad and battle log storage)
  • Steam Web API authentication → internal JWT

Prerequisites

  • Python 3.11+
  • uv for dependency management
  • Docker + Docker Compose (for local dev database)
  • The battle_engine package at ../battle_engine

Local Development

1. Install dependencies

uv sync --extra dev
uv pip install -e "../battle_engine"

Activate the venv (.venv\Scripts\activate on Windows, source .venv/bin/activate on Linux/macOS) or prefix commands with uv run.

2. Configure environment

Copy .env.example to .env and fill in values:

cp .env.example .env

Key variables:

Variable Default Notes
DATABASE_URL postgres://... Tortoise-compatible URL
JWT_SECRET Long random string
STEAM_AUTH_ENABLED true Set false to skip Steam validation in dev
STEAM_WEB_API_KEY Required when STEAM_AUTH_ENABLED=true

3. Start the database

docker-compose up -d db

4. Run migrations

aerich upgrade

5. Start the server

uvicorn app.main:app --reload

API available at http://localhost:8000. Docs at http://localhost:8000/docs.

Running Tests

pytest

Production

Run only the app container and point DATABASE_URL at your dedicated PostgreSQL instance:

docker build -t autobattler-server .
docker run -p 8000:8000 --env-file .env autobattler-server

API Overview

Method Path Description
POST /auth/steam Validate Steam ticket, receive JWT
POST /runs Start a new run
GET /runs/me/current Current run state (squad, inventory, gold, shop)
POST /runs/me/shop/buy Buy an item from the shop
POST /runs/me/equip Attach/detach rune or reorder weapons
POST /runs/me/fight Run a battle, receive BattleLog
GET /players/me Player profile and ELO
GET /battles/{id} Retrieve a past battle log