An open API service indexing awesome lists of open source software.

https://github.com/nandkumar1000/bookmystay

BookMyStay is an online accommodation booking system that allows users to book rooms from hotels, restaurants, villas, and more. Built with EJS, Node.js, MongoDB, and Passport.js for secure authentication.
https://github.com/nandkumar1000/bookmystay

bootstrap css ejs-template-engine expressjs html js mongodb mongoose nodejs passportjs restful-api

Last synced: 3 months ago
JSON representation

BookMyStay is an online accommodation booking system that allows users to book rooms from hotels, restaurants, villas, and more. Built with EJS, Node.js, MongoDB, and Passport.js for secure authentication.

Awesome Lists containing this project

README

          

# 🏨 **Welcome to BookMyStay!** 🌟

Hello there! πŸ‘‹ Welcome to **BookMyStay** – your ultimate online accommodation booking system! From cozy hotels 🏨 to luxurious villas 🏑, we've got a wide range of places you can book near you. Perfect for your next adventure! 🌍✨

---

## ✨ **Abstract**

**BookMyStay** allows users to seamlessly book rooms from a wide range of accommodations such as **hotels**, **restaurants**, **farmhouses**, **individual stays**, and **villas**. 🌟 It’s a secure platform πŸ” built using the **MVC (Model-View-Controller)** architecture for a modular and maintainable codebase. The platform supports **flash messages**, **session management**, and robust **authorization mechanisms** to provide an efficient, user-friendly experience for both travelers and property owners.

---

## πŸ› οΈ **Technology Stack**

We’ve used a powerful stack of technologies to bring this platform to life! πŸ’»πŸŽ‰

- **HTML5 & CSS3** 🌐 – Structured and styled web pages.
- **EJS** 🧩 – Dynamic web page rendering.
- **JavaScript** πŸ’» – Interactive features and smooth user experience.
- **Node.js & Express.js** πŸš€ – Backend logic, routing, and session handling.
- **MongoDB** πŸƒ – Stores all the accommodation listings and user details securely.
- **Bootstrap** 🎨 – Responsive design that looks great on any device.
- **Passport.js** πŸ”‘ – Provides secure user authentication and login features.
- **Express-Session** πŸ” – Manages user sessions.
- **Connect-Flash** ⚑ – Displays one-time messages for feedback, errors, or status updates.

---

## πŸ›‘οΈ **Security Features**

1. **Authentication**:
- Using **Passport.js** to securely log in users with encrypted credentials.
2. **Authorization**:
- Role-based access ensures admins and users access only their designated features.
- Admins can manage listings, while users can book accommodations.
3. **Session Management**:
- **Express-Session** tracks user sessions, ensuring persistent logins and access control.
4. **Flash Messages**:
- Powered by **Connect-Flash**, users receive clear feedback on actions like login errors, successful bookings, or unauthorized access.

---

## 🌟 **Features**

Here’s what **BookMyStay** offers:

- 🏨 **Easy Booking** – Users can browse and book rooms easily.
- ⭐ **Feedback System** – Share reviews and rate stays.
- πŸ” **Role-Based Authorization** –
- Users: Can book accommodations and leave reviews.
- Admins: Can manage listings (add, edit, delete).
- πŸ›‘οΈ **Flash Messages** –
- Success and error messages displayed dynamically (e.g., "Login successful," "Booking confirmed").
- πŸ“Ά **Session Tracking** – Users remain logged in until they manually log out.

---

## 🌐 **MVC Architecture**

**BookMyStay** follows the **MVC (Model-View-Controller)** pattern for organized and efficient code:

1. **Model**:
- Defines the structure of data using MongoDB schemas (e.g., `AccommodationModel`, `UserModel`).
2. **View**:
- EJS templates render dynamic content, allowing users to interact seamlessly.
3. **Controller**:
- Manages the business logic. For example:
- Validating user input.
- Communicating with models to fetch/update data.
- Redirecting users and displaying flash messages.

---

## πŸ—‚οΈ **File Structure**

```plaintext
πŸ“ BookMyStay/
β”œβ”€β”€ πŸ“ config/
β”‚ β”œβ”€β”€ passport.js # Passport.js configuration
β”‚ └── session.js # Express-session configuration
β”œβ”€β”€ πŸ“ controllers/
β”‚ β”œβ”€β”€ authController.js # Login/signup logic
β”‚ └── accommodationController.js # CRUD operations for accommodations
β”œβ”€β”€ πŸ“ models/
β”‚ β”œβ”€β”€ userModel.js # MongoDB schema for users
β”‚ └── accommodationModel.js # MongoDB schema for accommodations
β”œβ”€β”€ πŸ“ public/
β”‚ β”œβ”€β”€ css/ # CSS files for styling
β”‚ β”œβ”€β”€ js/ # Client-side JavaScript
β”‚ └── images/ # Images for the app
β”œβ”€β”€ πŸ“ routes/
β”‚ β”œβ”€β”€ authRoutes.js # Routes for authentication
β”‚ └── accommodationRoutes.js # Routes for accommodations
β”œβ”€β”€ πŸ“ views/
β”‚ β”œβ”€β”€ πŸ“„ index.ejs # Home page template
β”‚ β”œβ”€β”€ πŸ“„ login.ejs # Login form
β”‚ β”œβ”€β”€ πŸ“„ dashboard.ejs # Admin dashboard
β”‚ └── πŸ“„ error.ejs # Error page

```

---

## πŸš€ **How It Works**

### **Authentication and Authorization**

- **Login System**:
Users authenticate securely using Passport.js. Sessions are created to maintain login states.

- **Role-Based Access**:
Routes are protected to allow only authorized access based on user roles (e.g., admin routes are restricted).

---

### **Flash Messages**

- After critical actions (e.g., login, booking, or admin actions), flash messages provide instant feedback to users.
Example:
- **Success**: β€œYour booking was confirmed!”
- **Error**: β€œInvalid credentials. Please try again.”

### **Session Management**

- **Express-Session** keeps users logged in for the duration of their session, storing key details like user ID securely.
- Sessions are invalidated on logout, ensuring security.

---

## 🏁 **Conclusion**

**BookMyStay** is a highly secure, modular, and user-friendly accommodation booking platform. By implementing **MVC**, integrating **flash messages**, and ensuring robust **session management** and **authorization**, this platform provides a seamless experience for users and admins alike. 🌟

Thank you for exploring **BookMyStay**! Feel free to contribute or provide feedback as we make this platform even better. πŸŽ‰