A web application that leverages multi-modal AI to dynamically generate playable "Spot the Difference" games from a single text prompt.
The goal was to create a truly interactive and generative experience using a multi-modal AI workflow. Instead of just generating an image or text, this project uses AI as a creative partner in a two-step process: first to create a world (the base image), and then to subtly alter it (the modified image). The challenge of programmatically finding those differences without further AI calls led to an interesting blend of AI generation and classic computer vision techniques.
| Feature | Description |
|---|---|
| ๐จ AI-Powered Game Creation | Describe any scene and the AI generates a unique game for you |
| ๐ Dynamic Difference Generation | Multi-modal AI intelligently adds or removes elements from a base image |
| โก Client-Side Analysis | Differences detected mathematically in the browser via JavaScript & Canvas APIs |
| โ๏ธ Manual Editing | Add, remove, or resize differences after automated analysis |
| ๐พ Database Persistence | Manually curated games saved to Appwrite for future use or sharing |
| ๐ฎ Interactive Gameplay | Timer, scoring, and clickable regions to find the differences |
| ๐ Debug Mode | Visualizes mathematically-found differences before starting the game |
| ๐ฑ Responsive Design | Playable on both desktop and mobile devices |
| Layer | Technologies |
|---|---|
| Frontend | React, TypeScript, Tailwind CSS |
| AI Models | Imagen 4, Gemini 2.5 Flash Image Preview |
| Analysis | JavaScript, HTML Canvas API |
| Backend | Appwrite (Storage + Database) |
User Prompt
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Base Image Generation โ โ Imagen 4
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Difference Generation โ โ Gemini 2.5 Flash Image Preview
โ (3-5 subtle changes) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Image Storage โ โ Appwrite Storage
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Pixel-by-Pixel โ
โ Mathematical Analysis โ โ Canvas API
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Region Finding & โ
โ Noise Filtering โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Manual Curation & โ
โ Database Save โ โ Appwrite Database
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
๐ฎ Game Ready!
- Prompt โ User enters a theme (e.g. "A whimsical fantasy library with floating books")
- Base Image โ Imagen 4 generates the original high-quality image
- Difference Generation โ Gemini 2.5 Flash introduces 3โ5 structural changes (object additions/removals), explicitly avoiding simple color or brightness shifts
- Storage โ Both images uploaded to Appwrite Storage
- Analysis โ Client-side pixel-by-pixel canvas comparison
- Region Grouping โ Custom algorithm groups differing pixels into connected, filtered, merged regions
- Manual Curation โ User can add, delete, or resize auto-detected differences
- Save & Play โ Final game data saved to Appwrite Database, ready to play!
| Variable | Description |
|---|---|
API_KEY |
Your AI API key for Gemini models |
APPWRITE_ENDPOINT |
Appwrite API endpoint (e.g. https://cloud.appwrite.io/v1) |
APPWRITE_PROJECT_ID |
Project ID from Appwrite console |
APPWRITE_BUCKET_ID |
Storage Bucket ID for generated images |
APPWRITE_DATABASE_ID |
Database ID for the games collection |
Note: The app accesses these from the global scope via
(self as any).environment.API_KEYโ notprocess.env.
To allow local development, register your environment as a Web Platform in Appwrite:
- Go to your project in the Appwrite Console
- Click Platforms โ Add Platform โ New Web App
- Set Hostname to
localhost - Click Create
โ ๏ธ Without this step, you'll encounter authentication errors that prevent images from being saved.
1. Create a Database in Appwrite Console โ Databases. Note the Database ID.
2. Create an API Key with databases.write permission. Note the Secret.
3. Run the setup script:
# Install dependencies
npm install ts-node node-appwrite
# Run migration
APPWRITE_ENDPOINT="https://cloud.appwrite.io/v1" \
APPWRITE_PROJECT_ID="<YOUR_PROJECT_ID>" \
APPWRITE_API_KEY="<YOUR_SECRET_API_KEY>" \
APPWRITE_DATABASE_ID="<YOUR_DATABASE_ID>" \
npx ts-node migrations/setup-appwrite.tsThis creates the games collection with all required attributes.
# 1. Clone the repository
git clone https://github.com/seehiong/gemini-spot-the-diff-generator.git
cd gemini-spot-the-diff-generator
# 2. Set your environment variables
# 3. Serve the application
# All dependencies load via CDN โ no npm install needed for the web app!- Game Loading โ Load previously saved games from the database
- Difficulty Levels โ Adjust subtlety of AI changes and number of differences
- Zen Mode โ A relaxing game mode with no timer
- Shareable Games โ Unique URLs for each saved game to challenge friends
- Leaderboards โ Global leaderboard for fastest completion times
gemini-spot-the-diff-generator/
โโโ migrations/
โ โโโ setup-appwrite.ts # One-time DB setup script
โโโ src/
โ โโโ components/ # React components
โ โโโ ...
โโโ index.html
โโโ README.md
This project is open source. Feel free to fork, extend, and build upon it!