Skip to content

TabletopFoundry/rules-genie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RulesGenie 🎲✨

Next.js TypeScript React License: MIT PRs Welcome CI Node

Stop flipping through rulebooks. Get the ruling in seconds.

RulesGenie is an AI-powered board game rules assistant that answers natural-language questions with citation-backed answers. It supports 35 popular board games out of the box, works entirely in demo mode without any API keys, and optionally integrates with OpenAI for production-grade responses.


✨ Features

  • πŸ€– Rules Q&A β€” Chat-style answers with game-aware session memory and source citations
  • πŸ“š Game Library β€” Search and filter a curated catalog of popular board games
  • ⚑ Quick-Start Mode β€” Compressed rules summaries and setup guides for faster teaches
  • πŸ”– Saved Answers β€” Bookmark answers and revisit them on your personal dashboard
  • 🎯 Demo Mode β€” Works fully without API keys using intelligent keyword-scored mock responses
  • πŸ›‘οΈ Confidence Scoring β€” Every answer includes a confidence level and citation status

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Next.js App Router             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  Pages   β”‚  β”‚   API    β”‚  β”‚  Middleware    β”‚  β”‚
β”‚  β”‚ (RSC +   β”‚  β”‚  Routes  β”‚  β”‚ (CSRF guard)  β”‚  β”‚
β”‚  β”‚  Client) β”‚  β”‚          β”‚  β”‚               β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚       β”‚              β”‚                            β”‚
β”‚  β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”                      β”‚
β”‚  β”‚        src/lib/         β”‚                      β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚                      β”‚
β”‚  β”‚  β”‚ AI  β”‚   β”‚   DB   β”‚  β”‚                      β”‚
β”‚  β”‚  β”‚mock β”‚   β”‚ SQLite β”‚  β”‚                      β”‚
β”‚  β”‚  β”‚+GPT β”‚   β”‚(better β”‚  β”‚                      β”‚
β”‚  β”‚  β”‚     β”‚   β”‚sqlite3)β”‚  β”‚                      β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚                      β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Get running in under 2 minutes:

# 1. Clone and install
git clone <repo-url> && cd rulesgenie
npm install

# 2. (Optional) Configure environment
cp .env.example .env

# 3. Start development server
npm run dev

Open http://localhost:3000 β€” the app works immediately in demo mode.

πŸ’‘ Tip: Try asking "Can I draw a face-up locomotive first?" on the Ask page to see citations and confidence scoring in action.

βš™οΈ Environment Variables

Variable Default Description
RULESGENIE_DEMO_MODE true Keep the app in mock mode with scripted answers
OPENAI_API_KEY β€” Your OpenAI API key for live AI responses
OPENAI_MODEL gpt-4o-mini Override the default OpenAI model
RULESGENIE_DB_PATH ./rulesgenie.db Override the SQLite database location

If no API key is present, the app automatically falls back to demo mode. No configuration required to get started.

πŸ—„οΈ Persistence

The app stores data in SQLite. By default it uses ./rulesgenie.db, and you can override that path with RULESGENIE_DB_PATH. The production Docker image points that variable at /app/data/rulesgenie.db so data can live on a mounted volume. It stores:

  • Supported game metadata (35 games in development)
  • Development user personas, collections, bookmarks, sessions, and feedback
  • Chat history by session
  • Saved answers / bookmarks
  • Answer feedback (thumbs up/down)

πŸ“ Project Structure

src/
β”œβ”€β”€ app/                  # Next.js App Router pages & API routes
β”‚   β”œβ”€β”€ api/              # REST endpoints (ask, bookmarks, collection, feedback, session)
β”‚   β”œβ”€β”€ ask/              # Rules Q&A chat page
β”‚   β”œβ”€β”€ dashboard/        # Personal dashboard
β”‚   β”œβ”€β”€ games/            # Game library + detail pages
β”‚   └── quick-start/      # Quick-start explorer
β”œβ”€β”€ components/           # React components (client + server)
β”‚   └── hooks/            # Custom React hooks (useConversation, useRulesSession)
β”œβ”€β”€ data/                 # Static game data and mock Q&A entries
β”œβ”€β”€ lib/                  # Core business logic
β”‚   β”œβ”€β”€ ai/               # AI engine (mock + OpenAI)
β”‚   └── db/               # Database layer (SQLite via better-sqlite3)
└── types/                # TypeScript type definitions

πŸ› οΈ Tech Stack

Layer Technology
Framework Next.js 15 (App Router)
Language TypeScript 5.8 (strict mode)
UI React 19 + Tailwind CSS 3
Database SQLite via better-sqlite3
AI OpenAI API (optional)
Validation Zod on all API routes
Icons Lucide React

πŸ“œ Scripts

Command Description
npm run dev Start the development server
npm run build Create a production build
npm run start Run the production server
npm run lint Run ESLint
npm run typecheck Run TypeScript type checking
npm run format Format code with Prettier
npm run format:check Check formatting without modifying files
npm run validate Run all checks (lint + typecheck + format + build)
npm run clean Remove build artifacts

🌱 Development Seed Data

In non-production environments, RulesGenie reseeds SQLite automatically on startup with a deterministic development dataset.

  • 35 board games covering gateway, euro, co-op, party, and heavyweight titles
  • 3 user personas: a power user (demo-user), a casual player, and a brand-new account
  • 124 seeded Q&A rows sourced from a 100+ entry rules bank with realistic citations, bookmarks, collections, and feedback
  • Multiple conversation sessions with short and long histories, plus edge cases like unicode names, long questions, null optionals, and varied confidence values
  • Production-safe behavior: the development seed routine is skipped entirely when NODE_ENV=production

If you want a fresh development dataset, stop the app, delete rulesgenie.db, and start npm run dev again.

🀝 Contributing

Contributions are welcome! Please read our Contributing Guide for details on how to get started.

🐳 Docker

Build and run the production container:

docker build -t rulesgenie .
docker run -p 3000:3000 -v rulesgenie-data:/app/data rulesgenie

The container runs a standalone Next.js server with minimal footprint (~150 MB) and persists SQLite data in /app/data.

πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


RulesGenie · Built for fast mid-game rulings 🎲

About

AI-powered board game rules assistant that answers natural-language rules questions with citations.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages