strat-gameplay-webapp/backend
Cal Corum 38fb76c849 CLAUDE: Fix resolution phase control and add demo mode
Bug fix: During resolution phase (dice rolling), isMyTurn was false
for both players, preventing anyone from seeing the dice roller.
Now the batting team has control during resolution since they read
their card.

Demo mode: myTeamId now returns whichever team needs to act,
allowing single-player testing of both sides.

Changes:
- Add creator_discord_id to GameState (backend + frontend types)
- Add get_current_user_optional dependency for optional auth
- Update quick-create to capture creator's discord_id
- Fix isMyTurn to give batting team control during resolution
- Demo mode: myTeamId returns active team based on phase

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 23:47:21 -06:00
..
.claude CLAUDE: Add configurable regulation_innings and outs_per_inning 2025-11-19 20:06:57 -06:00
.git-hooks CLAUDE: Fix all unit test failures and implement 100% test requirement 2025-11-04 19:35:21 -06:00
alembic CLAUDE: Add Alembic migrations and database session injection 2025-11-28 12:09:09 -06:00
app CLAUDE: Fix resolution phase control and add demo mode 2026-01-13 23:47:21 -06:00
scripts CLAUDE: Add test game creation utilities 2025-11-19 16:30:29 -06:00
terminal_client CLAUDE: Fix RunnerAdvancementData tuple unpacking regression 2025-11-28 23:11:26 -06:00
tests CLAUDE: Load play history on mid-game join via game_state_sync 2025-11-28 12:38:56 -06:00
.dockerignore CLAUDE: Fix Docker build for UV migration 2025-11-04 09:19:30 -06:00
.env.dev CLAUDE: Improve UX with single-click OAuth, enhanced games list, and layout fix 2025-12-05 16:14:00 -06:00
.env.example CLAUDE: Implement server-side OAuth flow with HttpOnly cookies 2025-11-26 22:16:30 -06:00
.env.prod CLAUDE: Improve UX with single-click OAuth, enhanced games list, and layout fix 2025-12-05 16:14:00 -06:00
.gitignore CLAUDE: Add pages/ to backend gitignore 2025-11-20 23:57:25 -06:00
alembic.ini CLAUDE: Add Alembic migrations and database session injection 2025-11-28 12:09:09 -06:00
CLAUDE.md CLAUDE: Add multi-domain environment configuration support 2025-12-03 13:58:42 -06:00
clean_test_data.py CLAUDE: Refactor game models and modularize terminal client 2025-10-28 14:16:38 -05:00
docker-compose.yml CLAUDE: Complete Phase 1 backend infrastructure setup 2025-10-21 19:46:16 -05:00
Dockerfile CLAUDE: Fix Docker build for UV migration 2025-11-04 09:19:30 -06:00
mypy.ini CLAUDE: Refactor GameEngine to forward-looking play tracking pattern 2025-10-25 22:18:15 -05:00
pyproject.toml CLAUDE: Replace black and flake8 with ruff for formatting and linting 2025-11-20 15:33:21 -06:00
pyrightconfig.json Clean up false positive Pylance errors 2025-10-23 09:10:41 -05:00
pytest.ini CLAUDE: Complete Week 4 - State Management & Persistence 2025-10-22 12:01:03 -05:00
README.md CLAUDE: Update documentation across codebase 2025-11-28 12:10:10 -06:00
requirements-dev.txt CLAUDE: Complete Phase 1 backend infrastructure setup 2025-10-21 19:46:16 -05:00
requirements.txt CLAUDE: Add interactive terminal client for game engine testing 2025-10-26 12:51:01 -05:00
TEST_COVERAGE_SUMMARY.md CLAUDE: Phase 2 test infrastructure + comprehensive documentation 2025-11-05 12:39:32 -06:00
test_db_playground.py Add scripts to test models in dev database 2025-10-23 09:10:55 -05:00
test_pd_api_live.py CLAUDE: Phase 3E-Main - Position Ratings Integration for X-Check Resolution 2025-11-03 21:00:37 -06:00
test_pd_api_mock.py CLAUDE: Phase 3E-Main - Position Ratings Integration for X-Check Resolution 2025-11-03 21:00:37 -06:00
test_redis_cache.py CLAUDE: Phase 3E-Final - Redis Caching & X-Check WebSocket Integration 2025-11-03 22:46:59 -06:00
uv.lock CLAUDE: Replace black and flake8 with ruff for formatting and linting 2025-11-20 15:33:21 -06:00

Paper Dynasty Backend

FastAPI-based real-time baseball game engine with WebSocket support.

Quick Start

# Install UV
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install dependencies
uv sync

# Apply database migrations
uv run alembic upgrade head

# Run server
uv run python -m app.main

Database Migrations

This project uses Alembic for database schema migrations.

Initial Setup (New Database)

# Apply all migrations to create schema
uv run alembic upgrade head

Creating New Migrations

# Auto-generate from model changes
uv run alembic revision --autogenerate -m "Description of changes"

# IMPORTANT: Always review the generated migration before applying!
# Then apply:
uv run alembic upgrade head

Viewing Migration Status

# Show migration history
uv run alembic history

# Show current revision
uv run alembic current

Rolling Back

# Rollback one migration
uv run alembic downgrade -1

# Rollback to specific revision
uv run alembic downgrade 001

# Rollback all (dangerous!)
uv run alembic downgrade base

Migration Best Practices

  1. Always review auto-generated migrations before applying - autogenerate is helpful but not perfect
  2. Test migrations on dev/staging before production
  3. Keep migrations small and focused - easier to rollback
  4. Never edit migrations that have been applied to shared databases
  5. Include both upgrade and downgrade for reversibility

Existing Migrations

Revision Description
001 Initial schema (games, plays, lineups, rolls, etc.)
004 Materialized views for statistics

Documentation

See CLAUDE.md for full documentation.