A modern geo-location guessing game built with React and Fastify. Guess famous landmarks and locations around the world in 6 tries or less! Available as a web app and Discord Activity.
- ๐บ๏ธ Interactive map with guess visualization
- ๐ฏ Daily challenges with new locations
- ๐ก Helpful hints for each location
- ๐ Real-time statistics and guess history
- ๐จ Beautiful, modern UI with TailwindCSS
- ๐ฑ Responsive design
- ๐ฎ Discord Activity integration - play directly in Discord
- ๐ค Discord bot with automated daily challenges
- ๐๏ธ PostgreSQL database for persistent data
- React 18 - UI framework
- Vite - Build tool and dev server
- TailwindCSS - Styling
- Leaflet & React-Leaflet - Interactive maps
- Lucide React - Icons
- Discord Embedded App SDK - Discord Activity integration
- Fastify - Fast and efficient Node.js web framework
- PostgreSQL - Database for locations and game state
- Discord.js - Discord bot integration
- Node-cron - Scheduled tasks for daily challenges
- @fastify/cors - Cross-origin resource sharing
- @fastify/rate-limit - API rate limiting
- @fastify/static - Static file serving
- ES Modules - Modern JavaScript
- Node.js 18+ installed
- npm or yarn package manager
- Docker and Docker Compose installed
- Start PostgreSQL Database
docker-compose up -dThis will start a PostgreSQL database on port 5432 and automatically initialize it with the schema and seed data.
- Set up Backend Environment
cd backend
cp .env.example .env
npm installEdit backend/.env and configure the following:
PORT- Backend server port (default: 3001)GA_MEASUREMENT_ID- Google Analytics measurement ID (optional)GA_API_SECRET- Google Analytics API secret (optional)DISCORD_CLIENT_ID- Discord application client ID (required for Discord Activity)DISCORD_CLIENT_SECRET- Discord application client secret (required for Discord Activity)DISCORD_BOT_TOKEN- Discord bot token (required for Discord bot features)
Note: Discord credentials are required if you want to use the Discord Activity or bot features. For web-only usage, you can leave these blank.
- Install Frontend Dependencies
cd frontend
npm install- Start the Backend Server (Terminal 1)
cd backend
npm run devThe backend will run on http://localhost:3001
- Start the Frontend Dev Server (Terminal 2)
cd frontend
npm run devThe frontend will run on http://localhost:3000
- Open your browser and navigate to
http://localhost:3000
View database logs:
docker-compose logs postgresStop database:
docker-compose downReset database (delete all data):
docker-compose down -v
docker-compose up -dConnect to database:
docker exec -it locodle-postgres psql -U locodle -d locodle- Look at the image and hints provided
- Search for a location using the search bar
- Select your guess from the dropdown suggestions
- See how far away you are from the actual location
- Keep guessing until you find it or run out of tries!
- 6 guesses maximum per daily challenge
- Distance feedback shown for each guess (km or miles)
- Win condition: Guess within 50km of the actual location
- New challenge every day - automatically generated from a pool of 60+ locations
- Hints available to help you narrow down the location
- Two ways to guess: Search by name or click on the map
GET /api/health- Health checkGET /api/daily-challenge- Get today's challengePOST /api/guess- Submit a guessGET /api/stats/:sessionId- Get game statistics
locodle-second/
โโโ backend/
โ โโโ data/
โ โ โโโ locations.js # Location database
โ โโโ db/
โ โ โโโ migrations/ # Database migrations
โ โ โโโ connection.js # PostgreSQL connection
โ โ โโโ init.sql # Database schema
โ โโโ scripts/
โ โ โโโ check-locations.js # Location validation script
โ โ โโโ clear-today-location.js # Reset daily challenge
โ โ โโโ init-db.js # Database initialization
โ โโโ services/
โ โ โโโ discordBot.js # Discord bot service
โ โ โโโ locationGenerator.js # Daily location generation
โ โโโ server.js # Fastify server
โ โโโ .env.example # Environment variables template
โ โโโ package.json
โโโ frontend/
โ โโโ src/
โ โ โโโ components/
โ โ โ โโโ DiscordActivityWrapper.jsx # Discord Activity integration
โ โ โ โโโ GameMap.jsx # Interactive map
โ โ โ โโโ GuessInput.jsx # Search and guess input
โ โ โ โโโ GuessInputOverlay.jsx # Overlay for guess input
โ โ โ โโโ GuessHistory.jsx # Guess history display
โ โ โ โโโ GuessHistoryOverlay.jsx # Overlay for guess history
โ โ โ โโโ GameStats.jsx # Game statistics
โ โ โ โโโ HintsPanel.jsx # Hints display
โ โ โ โโโ GameOverModal.jsx # Game over screen
โ โ โ โโโ UserStatsModal.jsx # User statistics modal
โ โ โโโ contexts/ # React contexts
โ โ โโโ App.jsx # Main app component
โ โ โโโ main.jsx # Entry point
โ โ โโโ index.css # Global styles
โ โโโ public/ # Static assets
โ โโโ index.html
โ โโโ vite.config.js
โ โโโ tailwind.config.js
โ โโโ postcss.config.js
โ โโโ package.json
โโโ docker-compose.yml # PostgreSQL container config
โโโ README.md
The game automatically generates a new random location each day from a pool of 60+ famous landmarks, cities, and natural wonders. Locations are:
- Randomly selected each day
- Stored in PostgreSQL for consistency
- Never repeated within 30 days
- Automatically generated - no manual intervention needed
The location pool includes:
- Major world cities (Tokyo, New York, Paris, etc.)
- Famous landmarks (Pyramids, Stonehenge, etc.)
- Natural wonders (Grand Canyon, Mount Everest, etc.)
To expand the location pool, edit backend/services/locationGenerator.js and add entries to the LOCATION_TEMPLATES array:
{
type: 'city', // or 'landmark' or 'natural'
name: 'Location Name',
lat: 12.3456,
lng: 78.9012,
country: 'Country'
}Hints are automatically generated based on the location type, hemisphere, and continent.
To enable the Discord Activity feature:
- Create a Discord application at Discord Developer Portal
- Enable "Embedded App SDK" in your application settings
- Add your application's Client ID to
backend/.envasDISCORD_CLIENT_ID - Add your Client Secret to
backend/.envasDISCORD_CLIENT_SECRET - The same Client ID must be hardcoded in
frontend/src/components/DiscordActivityWrapper.jsx
To enable the Discord bot for automated daily challenges:
- Create a bot in your Discord application
- Enable necessary bot permissions (Send Messages, Embed Links)
- Add the bot token to
backend/.envasDISCORD_BOT_TOKEN - Invite the bot to your Discord server
- The bot will automatically post daily challenges using node-cron scheduling
Useful scripts for database management:
# Initialize database (run after docker-compose up)
cd backend
npm run init-db
# Check location data validity
node scripts/check-locations.js
# Clear today's location (for testing)
node scripts/clear-today-location.jscd frontend
npm run buildThe build output will be in frontend/dist/ and can be deployed to any static hosting service.
The backend is ready for production as-is. Deploy to your preferred hosting platform (Heroku, Railway, Render, etc.) and ensure:
- PostgreSQL database is provisioned
- Environment variables are configured
- Port is properly exposed
Built with โค๏ธ for geography enthusiasts worldwide!