A multiplayer game where players try to distinguish between real photos and AI-generated images. Test your skills solo or compete with friends in real-time! Inspired by games like LinkedIn or Interpol, and the cooperative style of Kahoot.
Important
This is a small side project I built because I thought it was fun. The code quality isn't great, but the result is entertaining. I welcome contributions, especially for translating it into more languages.
- Solo Mode: Play alone with 12 images, 30 seconds each - track previously seen images
- With Friends Mode: Host a game session where friends can join via QR code and vote from their mobile devices in real-time
- Multilingual: Supports English and Spanish (easily extensible to other languages)
- Responsive Design: Works seamlessly on desktop, tablet, and mobile devices
- Real-time Leaderboard: See scores update live during multiplayer games
- Smart Image Pool: Images are tracked to avoid repetition while playing
- Runtime: Bun - Fast JavaScript runtime
- Framework: Next.js 16 with App Router
- Language: TypeScript (strict mode)
- Styling: TailwindCSS 4 (Material Design)
- Real-time: WebSockets (ws library) for multiplayer synchronization
- i18n:
next-intlfor internationalization - Image Processing: Sharp for optimization
- QR Codes:
qrcode.reactfor room sharing
- Bun installed (Installation guide)
- (Optional) Unsplash API key for downloading more real images
- (Optional) Google AI API key for generating more AI images
# Clone the repository
git clone https://github.com/TeenBiscuits/RealOrAI.git
cd real-or-ia
# Install dependencies
bun install
# Start the development server (WebSockets could not work)
bun run dev
# OR Start the production version
bun run build && bun run startThe app will be available at http://localhost:3000
To replace placeholder images with real photos and AI-generated images:
-
Copy the environment template:
cp .env.example .env
-
Add your API keys to
.env:- Get Unsplash API key at: https://unsplash.com/developers
- Get Google AI API key at: https://aistudio.google.com/app/apikey
-
Run the setup script:
bun run setup-images 24 # Downloads 12 real + generates 12 AI images
# Download only real images from Unsplash
UNSPLASH_ACCESS_KEY=your_key bun run download-real 10
# Generate only AI images using Google Imagen
GOOGLE_API_KEY=your_key bun run generate-ai 10- Click "Solo" on the home page
- Each round shows an image for 30 seconds
- Click "π· Real" or "π AI" to vote
- See if you were correct
- After 12 rounds, view your final score
Host (on computer/TV):
- Click "With Friends" on the home page
- A QR code and room code will be displayed
- Wait for players to join
- Click "Start Game" when ready
- The game displays images and collects votes from all players
- After 12 rounds, see the leaderboard
Players (on mobile):
- Scan the QR code or enter the URL
- Enter a nickname and join
- When the game starts, vote on each image
- See your results and final ranking
real-or-ia/
βββ src/
β βββ app/
β β βββ [locale]/ # Internationalized pages
β β β βββ page.tsx # Home page
β β β βββ solo/ # Solo game mode
β β β βββ host/ # Host screen for multiplayer
β β β βββ join/[roomId]/ # Player join screen
β β βββ api/ # API routes
β βββ components/ # React components
β βββ hooks/ # Custom React hooks
β βββ lib/ # Utilities and game logic
β βββ i18n/ # Translations
βββ public/
β βββ images/
β βββ real/ # Real photographs
β βββ ai/ # AI-generated images
βββ scripts/ # Image generation/download scripts
βββ server.ts # Custom server with WebSocket support
- Create a new translation file in
src/i18n/(e.g.,fr.json) - Copy the structure from
en.jsonand translate - Add the locale to
src/i18n/config.ts:export const locales = ["en", "es", "fr"] as const; export const localeNames: Record<Locale, string> = { en: "English", es: "EspaΓ±ol", fr: "FranΓ§ais", };
All images are processed to:
- Resolution: 1280x720 pixels (16:9 aspect ratio)
- Format: JPEG (85% quality, progressive)
- Optimized for fast web loading
| Script | Description |
|---|---|
bun run dev |
Start development server with WebSocket support |
bun run build |
Build for production |
bun run start |
Start production server with WebSocket |
bun run lint |
Run ESLint to check code quality |
bun run format |
Run Prettier to format the code |
bun run setup-images [count] |
Download real + generate AI images |
bun run download-real [count] |
Download images from Unsplash |
bun run generate-ai [count] |
Generate images with Google Imagen |
See .env.example for all available environment variables:
UNSPLASH_ACCESS_KEY- For downloading real photosGOOGLE_API_KEY- For generating AI imagesNEXT_PUBLIC_SITE_URL- Your site URL (production domain)
The app includes a Dockerfile and docker-compose.yml for easy deployment:
# Build and run with Docker
docker-compose up --buildFor production deployment:
- Set
NEXT_PUBLIC_SITE_URLto your domain - Ensure WebSocket connections are properly configured in your reverse proxy
- The app runs on port 3000 by default
Contributions are welcome! Please feel free to submit a Pull Request.
Real images are sourced from Unsplash. See ATTRIBUTION.md for photo credits.
Apache License 2.0 - Copyright 2025 Pablo Portas LΓ³pez
