Skip to content

Latest commit

Β 

History

26 Commits

Folders and files

Repository files navigation

🏑 StaySphere - Modern Vacation Rental & Booking Platform

Node.js Express.js MongoDB Deploy to Render License: ISC

StaySphere Banner

StaySphere is a full-stack vacation rental marketplace web application (Airbnb alternative) engineered with Node.js, Express, MongoDB, EJS, and Bootstrap 5. It features full property listing CRUD, dynamic cloud image uploads with Cloudinary, interactive geolocation maps with Mapbox & Leaflet, an end-to-end booking & reservation engine, payment processing with Razorpay & Sandbox, star ratings, category filtering, and robust role-based authentication.


πŸš€ One-Click Cloud Deployment

Deploy your own live instance of StaySphere in seconds:

Deploy to Render


✨ Key Features & Capabilities

1. πŸ” Role-Based Authentication & Authorization

  • User Roles: Supports Guest, Host, and Admin permissions.
  • Passport.js Integration: Secure salted-and-hashed authentication with persistent session cookies.
  • Granular Authorization Middleware:
    • isLoggedIn: Guard for protected actions (booking, listing, writing reviews).
    • isOwner: Restricts property edits and deletions to verified listing owners.
    • isBookingOwner: Authorizes only the reserving guest, host, or admin to access booking invoices or perform cancellations.
    • isReviewAuthor: Restricts review deletion to original author and listing host.
  • User & Host Profile Dashboard (/profile):
    • Manage user profile details, phone number, and avatar.
    • View and manage hosted properties.
    • Live Host Revenue Metrics (total bookings, net earnings).

2. πŸ“… Smart Booking & Reservation Engine

  • Interactive Booking Widget on Listing Show Page:
    • Dynamic Check-In and Check-Out date selection with automated minimum-date validation.
    • Guest quantity selector.
    • Live Real-time Price Calculator: Computes night stay subtotal, cleaning fees, 18% GST government tax, and total payable amount on the fly.
  • "My Trips & Bookings" Portal (/bookings):
    • View all active, upcoming, and past reservations.
    • Live status tracking (Confirmed, Pending, Cancelled).
  • Printable Reservation Ticket & Invoice (/bookings/:id):
    • Printable boarding-pass style invoice with unique booking reference ID, stay schedule, host contact info, and itemized billing.
  • Host Reservations Management (/listings/:id/reservations):
    • Dedicated portal for hosts to view all incoming guest reservations and track gross payouts.

3. πŸ’³ Payment Processing (Razorpay + Sandbox)

  • Razorpay Integration: Official Razorpay checkout supporting Debit/Credit Cards, UPI, QR, and NetBanking.
  • Instant Test Sandbox Mode: Seamless testing environment allowing full checkout simulation and verified order receipts without requiring live payment credentials.
  • Cryptographic Signature Verification: Server-side HMAC SHA-256 signature verification ensuring fraud protection.

4. πŸ—ΊοΈ Dual Interactive Maps (Leaflet + Mapbox GL)

  • Zero-Setup Leaflet / OpenStreetMap Fallback: Interactive map with custom branding pins works out of the box with zero external API key requirements.
  • Mapbox GL JS Upgrade: Automatically upgrades to high-definition vector map tiles with fly-to zoom animations and popup cards when MAP_TOKEN is supplied.

5. 🏑 Property Listings & Exploration

  • Full CRUD Management: Create, view, edit, and delete accommodation listings with rich descriptions, pricing, and amenities.
  • Multi-Category Quick Filters: Real-time filtering by categories (Rooms, Iconic cities, Mountains, Castles, Amazing pools, Camping, Farms, Arctic, Domes, Boats).
  • Multi-Field Search: Real-time search by Title, City, Country, Category, and Maximum Price.
  • Price Tax Switcher: Instant toggle to preview night rates inclusive of 18% GST.

6. πŸ“Έ Cloud Image Storage & Reviews

  • Cloudinary Storage: Automated image optimization and cloud upload handling with Multer.
  • Starability Star Ratings: User feedback system with interactive animated star ratings and review moderation.

πŸ› οΈ Tech Stack & Architecture

                               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                               β”‚   Client / Browser     β”‚
                               β”‚ (EJS, Bootstrap, JS)   β”‚
                               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                           β”‚ HTTP / REST
                               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                               β”‚  Express.js & Node.js  β”‚
                               β”‚  (MVC Controller Core) β”‚
                               β””β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”˜
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β”‚        β”‚   └───────────────────────┐
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”             β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β” β”Œβ”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Passport.js &   β”‚             β”‚  MongoDB   β”‚ β”‚  Cloudinary     β”‚ β”‚   Mapbox GL &    β”‚
β”‚  Session Store   β”‚             β”‚   Atlas    β”‚ β”‚  (Media Upload) β”‚ β”‚     Leaflet      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  • Backend: Node.js, Express.js
  • Database: MongoDB, Mongoose ODM
  • Templating & UI: EJS, EJS-Mate, Bootstrap 5, FontAwesome 6
  • Authentication: Passport.js, Passport-Local, Passport-Local-Mongoose
  • Payments: Razorpay Node SDK, Client Checkout Modal, Test Sandbox
  • Cloud Storage: Cloudinary, Multer, Multer-Storage-Cloudinary
  • Maps & Geolocation: Leaflet, OpenStreetMap, Mapbox GL JS, Mapbox Geocoding SDK
  • Session & Flash: Express-Session, Connect-Mongo, Connect-Flash
  • Validation: Joi Object Schema Validation

πŸ“ Project Directory Structure

StaySphere/
β”œβ”€β”€ controllers/          # MVC Controllers
β”‚   β”œβ”€β”€ bookings.js       # Booking reservations & payment handlers
β”‚   β”œβ”€β”€ listings.js       # Listing CRUD, search & filtering
β”‚   β”œβ”€β”€ reviews.js        # Review creation & deletion
β”‚   └── users.js          # Authentication & user profile dashboard
β”œβ”€β”€ models/               # Mongoose Schemas
β”‚   β”œβ”€β”€ booking.js        # Booking model with billing & payment status
β”‚   β”œβ”€β”€ listing.js        # Listing model with GeoJSON & cascade delete
β”‚   β”œβ”€β”€ review.js         # Review model with author relation
β”‚   └── user.js           # User model with roles (guest, host, admin)
β”œβ”€β”€ routes/               # Express Routes
β”‚   β”œβ”€β”€ booking.js        # /bookings endpoints
β”‚   β”œβ”€β”€ listing.js        # /listings endpoints
β”‚   β”œβ”€β”€ review.js         # /listings/:id/reviews endpoints
β”‚   β”œβ”€β”€ static.js         # Static /terms and /privacy routes
β”‚   └── user.js           # /login, /signup, /profile routes
β”œβ”€β”€ views/                # EJS UI Templates
β”‚   β”œβ”€β”€ bookings/         # My Bookings, Checkout, Invoice Receipt views
β”‚   β”œβ”€β”€ includes/         # Navbar, Footer, Flash notification alerts
β”‚   β”œβ”€β”€ layouts/          # Boilerplate HTML layout
β”‚   β”œβ”€β”€ listings/         # Index, Show, New, Edit, Reservations views
β”‚   └── users/            # Login, Signup, Profile views
β”œβ”€β”€ public/               # Static Client Assets
β”‚   β”œβ”€β”€ css/              # style.css, rating.css, loader.css, staysphere.css
β”‚   β”œβ”€β”€ js/               # map.js, script.js
β”‚   └── icon/             # Screenshots, logos, favicon
β”œβ”€β”€ init/                 # Seed data sets
β”œβ”€β”€ cloudConfig.js        # Cloudinary & Multer configuration
β”œβ”€β”€ middleware.js         # Authorization & validation middlewares
β”œβ”€β”€ schema.js             # Joi input validation schemas
β”œβ”€β”€ seed.js               # Database seeding utility
β”œβ”€β”€ app.js                # Main Express Application entry point
β”œβ”€β”€ render.yaml           # Render Blueprint configuration
β”œβ”€β”€ vercel.json           # Vercel serverless configuration
β”œβ”€β”€ .env.example          # Environment variables template
└── README.md             # Project documentation

πŸ’» Local Development Setup

1. Prerequisites

  • Node.js (v18.0 or higher)
  • MongoDB (Local MongoDB Server or MongoDB Atlas cloud URI)
  • Git

2. Clone the Repository & Install Dependencies

git clone https://github.com/PREM-A261/StaySphere.git
cd StaySphere
npm install

3. Configure Environment Variables

Create a .env file in the root directory:

# MongoDB Connection URL (Local or Atlas)
ATLASDB_URL=mongodb://127.0.0.1:27017/staysphere

# Express Session Secret
SECRET=your_super_secret_session_key_2026

# Cloudinary Credentials (Optional for local test)
CLOUD_NAME=your_cloudinary_cloud_name
CLOUD_API_KEY=your_cloudinary_api_key
CLOUD_API_SECRET=your_cloudinary_api_secret

# Mapbox Token (Optional: Leaflet will work automatically if omitted)
MAP_TOKEN=your_mapbox_public_token

# Razorpay (Optional: Sandbox test checkout works automatically if omitted)
RAZORPAY_KEY_ID=your_razorpay_key_id
RAZORPAY_KEY_SECRET=your_razorpay_key_secret

# Server Port (default 8080)
PORT=8080

4. Seed the Database with Sample Data

Run the seeding script to initialize sample hosts, guests, listings, and reservations:

npm run seed

Default Seed Demo Accounts:

Role Username Password
Host Admin staysphere_admin Admin@12345
Demo Guest demo_guest Guest@12345

5. Start the Server

npm start

Visit http://localhost:8080 in your browser.


🌐 Production Cloud Deployment Guide

Deploy to Render (Recommended)

  1. Click the Deploy to Render button: Deploy to Render
  2. Connect your GitHub account and select this repository.
  3. Configure the following environment variables:
    • ATLASDB_URL: Your MongoDB Atlas connection URI (mongodb+srv://...)
    • SECRET: Random session secret string
    • CLOUD_NAME, CLOUD_API_KEY, CLOUD_API_SECRET: (Optional) Cloudinary credentials
    • MAP_TOKEN: (Optional) Mapbox public access token
    • RAZORPAY_KEY_ID, RAZORPAY_KEY_SECRET: (Optional) Razorpay credentials
  4. Click Create Web Service. Render will automatically build and deploy the app.

Deploy to Vercel

  1. Import PREM-A261/StaySphere on Vercel.
  2. Under Project Settings > Environment Variables, add ATLASDB_URL, SECRET, and cloud credentials.
  3. Deploy via vercel.json.

πŸ“„ License

This project is licensed under the ISC License.


πŸ‘€ Author

Prem Pawar