Horental is a full-stack web application for listing and booking home rentals, similar to Airbnb. Built with Node.js, Express, MongoDB, and EJS, this platform enables users to create listings, leave reviews, and manage bookings seamlessly.
- User Authentication: Register, login, logout with session management
- Property Listings: Browse, create, edit, and delete listings
- Reviews System: Leave and delete reviews on property listings
- Image Upload: Upload & manage images using Cloudinary
- Authorization: Only owners can edit/delete their listings or reviews
- Responsive Design: Mobile-first UI with Bootstrap
- Flash Messages: Feedback for user actions
- Backend: Node.js, Express.js
- Database: MongoDB with Mongoose ODM
- Authentication: Passport.js (Local Strategy)
- Templating: EJS with EJS-Mate layouts
- File Upload: Multer + Cloudinary
- Styling: Bootstrap CSS + custom styles
- Sessions: Express-session + MongoDB store
- Node.js (v18.17.0 or higher)
- MongoDB Atlas account
- Cloudinary account
git clone https://github.com/Abhinandan-Sah/Horental.git
cd Horental
npm install
Create a .env
file in the root directory and add the following variables:
CLOUD_NAME=your_cloudinary_cloud_name
CLOUD_API_KEY=your_cloudinary_api_key
CLOUD_API_SECRET=your_cloudinary_api_secret
ATLASDB_URL=your_mongodb_atlas_connection_string
SECRET=your_session_secret_key
-
Cloudinary Credentials:
- Sign up at Cloudinary
- Go to Dashboard
- Copy your Cloud Name, API Key, and API Secret
-
MongoDB Atlas URL:
- Create account at MongoDB Atlas
- Create a new cluster
- Get connection string from "Connect" → "Connect your application"
- Replace
<password>
with your database user password
-
SECRET:
- Use any random string for session encryption
- Example:
mySecretKey123
To populate the database with sample listings:
node init/index.js
npm start
The application will be
Horental/
├── controllers/ # Route handlers
│ ├── listings.js
│ ├── reviews.js
│ └── users.js
├── models/ # Database schemas
│ ├── listing.js
│ ├── review.js
│ └── user.js
├── routes/ # Route definitions
│ ├── listing.js
│ ├── review.js
│ └── user.js
├── views/ # EJS templates
│ ├── layouts/
│ ├── listings/
│ ├── users/
│ └── includes/
├── public/ # Static assets
│ ├── css/
│ └── js/
├── utils/ # Utility functions
├── init/ # Database initialization
├── middleware.js # Custom middleware
├── schema.js # Joi validation schemas
├── cloudConfig.js # Cloudinary configuration
└── app.js # Main application file
markdown
Copy
Edit
GET /signup
– Signup formPOST /signup
– Register new userGET /login
– Login formPOST /login
– Authenticate userGET /logout
– Logout user
GET /listings
– All listingsGET /listings/new
– Create listing form (requires login)POST /listings
– Create listing (requires login)GET /listings/:id
– View a listingGET /listings/:id/edit
– Edit listing (owner only)PUT /listings/:id
– Update listing (owner only)DELETE /listings/:id
– Delete listing (owner only)
POST /listings/:id/reviews
– Add review (requires login)DELETE /listings/:id/reviews/:reviewId
– Delete review (author only)
GET /
– Redirect to listingsGET /book
– Booking page (requires login)
Function | Description |
---|---|
isLoggedIn |
Verifies user is authenticated |
isOwner |
Checks if user is the owner of the listing |
isReviewAuthor |
Checks if user is the author of a review |
validateListing |
Validates listing data using Joi |
validateReview |
Validates review data using Joi |
- Node.js
v18.17.0+
- MongoDB Atlas account
- Cloudinary account
🚀 Deployment This app is configured for Vercel using vercel.json. To deploy on other platforms:
Ensure Node.js ≥ 18.17.0
Set all required .env variables
MongoDB Atlas must be accessible
🤝 Contributing Fork this repo
Create a new branch git checkout -b feature-name
Commit your changes
Push and open a Pull Request
📄 License This project is licensed under the ISC License.