Skip to content

sleepingCoder7/tour-connect-backend

Repository files navigation

🌍 Tour Connect Backend ✈️

Node.js Express.js MongoDB Swagger

Welcome to the Tour Connect backend! This is a robust Express.js & MongoDB-powered REST API designed for managing and organizing guided tours. It features full CRUD operations, detailed Swagger API documentation, and advanced logging capabilities. The backend is built with Node.js, Express.js, and MongoDB, and comes with a beautiful vanilla front-end to interact directly with the API.


✨ Key Features

  • 🚀 RESTful Architecture:
  • 📖 Swagger UI Documentation:
  • 💾 MongoDB Integration:
  • 📝 Advanced Logging:
  • 🎨 Built-in Dashboard:

🛠️ Tech Stack


📂 Folder Structure

📦 tour-connect-backend
 ┣ 📂 config            # Logging and configuration files (e.g., logger.js)
 ┣ 📂 controllers       # Core business logic methods for different routes
 ┣ 📂 middlewares       # Express middleware functions
 ┣ 📂 models            # Mongoose schemas representing database collections
 ┣ 📂 postman           # Postman collection for testing
 ┣ 📂 public            # Frontend assets (HTML, CSS, JS dashboard)
 ┣ 📂 routes            # Express router setups mapping URLs to controllers
 ┣ 📂 swagger           # Swagger configuration and implementation definitions
 ┣ 📂 tests             # Unit tests
 ┣ 📂 utils             # Utilities, e.g., dummy tour generation script
 ┣ 📂 validators        # Validation logic for request data
 ┣ 📜 app.js            # Express application setup, middlewares, and mounting
 ┣ 📜 index.js          # Entry point that connects to DB and starts the server
 ┗ 📜 package.json      # Dependencies and project scripts

⚙️ Pre-requisites

Make sure you have the following installed on your machine:

  • Node.js: v20.0.0 or higher
  • MongoDB: Locally installed or access to a MongoDB Atlas cluster URI

🚀 Installation & Setup

1. Clone the repository

git clone https://github.com/your-username/tour-connect-backend.git
cd tour-connect-backend

2. Install dependencies

npm install

3. Configure Environment Variables Create a .env file in the root directory and add:

PORT=3000
MONGO_URI=your_mongodb_connection_string
BASE_URL=http://localhost:3000

4. Run the application For development (uses nodemon to auto-restart):

npm run dev

For production:

npm start

The server will be running normally on http://localhost:3000.


🌐 API Overview & Endpoints

The base API route path is /tour.

Method Endpoint Description
GET /tour Fetch all available tours
POST /tour Create a new tour
GET /tour/:id Fetch a specific tour by its ID
PUT /tour/:id Update a specific tour fully
DELETE /tour/:id Delete a specific tour from the DB

📚 Interactive API Documentation (Swagger)

This project makes API testing and implementation simple using a built-in Swagger interface. Once the server is running, navigate to:

👉 http://localhost:3000/api-docs

Here, you can learn about expected request bodies and schema requirements, and natively execute requests to test response states.


🖥️ Mini Dashboard Access

This project features a neatly-styled built-in Vanilla frontend to easily test API endpoints visually. Start the server and immediately open your browser, navigating to:

👉 http://localhost:3000

You'll see a dashboard interface featuring:

  • All Tours fetcher
  • Fetch Tour for a specific tour
  • Create Tour with all details
  • Update Tour information
  • Delete Tour for a specific tour

📊 Request Logging Overview

All HTTP requests hitting the server endpoints are logged using morgan library.


Crafted with ❤️ by Durga Prasad Kar

About

A tour connect backend application to store and fetch tour information using mongo DB

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors