A real-time multiplayer trivia game where the lowest score wins! Answer questions correctly, but try to pick the answers that the fewest other players will choose.
- 10 trivia questions per game
- Each question has multiple correct answers
- All players see the same question simultaneously
- 15-second time limit per question
- Correct answer: You get points equal to the number of players who chose the same answer
- Wrong answer: You get the highest correct answer count + 5 penalty points
- Lower score wins!
Playing with 10 players, question: "Name one of the Beatles"
- 5 people guessed John → each gets 5 points
- 3 people guessed Ringo → each gets 3 points
- 1 person guessed Paul → gets 1 point (best score!)
- 1 person guessed Marty (wrong) → gets 10 points (5 + 5 penalty)
- Frontend: Next.js 14 (App Router), React, TypeScript, Tailwind CSS
- Backend: Next.js API Routes, Socket.io for real-time features
- Database: PostgreSQL with Prisma ORM
- Authentication: NextAuth.js with Google OAuth
- AI: ATXP LLM Gateway for question generation
- Node.js 18+ and npm
- PostgreSQL database
- Google OAuth credentials
- ATXP connection string (optional, for AI question generation)
npm install --legacy-peer-depsCopy the example env file and fill in your values:
cp .env.example .envEdit .env with your configuration:
# Database
DATABASE_URL="postgresql://user:password@localhost:5432/crash_trivia"
# NextAuth
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-secret-key-here" # Generate with: openssl rand -base64 32
# OAuth Provider (Google)
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"
# ATXP LLM Gateway (optional, for AI question generation)
ATXP_CONNECTION_STRING="your-atxp-connection-string"# Generate Prisma client
npm run db:generate
# Push schema to database
npm run db:pushAfter signing in for the first time, you'll need to manually set your user role to "admin" in the database:
UPDATE "User" SET role = 'admin' WHERE email = 'your-email@example.com';Visit /admin after signing in as an admin to:
- Manually create questions
- Generate questions using AI
- Manage existing questions
npm run devVisit http://localhost:3000
- Sign in with Google
- Create a game or join with a code
- Wait for host to start the game
- Answer questions within 15 seconds
- View results after all questions are answered
- Lowest score wins!
- Visit
/admin - Create questions manually or use AI generation
- Each question needs:
- Question text
- Multiple correct answers (comma-separated)
- Optional: category and difficulty
- Push code to GitHub
- Import project in Vercel
- Add environment variables
- Deploy!
Note: For production, you'll need to handle Socket.io differently as Vercel doesn't support WebSockets. Consider:
- Using a separate Socket.io server on Railway/Render
- Switching to Pusher or Ably for real-time features
- Deploying the entire app on Railway/Render instead
# Install Railway CLI
npm install -g @railway/cli
# Login
railway login
# Initialize project
railway init
# Add PostgreSQL
railway add postgresql
# Deploy
railway up- User: Authentication and user profiles
- Account: OAuth provider accounts
- Session: User sessions
- Question: Trivia questions with multiple correct answers
- Game: Game instances with status and code
- GamePlayer: Players in a specific game
- GameQuestion: Questions assigned to a game
- PlayerAnswer: Answers submitted by players
POST /api/games/create- Create a new gamePOST /api/games/join- Join an existing gameGET /api/games/[id]- Get game detailsPOST /api/games/[id]/submit-answer- Submit an answerPOST /api/games/[id]/start- Start a game (creator only)POST /api/games/[id]/calculate-scores- Calculate question scores
GET /api/admin/questions- List all questionsPOST /api/admin/questions- Create a questionGET /api/admin/questions/[id]- Get question detailsPUT /api/admin/questions/[id]- Update a questionDELETE /api/admin/questions/[id]- Delete a questionPOST /api/admin/generate-question- Generate questions with AI
join-game- Join a game roomleave-game- Leave a game roomstart-game- Start the gameshow-question- Show question to all playersstart-timer- Start question timertimes-up- Time expired for questionanswer-submitted- Player submitted answerstart-reveal- Start reveal phasereveal-answers- Show all answers and scoresgame-complete- Game finished
player-joined- New player joinedgame-started- Game has startedquestion-revealed- New question showntimer-started- Timer startedtime-expired- Time is upplayer-answered- Another player answeredreveal-phase-started- Reveal phase beginninganswers-revealed- Answers and scores showngame-ended- Game completed with final scores
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint
npm run db:push # Push Prisma schema to database
npm run db:studio # Open Prisma Studio
npm run db:generate # Generate Prisma client- Game history and statistics
- Leaderboards
- Custom game settings (question count, time limit)
- Question categories and difficulty filtering
- Team mode
- Tournament brackets
- Sound effects and animations
- Mobile app (React Native)
MIT
Contributions are welcome! Please open an issue or submit a pull request.