Framework
Next.js 15
The application uses Next.js 15 with the App Router for full-stack React development. Why Next.js?- Server and client components in one codebase
- Built-in API routes for backend logic
- Automatic code splitting and optimization
- Zero-config TypeScript support
- Server-side rendering for better SEO
- App Router for file-based routing (
app/directory) - Server Actions for data mutations
- React Server Components for initial data fetching
- API routes for backend endpoints (
app/api/) - Middleware for request interception
- Turbopack for faster development builds
package.json:18
--turbopack flag for improved performance:
package.json:6-7
UI framework
React 19
The frontend is built with React 19, using hooks and functional components throughout. Key patterns:- Hooks:
useState,useEffect,useRouterfor state management - Suspense: Loading states with
<Suspense>boundaries - Client components: Marked with
"use client"directive - Composition: Small, reusable components
package.json:19-20
Why React 19?
- Improved Suspense support
- Better concurrent rendering
- Server Component integration with Next.js
- Enhanced TypeScript support
Tailwind CSS
All styling is done with Tailwind CSS utility classes. Configuration:- Tailwind CSS v4 with PostCSS plugin
- Dark theme by default (
bg-[#121212]) - Custom color palette for game UI
- Responsive design with mobile-first approach
package.json:27,34
Example usage:
app/page.tsx:55-57
Framer Motion
Used for animations and transitions throughout the UI. Use cases:- Hint reveal animations
- Modal transitions (stats modal)
- Guess list animations
- Map country highlighting
package.json:15
Lucide React
Icon library for consistent, lightweight icons. Examples:- Navigation arrows
- Stats icons
- Game UI elements
package.json:16
Language
TypeScript
The entire codebase is written in TypeScript with strict type checking. Type definitions:app/types.ts:3-45
Why TypeScript?
- Catch errors at compile time
- Better IDE autocomplete
- Self-documenting code
- Safer refactoring
- Improved maintainability
package.json:35
Database
MongoDB Atlas
Persistent storage using MongoDB’s cloud database service. Collections:daily_games: One document per date with target country and hintsuser_progress: Progress tracking per session and date
package.json:17
Connection management:
Singleton pattern with connection pooling:
app/lib/mongodb.ts:1-22
Why MongoDB?
- Flexible schema for country data
- Easy to store nested hint packages
- Fast document queries by date
- Free tier on Atlas for small projects
- JSON-like document structure matches JavaScript
External APIs
RestCountries API
Provides comprehensive country data including:- Country names and codes
- Flags (SVG URLs)
- Geographic coordinates
- Border countries
- Population and area
- Regions and subregions
app/api/daily/route.ts:12-13
Data shape:
CIA World Factbook
JSON version hosted on GitHub provides detailed country information for hints. Base URL:app/lib/factbook.ts:19
Data extracted:
- Climate descriptions
- Terrain information
- Natural resources
- Export commodities
- Demographics and religions
- Flag descriptions
- National symbols
app/lib/factbook.ts:5-17
HTTP client:
package.json:12
Axios is used for Factbook requests due to better error handling:
app/lib/factbook.ts:33-35
Map visualization
D3-geo
Core library for geographic projections and path generation.package.json:14,28
Usage:
- Mercator projection for world map
- Path generation from GeoJSON
- Coordinate transformations
react-svg
Loads and renders SVG map files dynamically.package.json:21
react-zoom-pan-pinch
Enables interactive map controls:package.json:22
Features:
- Mouse wheel zoom
- Click and drag panning
- Touch gestures on mobile
- Programmatic zoom/pan controls
Session management
cookies-next
Server and client cookie handling for Next.js:package.json:13
Usage:
app/api/progress/route.ts:4,17-18
uuid
Generates unique session identifiers:package.json:23
app/api/progress/route.ts:3,21
Utilities
Geographic calculations
Custom utilities for distance and bearing calculations:app/lib/geoUtils.ts:5-44
Development tools
ESLint
Code linting with Next.js configuration:package.json:32-33
pnpm
Package manager for faster installs and better disk efficiency. Why pnpm?- Faster than npm/yarn
- Saves disk space with content-addressable storage
- Strict dependency resolution
README.md:32-34
Deployment
Vercel
The app is deployed on Vercel’s platform (Next.js creators). Benefits:- Zero-config deployment
- Automatic HTTPS
- Edge network CDN
- Environment variable management
- Preview deployments for PRs
README.md:5
Environment variables
Required configuration:README.md:39
Stored in:
.env.localfor development- Vercel dashboard for production
Technology choices summary
| Technology | Purpose | Why chosen |
|---|---|---|
| Next.js 15 | Framework | Full-stack React, API routes, SSR |
| React 19 | UI library | Modern hooks, Suspense, Server Components |
| TypeScript | Language | Type safety, better DX |
| Tailwind CSS | Styling | Utility-first, fast iteration |
| MongoDB | Database | Flexible schema, easy JSON storage |
| RestCountries | Country data | Free, comprehensive, reliable |
| CIA Factbook | Hint data | Rich geographic/economic info |
| D3-geo | Maps | Industry standard for geo projections |
| Framer Motion | Animations | Declarative, performant animations |
| Vercel | Hosting | Zero-config, global CDN, Next.js optimized |