Skip to content

Backend for a "Trip Mate" website built with Express.js, Mongoose, and MongoDB. Includes user authentication, booking functionality, and APIs for managing tours, users, and bookings.

Notifications You must be signed in to change notification settings

NiharMondal/trip-mate-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌍 TripMate - Travel & Trip Management Backend API

TripMate is a RESTful API backend for a travel-based application where users can create trips, join others' trips, and explore new destinations. The application supports role-based access, secure authentication, dynamic filtering, and trip management functionality.

🚀 Features

  • 🧳 Create and manage personal trip events
  • 🤝 Request to join others' trips
  • 🔐 Role-based access control (Admin, User)
  • 🔎 Advanced trip search, filtering, sorting & pagination
  • ✅ Trip owner can accept/decline join requests
  • 🧑‍💼 Admin dashboard with full user/trip management
  • 🔒 JWT-based authentication and authorization
  • 📚 RESTful APIs with proper route separation and structure

🛠️ Technologies Used

Technology Description
Node.js JavaScript runtime
Express.js Web framework for Node.js
MongoDB NoSQL database
Mongoose ODM for MongoDB
JWT Authentication
dotenv Environment variable management
bcryptjs Password hashing
cors Cross-origin resource sharing
nodemailer Send email

🔐 Authentication & Authorization

  • JWT-based login system
  • Passwords hashed using bcryptjs
  • Role-based route protection:
    • admin: can manage users and all trips
    • user: can create, update, or join trips

🔍 API Features

  • Auth
    • Register / Login / Logout
    • JWT Token-based access
  • Trip
    • Create, Read, Update, Delete (CRUD)
    • Search by title/destination
    • Filter by date, location, category
    • Sort by date, popularity, etc.
    • Pagination support
  • Join Request
    • Request to join other's trip
    • Accept or reject join request
  • Admin
    • View all trips and users
    • Ban/unban users or remove trips

📦 Installation & Setup

1. Clone the Repository

git clone https://github.com/NiharMondal/trip-mate-backend
cd tripmate-backend

2. Install Dependencies

npm install

3. Create a .env File

NODE_ENV
FRONT_END_URL
MONGO_URI
JWT_SECRET
EMAIL #your app password email
PASSWORD #app password credentials

4. Run the Server

npm run dev

The server will start on http://localhost:5000

📌 Future Improvements

  • Email notifications
  • Payment gateway integration
  • Real-time updates using WebSocket (e.g., join request notifications)

🧑 Author

Nihar Mondal
LinkedIn | Portfolio | GitHub

API Routes

Public Routes

  • Get Related Trips

    GET /related-trip/:id
  • Get Freshly Added Trips

    GET /freshly-added
  • Get Popular Trips

    GET /popular-trip
  • Get Trip by ID

    GET /by-id/:id
  • Get Trip by Slug

    GET /:slug
  • Get Top Destination

    GET /top-destination

User Authentication

  • Register
    POST /auth/register
  • Login
    POST /auth/login
  • Update Profile
    PATCH /user/profile/:userId

User Trip Management

  • Get User's Trips
    GET /my-trip/:userId
  • Create a Trip
    POST /trip
  • Update a Trip
    PATCH /trip/:id
  • Delete a Trip
    DELETE /trip/:id

Buddy Requests

  • Send Buddy Request
    POST /buddy-request
  • Accept Buddy Request
    PATCH /buddy-request/:id/accept

Reviews & Approval

  • Submit a Review
    POST /reviews
  • Admin Approve Review
    PATCH /reviews/:id/approve

About

Backend for a "Trip Mate" website built with Express.js, Mongoose, and MongoDB. Includes user authentication, booking functionality, and APIs for managing tours, users, and bookings.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published