A modern, endlessly fun trivia game powered by Gemini AI and Firebase. Challenge your knowledge with a continuous stream of unique questions, compete for high scores, and climb the leaderboards!
- Endless and Daily Challenge trivia modes
- AI-generated, unique trivia questions
- Multiple categories and difficulty levels
- Leaderboards for both Endless and Daily modes
- Google authentication
- Power-ups and streak bonuses
- Beautiful, responsive UI
- 2025-07-17
- Added a leaderboard for the Quiz Me on Useful Answers mode, showing top scores.
- Moved the Quiz Me on Useful Answers button to the main button stack for better UX.
- Added a new "Real Life" category for practical, real-world, and everyday knowledge questions.
- AI prompt improved to generate more real-life and practical trivia when this category is selected.
- 2025-07-15
- Users can now rate the usefulness of each answer (1-10).
- Questions with highly-rated answers (average ≥ 7) appear in the Useful Answers area.
- Answer flow improved: 5-second pause after answering to allow rating.
- Added a Changelog page accessible from the Home screen.
- React + TypeScript
- Vite
- Firebase (Auth, Firestore)
- Gemini AI (Google GenAI)
- Framer Motion (animations)
git clone https://github.com/thor-op/brain-trivia.git
cd brain-triviayarn install
# or
npm install- Go to the Firebase Console
- Click "Create a project" or "Add project"
- Enter your project name (e.g., "brain-trivia")
- Choose whether to enable Google Analytics (recommended)
- Select or create a Google Analytics account if enabled
- Click "Create project"
- In your Firebase project, go to "Authentication" in the left sidebar
- Click "Get started" if it's your first time
- Go to the "Sign-in method" tab
- Click on "Google" provider
- Toggle "Enable" to turn it on
- Add your project's domain to "Authorized domains" (e.g.,
localhostfor development) - Click "Save"
- Go to "Firestore Database" in the left sidebar
- Click "Create database"
- Choose "Start in test mode" (you can secure it later)
- Select a location for your database (choose closest to your users)
- Click "Done"
Your app needs these collections. Firebase will create them automatically when data is first written:
Required Collections:
-
leaderboards - Stores user scores and rankings
- Document structure:
{ userId, displayName, score, timestamp, mode }
- Document structure:
-
daily-challenges - Stores daily challenge data
- Document structure:
{ date, questions, participants }
- Document structure:
-
user-ratings - Stores question ratings
- Document structure:
{ questionId, userId, rating, timestamp }
- Document structure:
-
useful-answers - Stores highly-rated questions
- Document structure:
{ question, answer, category, averageRating, ratingCount }
- Document structure:
When you first run the app, you'll likely see red error messages in your browser console like:
Failed to fetch leaderboard FirebaseError: The query requires an index. You can create it here: https://console.firebase.google.com/...
Don't worry - this is normal! Firebase automatically provides clickable links in these error messages to create the required indexes:
- Run your app first and try to use features that query Firestore (like viewing leaderboards)
- Check your browser console for red Firebase error messages
- Click the provided links in the error messages - they'll take you directly to Firebase Console to create the needed indexes
- Click "Create Index" on each page that opens
- Wait for indexes to build (usually takes a few minutes)
This is the easiest way to set up indexes because Firebase generates the exact index configuration your app needs!
- Go to "Firestore Database" > "Rules" tab
- Replace the default rules with this simple rule (allows all read/write access):
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}- Click "Publish"
Note: This rule allows unrestricted access to your database. For production apps, consider implementing more secure rules based on authentication and user permissions.
- Go to "Project Settings" (gear icon in left sidebar)
- Scroll down to "Your apps" section
- Click "Add app" and select the web icon (
</>) - Enter an app nickname (e.g., "brain-trivia-web")
- Check "Also set up Firebase Hosting" if you plan to deploy to Firebase
- Click "Register app"
- Copy the Firebase configuration object
Create a .env file in the project root with your Firebase configuration:
VITE_FIREBASE_API_KEY=your_firebase_api_key
VITE_FIREBASE_AUTH_DOMAIN=your_firebase_auth_domain
VITE_FIREBASE_PROJECT_ID=your_firebase_project_id
VITE_FIREBASE_STORAGE_BUCKET=your_firebase_storage_bucket
VITE_FIREBASE_MESSAGING_SENDER_ID=your_firebase_messaging_sender_id
VITE_FIREBASE_APP_ID=your_firebase_app_id
VITE_FIREBASE_MEASUREMENT_ID=your_firebase_measurement_id
VITE_GEMINI_API_KEY=your_gemini_api_keyImportant Notes:
- Replace
your_*values with actual values from your Firebase config - Never commit the
.envfile to version control - Use
.env.exampleas a template for other developers - Get your Gemini API key from Google AI Studio
- Go to Google Cloud Console
- Select your Firebase project
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "OAuth 2.0 Client IDs"
- Choose "Web application"
- Add authorized origins:
http://localhost:5173(for development)- Your production domain
- Add authorized redirect URIs:
http://localhost:5173/__/auth/handler(for development)https://yourdomain.com/__/auth/handler(for production)
- Save the client ID and add it to your Firebase Authentication settings
yarn dev
# or
npm run devVisit http://localhost:5173 in your browser.
- Sign in with Google to play.
- Choose a category and mode (Endless or Daily Challenge).
- Answer trivia questions, use power-ups, and try to get the highest score!
- Check the leaderboard to see how you rank.
You can deploy this app to Vercel, Netlify, Firebase Hosting, or any static hosting provider. Make sure to set the same environment variables in your deployment settings.
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
- Fork the repo
- Create your feature branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/your-feature) - Open a pull request
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
- ✅ You can use, modify, and distribute this software
- ✅ You can use it for commercial purposes
- ✅ You must include the license and copyright notice
- ✅ You must disclose the source code of any modifications
- ❌ This software comes with no warranty
For more information about GPL v3, visit: https://www.gnu.org/licenses/gpl-3.0.html
Enjoy playing Never-Ending Brain Trivia and may your knowledge never end!