Globetrotter Challenge Documentation
Project Overview
The Globetrotter Challenge is an interactive web application that tests usersβ geography knowledge through a quiz game format. Users are presented with clues about various global destinations and must guess the correct location from multiple options.
Key features:
- 10-question geography quiz with clues
- Score tracking
- Fun facts about destinations
- Friend challenge system
- Username selection
- Celebratory confetti animations
- Responsive design with modern UI components
Tech Stack
- Frontend Framework: Next.js 15.2.0
- UI Library: React 19.0.0
- Styling: Tailwind CSS 4.0.9
- Animation: Custom animations, Framer Motion
- Icons: Lucide React
- HTTP Client: Axios
- Storage: Cookies and SessionStorage
- Unique IDs: UUID
Folder Structure
π project-root
βββ π pages
β βββ π api
β β βββ destinations.js # Fetches destination data from MongoDB
β β βββ users.js # Manages user scores and game history
β β βββ challenges/[id].js # Fetches challenge data based on game ID
β βββ _app.js # Main application wrapper
β βββ _document.js # Custom document structure
β βββ index.js # Main game logic
βββ π components
β βββ Confetti.js # Displays confetti animation on correct answers
β βββ FriendChallengeInfo.js # Displays friend challenge notifications
β βββ GameResultModal.js # Shows final game results and challenges
β βββ QuizGame.js # Main quiz game logic
βββ π styles
β βββ globals.css # Global styles
βββ .env.local # Environment variables (MongoDB connection)
βββ package.json # Project dependencies
βββ README.md # Project documentation
Component Structure
Core Game Components
QuizGame.js
The main game component that orchestrates the quiz experience.
Features:
- Fetches destination data from API
- Manages game state (current question, options, scores)
- Handles answer selection and validation
- Displays feedback for correct/incorrect answers
- Shows fun facts about destinations
- Controls game flow from start to completion
- Integrates with challenge system
GameResultModal.js
Displays the final results when the quiz is completed.
Features:
- Shows final score with visual feedback
- Provides performance message based on score percentage
- Displays comparison results for challenges
- Contains options to restart or challenge friends
- Integrates with username system
WelcomeModal.js
The initial screen users see when starting the game.
Features:
- Introduces the game concept
- Displays challenge information if applicable
- Provides start button to begin quiz
Challenge System
SharePopup.js (referenced but not included in the code samples)
Allows users to challenge friends by sharing their score.
Features:
- Facilitates username collection
- Generates shareable links for challenges
- Displays comparison results
FriendChallengeInfo.js
Displays information about an incoming challenge.
Features:
- Shows challengerβs username
- Displays challengerβs score
- Provides a dismissible notification
UI Components
StylizedButton.js
A customizable button component with various styles.
Features:
- Multiple variants (primary, secondary, outline, rounded)
- Size options (small, medium, large)
- Width control (full-width option)
- Disabled state styling
- Animation effects
- Customizable with additional classes
Confetti.js
Creates a celebratory confetti animation effect.
Features:
- Custom particle generation
- Purple-themed color scheme with accents
- Animation for falling effect
- Automatic cleanup after display
UsernameModal.js
Modal for selecting and validating a username.
Features:
- Real-time username availability checking
- Validation for length and character restrictions
- Error feedback
- Loading state during API checks
API Integration
The application interacts with several backend API endpoints:
/api/destinations: Fetches the list of destinations with clues and fun facts
/api/users: Validates username availability
/api/challenges/{id}: Retrieves challenge information
User Flow
-
Initial Load:
- User sees the Welcome Modal
- If thereβs a challenge in the URL, challenge info is displayed
-
Quiz Gameplay:
- User is presented with 1-2 clues about a destination
- Four possible answers are shown
- User selects an answer and receives immediate feedback
- Fun facts are displayed about the destination
- Score is tracked at the top of the screen
-
Game Completion:
- After 10 questions, the Game Result Modal appears
- User sees their final score and performance message
- If responding to a challenge, comparison results are shown
-
Challenge Creation:
- User can click βChallenge a Friendβ button
- If they donβt have a username, theyβre prompted to create one
- A shareable link is generated with their score
-
Challenge Response:
- When a user follows a challenge link, they see the challengerβs info
- After completing the quiz, they see how they compared
State Management
The application uses Reactβs useState and useEffect hooks for state management:
- Game state (current question, options, scores)
- User information (username)
- Challenge data
- UI states (loading, errors, modals)
Session storage is used to persist the username between sessions.
UI/UX Features
- Color Theme: Purple-based gradient with accent colors
- Interactive Elements: Buttons with hover and active states
- Feedback: Visual and textual feedback for answers
- Animations: Confetti for correct answers
- Loading States: Skeleton loaders during API calls
- Responsive Design: Adapts to different screen sizes
CSS and Styling
The project uses Tailwind CSS with custom utility classes:
accent-gradient: Purple gradient for primary elements
purple-card: Card styling with purple accents
accent-gradient-btn: Button styling with gradient background
Error Handling
The application includes error handling for:
- API request failures
- Username validation
- Challenge information retrieval
Future Enhancements
Potential areas for further development:
- Leaderboards for top scores
- Additional quiz categories
- Achievement system
- Social media integration
- Profile customization
- More detailed analytics of user performance