How vashu4832/wanderlust works
Project type and purpose
• Full-stack web application named “WanderLust” for browsing, adding, and booking vacation properties.
• Front-end: EJS templates, HTML/CSS/JS, Mapbox for maps, responsive design.
• Back-end: Node.js/Express REST API, Passport.js authentication (local, Google, GitHub), session management.
• Database: MongoDB Atlas for listings, users, reviews.
• External services: Cloudinary for image storage, Mapbox API, OAuth providers.
File structure
• Top-level files
– app.js: entry point that configures Express, middleware, routes
– cloudConfig.js: Cloudinary setup
– schema.js & init/: input validation schemas and one-time data seeding scripts
– middleware.js & utils/: custom error handling and async wrapper
• Directories
– controllers/: business logic for listings, reviews, users
– routes/: route definitions mapped to controllers
– models/: Mongoose models for Listing, Review, User
– views/: EJS templates organized by layouts, includes, listings, users, error
– public/: static assets (CSS, JS) including map.js for client-side Mapbox integration
• Configuration & deployment
– package.json/package-lock.json: dependencies
– cloudConfig.js & .env variables for API keys
– Render config implied in README
README for additional insights
• MVC architecture is explicitly used
• Technology stack and major features (search/filter, reviews, session and cookie management, Multer uploads)
• Deployment details: Render + MongoDB Atlas
• Third-party integrations: Mapbox API, Cloudinary, Passport OAuth strategies
Main components
• Client (Browser)
– EJS-rendered pages, static JS (search, map integration), CSS
• Web Server (Express)
– Middleware layer (session, flash, cookie parsing, error handler, validation)
– Routes → Controllers → Models
– Auth layer (Passport strategies + session store via Connect-Mongo)
– File upload handler (Multer)
• Database
– MongoDB Atlas (Listings, Users, Reviews collections)
– Session store in MongoDB
• External Services
– Cloudinary for image upload/storage
– Mapbox API for map tiles and geocoding
– OAuth Providers (Google, GitHub) for authentication
• Deployment Platform
– Render (hosting Express server)
Relationships and interactions
• Server → MongoDB (CRUD via Mongoose)
• Server → Cloudinary (upload/retrieve images)
• Server → Mapbox (geocoding, map tiles)
• Server ↔ OAuth Providers (token exchange, callback flows)
• Session store: Express Session ↔ MongoDB
Architectural patterns and design principles
• MVC separation: clear division between Models, Views, Controllers
• Layered middleware pipeline in Express
• RESTful API endpoints for listing and review operations
• Single responsibility in controllers and utils (wrapAsync, ExpressError)
• Modular EJS partials for reusable UI components
• Security: data validation via Joi (schema.js), sanitization, Passport sessions