- Backend: FastAPI + Python-SocketIO + SQLAlchemy - Models for categories, questions, game sessions, events - AI services for answer validation and question generation (Claude) - Room management with Redis - Game logic with stealing mechanics - Admin API for question management - Frontend: React + Vite + TypeScript + Tailwind - 5 visual themes (DRRR, Retro, Minimal, RGB, Anime 90s) - Real-time game with Socket.IO - Achievement system - Replay functionality - Sound effects per theme - Docker Compose for deployment - Design documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
25 lines
980 B
Python
25 lines
980 B
Python
from sqlalchemy import Column, Integer, String, DateTime, ARRAY
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
from app.models.base import Base
|
|
|
|
|
|
class GameSession(Base):
|
|
__tablename__ = "game_sessions"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
room_code = Column(String(6), unique=True, nullable=False, index=True)
|
|
status = Column(String(20), default="waiting") # waiting, playing, finished
|
|
team_a_score = Column(Integer, default=0)
|
|
team_b_score = Column(Integer, default=0)
|
|
current_team = Column(String(1)) # 'A' or 'B'
|
|
questions_used = Column(ARRAY(Integer), default=[])
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
finished_at = Column(DateTime(timezone=True))
|
|
|
|
# Relationships
|
|
events = relationship("GameEvent", back_populates="session")
|
|
|
|
def __repr__(self):
|
|
return f"<GameSession(id={self.id}, room_code='{self.room_code}', status='{self.status}')>"
|