An AI-powered pinball rules archive and Q&A assistant built with Next.js 14, PostgreSQL with pgvector, Meilisearch, and OpenAI.
- 🎯 Browse Games: Search and explore pinball machine rules
- 🤖 AI Assistant: Ask questions and get instant answers about game rules
- 🔍 Hybrid Search: Combines vector similarity and keyword search
- 📝 Admin Panel: Upload and manage game rules
- 🚀 Railway Ready: Optimized for Railway deployment
- Frontend: Next.js 14 (App Router), Tailwind CSS, shadcn/ui
- Database: PostgreSQL with pgvector extension
- Search: Meilisearch for full-text search
- AI: OpenAI API for embeddings and chat completion
- Deployment: Docker + Railway
- Node.js 20+
- PostgreSQL with pgvector extension
- Meilisearch instance
- OpenAI API key
-
Clone the repository
git clone https://github.com/200even/pinball-rules-mvp.git cd pinball-rules-mvp -
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env.local
Edit
.env.localwith your configuration:DATABASE_URL="postgresql://username:password@localhost:5432/pinball_rules" OPENAI_API_KEY="sk-your-openai-api-key-here" MEILI_MASTER_KEY="your-meilisearch-master-key" MEILI_HOST="http://localhost:7700" NEXT_PUBLIC_MEILI_HOST="http://localhost:7700" NEXT_PUBLIC_SITE_URL="http://localhost:3000" VECTOR_DIM=1536
-
Set up PostgreSQL
# Create database and enable pgvector createdb pinball_rules psql pinball_rules -c "CREATE EXTENSION vector;"
-
Start Meilisearch
# Using Docker docker run -it --rm \ -p 7700:7700 \ -e MEILI_MASTER_KEY=your-master-key \ getmeili/meilisearch:latest # Or install locally # See: https://docs.meilisearch.com/learn/getting_started/installation.html
-
Run database migrations
npm run migrate
-
Seed the database
npm run seed
-
Start the development server
npm run dev
-
Visit the application
- Main site: http://localhost:3000
- Admin panel: http://localhost:3000/admin
npm run dev- Start development servernpm run build- Build for productionnpm run start- Start production servernpm run migrate- Run database migrationsnpm run seed- Seed database with sample datanpm run reindex- Reindex all content in Meilisearchnpm run lint- Run ESLint
- Railway account
- GitHub repository
-
Push to GitHub
git add . git commit -m "Initial commit" git push origin main
-
Create Railway Project
- Connect your GitHub repository
- Railway will automatically detect the
railway.tomlconfiguration
-
Set Environment Variables
DATABASE_URL=<railway-postgres-url> OPENAI_API_KEY=<your-openai-key> MEILI_MASTER_KEY=<generate-secure-key> MEILI_HOST=<railway-meilisearch-internal-url> NEXT_PUBLIC_MEILI_HOST=<railway-meilisearch-public-url> NEXT_PUBLIC_SITE_URL=<your-railway-app-url> VECTOR_DIM=1536 NODE_ENV=production
-
Deploy Services
- Railway will deploy both the web app and Meilisearch service
- The database will be automatically provisioned
-
Run Initial Setup
# SSH into your Railway deployment or use Railway CLI npm run migrate npm run seed
The railway.toml file configures two services:
- web: Next.js application (port 8080)
- meilisearch: Search engine with persistent volume
- Basic game information (title, manufacturer, year, etc.)
- Links to IPDB and Pinside
- Version-specific rules for each game
- Provenance tracking
- Individual rule sections with vector embeddings
- Full-text search integration
- Structured metadata (facts)
GET /api/health- Health checkPOST /api/ask- AI Q&A endpoint
POST /api/admin/games- Create gamePOST /api/admin/rulesets- Create rulesetPOST /api/admin/process-markdown- Parse markdown into sectionsPOST /api/admin/generate-embeddings- Generate AI embeddingsPOST /api/admin/reindex- Reindex search content
- Visit
/admin - Fill in game information
- Paste rules in Markdown format
- Submit - the system will:
- Parse markdown into sections
- Generate AI embeddings
- Index for search
- Visit a game page (e.g.,
/games/[id]) - Use the "Ask AI" component
- Ask specific questions like:
- "How do you start multiball?"
- "What are the jackpot values?"
- "How do you reach the wizard mode?"
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details.
For issues and questions:
- GitHub Issues: Report a bug
- Discussions: Ask questions