A full-stack travel listing web application built with Node.js, Express, and MongoDB. WanderLust allows users to browse, create, and review travel destinations around the world.
- 🏠 Listing Management: Create, read, update, and delete travel listings
- ⭐ Reviews & Ratings: Add reviews and ratings (1-5 stars) to listings
- 🔐 User Authentication: Secure signup/login with Passport.js
- 👤 User Authorization: Only listing owners can edit/delete their listings
- 📝 Form Validation: Server-side validation using Joi
- ⚡ Flash Messages: User-friendly success and error notifications
- 🎨 Responsive Design: Built with EJS templating engine
- 🔒 Session Management: Secure session handling with express-session
- Node.js - Runtime environment
- Express.js - Web application framework
- MongoDB - NoSQL database
- Mongoose - MongoDB object modeling
- Passport.js - Authentication middleware
- Passport-Local - Local authentication strategy
- Passport-Local-Mongoose - Mongoose plugin for user authentication
- Joi - Schema validation
- Custom Error Handling - ExpressError utility
- EJS - Embedded JavaScript templating
- EJS-Mate - Layout support for EJS
- Method-Override - HTTP verb support (PUT, DELETE)
- Connect-Flash - Flash messages
- Express-Session - Session management
- Nodemon - Development auto-restart
Before running this project, make sure you have:
- Node.js (v14 or higher)
- MongoDB (running locally or MongoDB Atlas account)
- npm or yarn package manager
-
Clone the repository
git clone https://github.com/Shree-Gowda/WanderLust..git cd WanderLust -
Install dependencies
npm install
-
Set up MongoDB
- Make sure MongoDB is running locally on
mongodb://127.0.0.1:27017 - Or update the
MONGO_URLinapp.jsto your MongoDB connection string
- Make sure MongoDB is running locally on
-
Initialize the database (optional)
node init/index.js
This will populate the database with sample data.
-
Start the application
node app.js
Or for development with auto-restart:
nodemon app.js
-
Open your browser Navigate to
http://localhost:8080
WanderLust/
├── models/ # Mongoose models
│ ├── listing.js # Listing schema
│ ├── review.js # Review schema
│ └── user.js # User schema
├── routes/ # Express routes
│ ├── listing.js # Listing routes
│ ├── review.js # Review routes
│ └── user.js # User authentication routes
├── views/ # EJS templates
│ ├── listings/ # Listing views
│ ├── users/ # User views
│ └── layouts/ # Layout templates
├── public/ # Static files (CSS, JS, images)
├── utils/ # Utility functions
│ ├── ExpressError.js # Custom error class
│ └── wrapAsync.js # Async error wrapper
├── init/ # Database initialization
├── middleware.js # Custom middleware
├── schema.js # Joi validation schemas
├── app.js # Main application file
└── package.json # Dependencies
GET /listings- View all listingsGET /listings/new- Show create listing formPOST /listings- Create new listingGET /listings/:id- View single listingGET /listings/:id/edit- Show edit formPUT /listings/:id- Update listingDELETE /listings/:id- Delete listing
POST /listings/:id/reviews- Add review to listingDELETE /listings/:id/reviews/:reviewId- Delete review
GET /signup- Show signup formPOST /signup- Register new userGET /login- Show login formPOST /login- Authenticate userGET /logout- Logout user
For production, consider creating a .env file:
MONGO_URL=mongodb://127.0.0.1:27017/wanderlust
SESSION_SECRET=mysupersecretecode
PORT=8080Note: Remember to add
.envto.gitignore(already included)
The application uses Joi for server-side validation:
- Listing validation: Title, description, location, country, and price are required
- Review validation: Rating (1-5) and comment are required
- User validation: Email and username uniqueness
- Password hashing with Passport-Local-Mongoose
- Session-based authentication
- HTTP-only cookies
- CSRF protection ready
- Input validation and sanitization
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your 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 open source and available under the ISC License.
Shree Gowda
- GitHub: @Shree-Gowda
- Unsplash for placeholder images
- Express.js community
- MongoDB documentation
- Passport.js documentation
Happy Traveling!