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:

Tech Stack

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:

GameResultModal.js

Displays the final results when the quiz is completed.

Features:

WelcomeModal.js

The initial screen users see when starting the game.

Features:

Challenge System

SharePopup.js (referenced but not included in the code samples)

Allows users to challenge friends by sharing their score.

Features:

FriendChallengeInfo.js

Displays information about an incoming challenge.

Features:

UI Components

StylizedButton.js

A customizable button component with various styles.

Features:

Confetti.js

Creates a celebratory confetti animation effect.

Features:

UsernameModal.js

Modal for selecting and validating a username.

Features:

API Integration

The application interacts with several backend API endpoints:

User Flow

  1. Initial Load:

  2. Quiz Gameplay:

  3. Game Completion:

  4. Challenge Creation:

  5. Challenge Response:

State Management

The application uses React’s useState and useEffect hooks for state management:

Session storage is used to persist the username between sessions.

UI/UX Features

CSS and Styling

The project uses Tailwind CSS with custom utility classes:

Error Handling

The application includes error handling for:

Future Enhancements

Potential areas for further development:

  1. Leaderboards for top scores
  2. Additional quiz categories
  3. Achievement system
  4. Social media integration
  5. Profile customization
  6. More detailed analytics of user performance