Skip to content

ashvinck/Globetrotter_Backend

Repository files navigation

🌍 Globetrotter Backend

The backend for Globetrotter - The Ultimate Travel Guessing Game!
Powered by Node.js, Express, MongoDB, Redis, and Socket.io, this backend handles game logic, user interactions, and real-time updates.

πŸ“Œ Table of Contents


πŸ› οΈ Features

βœ… AI-enhanced destination dataset – Uses a mix of AI tools and manual curation.
βœ… Rate-limited API – Protects against excessive requests.
βœ… Real-time multiplayer support – Powered by Socket.io.
βœ… Robust validation – Uses Joi for request validation.
βœ… Secure & optimized – Helmet, CORS, compression, and logging (Winston & Morgan).


πŸš€ Installation

1️⃣ Clone the Repository

git clone https://github.com/ashvinck/globetrotter-backend.git
cd globetrotter-backend

2️⃣ Install Dependencies

npm install

πŸ“Œ Environment Variables

Create a .env file in the root directory and define the following variables:

PORT=5000
MONGO_URI=mongodb+srv://your_username:your_password@cluster.mongodb.net/globetrotter
REDIS_URL=redis://localhost:6379

▢️ Running the Server

Development Mode

npm run dev

Production Mode

npm start

πŸ§ͺ Running Tests

npm test

To run tests in watch mode:

npm run test:watch

πŸ“‚ Project Structure

πŸ“¦ globetrotter-backend
β”œβ”€β”€ πŸ“‚ src
β”‚   β”œβ”€β”€ πŸ“‚ config          # Database and environment configuration
β”‚   β”œβ”€β”€ πŸ“‚ controllers     # Route handlers
β”‚   β”œβ”€β”€ πŸ“‚ middleware      # Express middleware (auth, validation, rate limiting, etc.)
β”‚   β”œβ”€β”€ πŸ“‚ models          # Mongoose models
β”‚   β”œβ”€β”€ πŸ“‚ routes          # API routes
β”‚   β”œβ”€β”€ πŸ“‚ services        # Business logic (game logic, scoring, AI integration, etc.)
β”‚   β”œβ”€β”€ πŸ“‚ utils           # Helper functions (logging, error handling, etc.)
β”‚   β”œβ”€β”€ index.js           # Main server file
β”œβ”€β”€ .env                   # Environment variables
β”œβ”€β”€ .gitignore             # Files to ignore in git
β”œβ”€β”€ package.json           # Dependencies and scripts
β”œβ”€β”€ README.md              # Documentation

πŸ“Œ API Endpoints

πŸ”Ή Game Logic

  • GET /destinations/get/random – Get random clues
  • POST /destinations/check-destination – Check user selected destination is correct or not

πŸ”Ή Admin

  • GET /destinations/get/all – Retrieve all destination info.
  • POST /api/admin/add-destination – Add new destinations.

🀝 Contributing

  1. Fork the repository
  2. Create a new branch (git checkout -b feature-branch)
  3. Commit your changes (git commit -m "Added new feature")
  4. Push to the branch (git push origin feature-branch)
  5. Open a pull request

πŸ“œ License

This project is licensed under the ISC License.


πŸš€ Happy Coding & Enjoy Exploring the World! πŸŒπŸŽ‰

About

This is a backend of the city guessing game Globetrotter based on clues.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published