Implemented full FastAPI backend with WebSocket support, database models, and comprehensive documentation for the Paper Dynasty game engine. Backend Implementation: - FastAPI application with Socket.io WebSocket server - SQLAlchemy async database models (Game, Play, Lineup, GameSession) - PostgreSQL connection to dev server (10.10.0.42:5432) - Connection manager for WebSocket lifecycle - JWT authentication utilities - Health check and stub API endpoints - Rotating file logger with Pendulum datetime handling - Redis via Docker Compose for caching Technical Details: - Python 3.13 with updated package versions - Pendulum 3.0 for all datetime operations - Greenlet for SQLAlchemy async support - Fixed SQLAlchemy reserved column names (metadata -> *_metadata) - Pydantic Settings with JSON array format for lists - Docker Compose V2 commands Documentation: - Updated backend/CLAUDE.md with environment-specific details - Created .claude/ENVIRONMENT.md for gotchas and quirks - Created QUICKSTART.md for developer onboarding - Documented all critical learnings and troubleshooting steps Database: - Tables created: games, plays, lineups, game_sessions - All indexes and foreign keys configured - Successfully tested connection and health checks Verified: - Server starts at http://localhost:8000 - Health endpoints responding - Database connection working - WebSocket infrastructure functional - Hot-reload working 🎯 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
49 lines
1007 B
Python
49 lines
1007 B
Python
from functools import lru_cache
|
|
from pydantic_settings import BaseSettings
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Application settings"""
|
|
|
|
# Application
|
|
app_env: str = "development"
|
|
debug: bool = True
|
|
secret_key: str
|
|
|
|
# Database
|
|
database_url: str
|
|
db_pool_size: int = 20
|
|
db_max_overflow: int = 10
|
|
|
|
# Discord OAuth
|
|
discord_client_id: str
|
|
discord_client_secret: str
|
|
discord_redirect_uri: str
|
|
|
|
# League APIs
|
|
sba_api_url: str
|
|
sba_api_key: str
|
|
pd_api_url: str
|
|
pd_api_key: str
|
|
|
|
# WebSocket
|
|
ws_heartbeat_interval: int = 30
|
|
ws_connection_timeout: int = 60
|
|
|
|
# CORS
|
|
cors_origins: list[str] = ["http://localhost:3000", "http://localhost:3001"]
|
|
|
|
# Game settings
|
|
max_concurrent_games: int = 20
|
|
game_idle_timeout: int = 86400 # 24 hours
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
case_sensitive = False
|
|
|
|
|
|
@lru_cache()
|
|
def get_settings() -> Settings:
|
|
"""Get cached settings instance"""
|
|
return Settings()
|