Phase 1 Database Implementation (DB-001 through DB-012): Models: - User: OAuth support (Google/Discord), premium subscriptions - Collection: Card ownership with CardSource enum - Deck: JSONB cards/energy_cards, validation state - CampaignProgress: One-to-one with User, medals/NPCs as JSONB - ActiveGame: In-progress games with GameType enum - GameHistory: Completed games with EndReason enum, replay data Infrastructure: - Alembic migrations with sync psycopg2 (avoids async issues) - Docker Compose for Postgres (5433) and Redis (6380) - App config with Pydantic settings - Redis client helper Test Infrastructure: - 68 database tests (47 model + 21 relationship) - Async factory pattern for test data creation - Sync TRUNCATE cleanup (solves pytest-asyncio event loop mismatch) - Uses dev containers instead of testcontainers for reliability Key technical decisions: - passive_deletes=True for ON DELETE SET NULL relationships - NullPool for test sessions (no connection reuse) - expire_on_commit=False with manual expire() for relationship tests
84 lines
3.1 KiB
Plaintext
84 lines
3.1 KiB
Plaintext
# Mantimon TCG Backend - Environment Configuration
|
|
# Copy this file to .env and customize for your environment
|
|
#
|
|
# Usage:
|
|
# cp .env.example .env
|
|
# # Edit .env with your values
|
|
|
|
# =============================================================================
|
|
# ENVIRONMENT
|
|
# =============================================================================
|
|
# Options: dev, staging, prod
|
|
ENVIRONMENT=dev
|
|
|
|
# Enable debug mode (auto-enabled in dev)
|
|
DEBUG=true
|
|
|
|
# =============================================================================
|
|
# DATABASE (PostgreSQL)
|
|
# =============================================================================
|
|
# Format: postgresql+asyncpg://user:password@host:port/database
|
|
# Note: Port 5433 to avoid conflicts with other Postgres instances
|
|
DATABASE_URL=postgresql+asyncpg://mantimon:mantimon@localhost:5433/mantimon
|
|
|
|
# Connection pool settings
|
|
DATABASE_POOL_SIZE=5
|
|
DATABASE_MAX_OVERFLOW=10
|
|
|
|
# Echo SQL statements (useful for debugging)
|
|
DATABASE_ECHO=false
|
|
|
|
# =============================================================================
|
|
# REDIS
|
|
# =============================================================================
|
|
# Format: redis://host:port/db
|
|
# Note: Port 6380 to avoid conflicts with other Redis instances
|
|
REDIS_URL=redis://localhost:6380/0
|
|
|
|
# Max connections in pool
|
|
REDIS_MAX_CONNECTIONS=10
|
|
|
|
# =============================================================================
|
|
# SECURITY
|
|
# =============================================================================
|
|
# IMPORTANT: Change this in production!
|
|
# Generate with: python -c "import secrets; print(secrets.token_urlsafe(32))"
|
|
SECRET_KEY=dev-secret-key-change-in-production
|
|
|
|
# JWT settings
|
|
JWT_ALGORITHM=HS256
|
|
JWT_EXPIRE_MINUTES=30
|
|
JWT_REFRESH_EXPIRE_DAYS=7
|
|
|
|
# =============================================================================
|
|
# OAUTH - GOOGLE
|
|
# =============================================================================
|
|
# Get credentials from: https://console.cloud.google.com/apis/credentials
|
|
# GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
|
|
# GOOGLE_CLIENT_SECRET=your-client-secret
|
|
|
|
# =============================================================================
|
|
# OAUTH - DISCORD
|
|
# =============================================================================
|
|
# Get credentials from: https://discord.com/developers/applications
|
|
# DISCORD_CLIENT_ID=your-client-id
|
|
# DISCORD_CLIENT_SECRET=your-client-secret
|
|
|
|
# =============================================================================
|
|
# CORS
|
|
# =============================================================================
|
|
# Comma-separated list of allowed origins
|
|
# CORS_ORIGINS=http://localhost:3000,http://localhost:5173
|
|
|
|
# =============================================================================
|
|
# GAME SETTINGS
|
|
# =============================================================================
|
|
# Turn timeout in seconds (default: 120 = 2 minutes)
|
|
TURN_TIMEOUT_SECONDS=120
|
|
|
|
# =============================================================================
|
|
# CARD DATA
|
|
# =============================================================================
|
|
# Path to card JSON files (relative to backend/)
|
|
CARD_DATA_PATH=data/cards
|