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.
- Host: GitHub
- URL: https://github.com/nandkumar1000/bookmystay
- Owner: nandkumar1000
- Created: 2024-10-30T03:44:58.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-13T18:42:21.000Z (over 1 year ago)
- Last Synced: 2025-02-07T02:32:11.595Z (over 1 year ago)
- Topics: bootstrap, css, ejs-template-engine, expressjs, html, js, mongodb, mongoose, nodejs, passportjs, restful-api
- Language: JavaScript
- Homepage:
- Size: 125 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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. π