A full-stack web application for listing and managing property rentals. This project is built with Node.js, Express, and MongoDB, featuring a dynamic EJS templating system for server-side rendering.
- Browse Listings: View all available property listings with images, descriptions, and pricing
- Create Listings: Add new property listings with title, description, image, price, location, and country
- View Details: Click on listings to see detailed information
- Edit Listings: Modify existing listing information
- Delete Listings: Remove listings from the database
- MongoDB Integration: Persistent data storage with MongoDB
- Responsive Design: EJS-based templating for dynamic content rendering
- Backend: Node.js & Express.js
- Database: MongoDB
- Templating: EJS (Embedded JavaScript)
- Form Handling: Method Override for PUT/DELETE requests
- Environment: dotenv for configuration management
Before running this project, ensure you have installed:
- Node.js (v14 or higher)
- npm (Node Package Manager)
- MongoDB (running locally or connection string available)
- Clone the repository:
git clone <repository-url>
cd airbnb- Navigate to the backend directory:
cd backend- Install dependencies:
npm install- Create a
.envfile in the backend directory (if needed for configuration)
-
Ensure MongoDB is running on your local machine at
mongodb://127.0.0.1:27017 -
Start the server:
node app.js- Open your browser and navigate to:
http://localhost:3000
backend/
├── app.js # Main Express application
├── package.json # Project dependencies
├── db/
│ └── db.js # Database configuration
├── init/
│ ├── index.js # Initialization script
│ └── data.js # Sample data for seeding
├── models/
│ └── listing.js # Mongoose schema for listings
└── views/
├── index.ejs # Listings list view
├── show.ejs # Single listing detail view
├── new.ejs # New listing form
└── edit.ejs # Edit listing form
{
title: String (required),
description: String (required),
image: String (default: unsplash image),
price: Number (required),
location: String (required),
country: String (required)
}| Method | Route | Description |
|---|---|---|
| GET | / |
Root endpoint |
| GET | /listings |
Get all listings |
| GET | /listings/new |
Show form to create new listing |
| POST | /listings |
Create a new listing |
| GET | /listings/:id |
Get listing details |
| GET | /listings/:id/edit |
Show form to edit listing |
| PUT | /listings/:id |
Update a listing |
| DELETE | /listings/:id |
Delete a listing |
- express - Web application framework
- mongoose - MongoDB object modeling
- ejs - Templating engine
- method-override - Middleware for HTTP method override
- dotenv - Environment variable management