A full-featured property rental web application built with Node.js, Express, and MongoDB. Vistayr is a modern accommodation booking platform that allows users to list properties, search for rentals, and manage bookings seamlessly.
- Features
- Tech Stack
- Prerequisites
- Installation
- Configuration
- Running the Application
- Project Structure
- API Routes
- Usage Guide
- Contributing
- License
- User Registration & Login: Secure authentication using Passport.js with local strategy
- Role-Based Access: Users can be either hosts (property owners) or guests (renters)
- User Dashboard: View profile, manage listings, and track bookings
- Password Security: Passwords are hashed and salted automatically
- Create Listings: Hosts can create new property listings with detailed information
- Edit & Delete: Hosts can update or remove their listings
- Image Upload: Upload property images directly to Cloudinary for secure cloud storage
- Categories: Organize listings by property type (apartments, houses, villas, etc.)
- Geolocation: View property locations on interactive Mapbox maps
- Instant Booking: Option to enable instant booking for properties
- Book Properties: Guests can book properties for specific date ranges
- Booking Status: Track booking status (waiting, confirmed, canceled, completed)
- Price Calculation: Automatic total price calculation based on number of nights
- View Bookings: Users can see all their bookings in one place
- Leave Reviews: Guests can rate and review properties they've booked
- Rating System: 5-star rating system for feedback
- Review Display: See reviews on property detail pages
- Search Listings: Find properties by keywords
- Category Filter: Browse properties by category (apartments, houses, villas, etc.)
- Advanced Filters: Filter by location, price range, and more
- Search Results: View filtered results with property previews
- Save Favorites: Guests can add properties to their wishlist
- Manage Wishlist: View and manage saved properties from the dashboard
- Flash Messages: Real-time feedback on actions (success, error notifications)
- Session Management: Secure session handling with MongoDB session store
- Error Handling: Custom error pages and comprehensive error management
- Data Validation: Input validation using Joi schema validation
- Responsive Design: Mobile-friendly interface
- Node.js (v22.11.0) - JavaScript runtime
- Express.js (v4.21.2) - Web framework
- MongoDB - NoSQL database
- Mongoose (v8.9.3) - MongoDB object modeling
- Passport.js (v0.7.0) - Authentication middleware
- Passport-Local (v1.0.0) - Local authentication strategy
- Passport-Local-Mongoose (v8.0.0) - Mongoose integration for Passport
- Express-Session (v1.18.1) - Session management
- Connect-Mongo (v5.1.0) - MongoDB session store
- EJS (v3.1.10) - Templating engine
- EJS-Mate (v4.0.0) - Layout support for EJS
- CSS - Custom styling with Bootstrap
- JavaScript - Client-side interactivity
- Multer (v1.4.5-lts.1) - File upload middleware
- Cloudinary (v1.41.3) - Cloud storage service
- Multer-Storage-Cloudinary (v4.0.0) - Cloudinary integration for Multer
- Joi (v17.13.3) - Data validation
- Connect-Flash (v0.1.1) - Flash message middleware
- Method-Override (v3.0.0) - HTTP method override
- Mapbox SDK (v0.16.1) - Interactive maps
- dotenv (v16.4.7) - Environment variable management
Before you begin, ensure you have the following installed:
- Node.js (v22.11.0 or later)
- npm (Node Package Manager)
- MongoDB Atlas account (for cloud database) or local MongoDB installation
- Cloudinary account (for image hosting)
- Mapbox account (for maps functionality)
git clone https://github.com/yourusername/vistayr.git
cd vistayrnpm installCreate a .env file in the root directory with the following variables:
NODE_ENV=production
ATLASDB_URL=mongodb+srv://username:password@cluster.mongodb.net/vistayr
SECRET=your_secret_key_here
# Cloudinary Configuration
CLOUD_NAME=your_cloudinary_name
CLOUD_API_KEY=your_cloudinary_api_key
CLOUD_API_SECRET=your_cloudinary_api_secret
# Mapbox Configuration
MAPBOX_TOKEN=your_mapbox_tokenHow to get these credentials:
- MongoDB Atlas: Create a free account at mongodb.com/cloud/atlas
- Cloudinary: Sign up at cloudinary.com
- Mapbox: Register at mapbox.com
The application automatically reads from .env file using dotenv. In production, make sure NODE_ENV=production is set.
MongoDB connection is established in app.js using the ATLASDB_URL from environment variables.
- Sessions are stored in MongoDB
- Cookie expiration: 7 days
- Session timeout: 24 hours
node app.jsThe server will start on http://localhost:8080
GET /- Home pageGET /login- Login pagePOST /login- Submit login formGET /signup- Sign up pagePOST /signup- Create new accountGET /logout- Logout userGET /dashboard- User dashboardGET /bookings- View user bookingsGET /wishlist- View wishlist
GET /listings- View all listingsGET /listings/new- Create new listing (for hosts)POST /listings- Submit new listingGET /listings/:id- View listing detailsGET /listings/:id/edit- Edit listingPUT /listings/:id- Update listingDELETE /listings/:id- Delete listingGET /listings/category/:category- View listings by categoryGET /listings/search- Search listings
GET /bookings- View all user bookingsPOST /bookings- Create new bookingGET /bookings/:id- View booking detailsPUT /bookings/:id- Update booking status
POST /listings/:id/reviews- Add review to listingDELETE /listings/:id/reviews/:reviewId- Delete review
- Sign Up: Create an account with your email
- Browse Properties: Explore listings by category or search
- View Details: Click on a property to see full details and map
- Book Property: Select dates and click "Book Now"
- Leave Review: After your stay, leave a rating and review
- Manage Bookings: View all your bookings in the dashboard
- Save Favorites: Add properties to your wishlist
- Sign Up: Create an account
- Verify Role: Set your account as a "Host"
- Create Listing: Click "List Your Property" and fill in details
- Upload Images: Add photos from Cloudinary
- Set Pricing: Enter nightly rate and booking options
- Manage Listings: Edit or delete your listings
- Track Bookings: See who has booked your properties
- Read Reviews: Get feedback from guests
vistayr/
βββ controllers/ # Business logic for routes
β βββ listings.js
β βββ bookings.js
β βββ reviews.js
β βββ users.js
βββ models/ # Mongoose schemas
β βββ listing.js
β βββ booking.js
β βββ review.js
β βββ user.js
βββ routes/ # Route definitions
β βββ listing.js
β βββ booking.js
β βββ review.js
β βββ user.js
βββ views/ # EJS templates
β βββ layouts/
β βββ listings/
β βββ users/
β βββ includes/
βββ public/ # Static files
β βββ css/
β βββ js/
β βββ images/
βββ utils/ # Utility functions
β βββ ExpressError.js
β βββ wrapAsync.js
βββ init/ # Database initialization
β βββ data_newFormat.js
βββ app.js # Application entry point
βββ middleware.js # Custom middleware
βββ schema.js # Joi validation schemas
βββ cloudConfig.js # Cloudinary configuration
βββ package.json # Dependencies
βββ .env # Environment variables
- Password hashing with salt
- CSRF protection through session tokens
- Input validation with Joi
- SQL injection prevention with Mongoose
- Secure session management
- HTTP-only cookies
- Authentication middleware for protected routes
- Authorization checks for resource ownership
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the ISC License - see the LICENSE file for details.
If you encounter any issues or have questions, please:
- Open an issue on GitHub
- Contact the project maintainer
- Check the existing issues for solutions
- Vistayr - A modern accommodation booking platform
- Built with Express.js documentation
- Cloudinary for image hosting
- Mapbox for mapping services
- MongoDB for database solutions
Happy Coding! π
If you find this project helpful, please give it a star β