LLM Board Game Server

A game-agnostic server for physical board games where LLM-controlled pieces make moves based on photos of the game board.

Architecture

Backend (/backend/)

  • index.ts: Main Hono server with all routes
  • database/: SQLite database management
    • migrations.ts: Database schema setup
    • queries.ts: Database query functions
  • llm/: LLM integration
    • openai.ts: OpenAI API calls for piece moves

Frontend (/frontend/)

  • index.html: Main HTML template
  • components/: React components
    • App.tsx: Main app component
    • HomePage.tsx: Game creation/joining
    • ManagePage.tsx: Game management interface
    • PlayPage.tsx: Player interface with SSE updates
  • style.css: Styling

Shared (/shared/)

  • types.ts: TypeScript interfaces
  • utils.ts: Shared utility functions

Key Features

  1. Game Management: Create games with unique 5-letter IDs
  2. Piece Configuration: Define piece types with descriptions
  3. Player Instructions: Persistent instructions for each piece
  4. Parallel LLM Processing: All pieces move simultaneously
  5. Real-time Updates: Server-sent events for live move updates
  6. Photo-based Turns: Multimodal LLM analysis of board state

Workflow

  1. Game manager creates game → gets management URL
  2. Players join with usernames → get play URLs
  3. Players configure pieces and instructions
  4. Any player takes photo → triggers parallel LLM moves
  5. Results stream back in real-time via SSE

Database Schema

  • games: Game metadata and rules
  • pieces: Piece types and descriptions
  • players: Player usernames per game
  • player_pieces: Player-owned pieces with instructions
  • moves: Historical move data (optional context)