# pavan9464/wanderlust architecture

> Architecture diagram of the GitHub repository pavan9464/wanderlust, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pavan9464/wanderlust
- Repository: https://github.com/pavan9464/wanderlust

## Overview

Wanderlust is a server-rendered travel-listing app. Visitors browse or search listings, then view listing details, reviews, and a map; registered users can create listings and reviews, while ownership and authorship checks protect edits and deletions. Listing writes validate input, upload images, and geocode locations; MongoDB holds listings, reviews, users, and sessions. The graph also shows authentication, shared error handling, and the documented sample-data seeding capability. Some view and seed relationships are based on README descriptions rather than sampled implementation excerpts.

Main entry points: [`app.js`](https://github.com/pavan9464/wanderlust/blob/main/app.js) (Express application), [`controllers/listingController.js`](https://github.com/pavan9464/wanderlust/blob/main/controllers/listingController.js) (Listing handlers), [`controllers/reviewController.js`](https://github.com/pavan9464/wanderlust/blob/main/controllers/reviewController.js) (Review handlers), [`models/Listing.js`](https://github.com/pavan9464/wanderlust/blob/main/models/Listing.js) (Listing model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Express application<br/>[app.js]"]
  node_error_page["Error page<br/>[error.ejs]"]
  node_search_script["Search behavior<br/>[script.js]"]
  node_map_script["Map display<br/>[map.js]"]
end

subgraph group_listings["Listings"]
  node_listing_routes["Listing routes<br/>[listings.js]"]
  node_listing_controller["Listing handlers"]
  node_listing_model["Listing model<br/>[Listing.js]"]
  node_listing_pages["Listing pages"]
end

subgraph group_reviews["Reviews"]
  node_reviews_routes["Review routes<br/>[review.js]"]
  node_review_controller["Review handlers"]
  node_review_model["Review model<br/>[review.js]"]
  node_review_pages["Review views<br/>[show.ejs]"]
end

subgraph group_identity["Identity and access"]
  node_user_routes["User routes<br/>[user.js]"]
  node_user_controller["User handlers<br/>[userController.js]"]
  node_user_model["User model<br/>[user.js]"]
  node_access_middleware["Access and validation<br/>[middelware.js]"]
  node_schemas["Input schemas<br/>[schema.js]"]
end

subgraph group_services["Storage and integrations"]
  node_mongodb[("MongoDB")]
  node_cloud_config["Image upload config<br/>[cloudConfig.js]"]
  node_cloudinary[("Cloudinary")]
  node_mapbox["Mapbox geocoding"]
  node_mapbox_gl["Mapbox GL JS"]
end

subgraph group_seed["Sample data"]
  node_seed_script["Seed script<br/>[index.js]"]
  node_seed_data["Sample listings<br/>[data.js]"]
end

node_visitor(("Visitor"))

node_visitor -->|"sends requests"| node_app
node_app -->|"mounts routes"| node_listing_routes
node_app -->|"mounts routes"| node_reviews_routes
node_app -->|"mounts routes"| node_user_routes
node_listing_routes -->|"dispatches to"| node_listing_controller
node_listing_routes -->|"checks access"| node_access_middleware
node_access_middleware -->|"validates with"| node_schemas
node_listing_controller -->|"reads and writes"| node_listing_model
node_listing_controller -->|"renders"| node_listing_pages
node_listing_controller -->|"uses uploads"| node_cloud_config
node_cloud_config -.->|"stores images"| node_cloudinary
node_listing_controller -->|"forward geocodes"| node_mapbox
node_listing_pages -.->|"provides map page"| node_map_script
node_map_script -.->|"renders map"| node_mapbox_gl
node_reviews_routes -->|"dispatches to"| node_review_controller
node_reviews_routes -->|"checks access"| node_access_middleware
node_review_controller -->|"loads listing"| node_listing_model
node_review_controller -->|"creates and deletes"| node_review_model
node_review_controller -->|"redirects to"| node_review_pages
node_user_routes -->|"dispatches to"| node_user_controller
node_user_routes -->|"uses access checks"| node_access_middleware
node_user_controller -->|"registers users"| node_user_model
node_app -->|"configures authentication"| node_user_model
node_app -->|"renders errors"| node_error_page
node_search_script -.->|"clears search"| node_listing_pages
node_listing_model -.->|"persists listings"| node_mongodb
node_review_model -.->|"persists reviews"| node_mongodb
node_user_model -.->|"persists users"| node_mongodb
node_seed_script -->|"loads sample data"| node_seed_data
node_seed_script -->|"inserts listings"| node_listing_model
node_seed_script -->|"geocodes samples"| node_mapbox

click node_app "https://github.com/pavan9464/wanderlust/blob/main/app.js"
click node_listing_routes "https://github.com/pavan9464/wanderlust/blob/main/routes/listings.js"
click node_listing_controller "https://github.com/pavan9464/wanderlust/blob/main/controllers/listingController.js"
click node_listing_model "https://github.com/pavan9464/wanderlust/blob/main/models/Listing.js"
click node_listing_pages "https://github.com/pavan9464/wanderlust/tree/main/views/listings"
click node_reviews_routes "https://github.com/pavan9464/wanderlust/blob/main/routes/review.js"
click node_review_controller "https://github.com/pavan9464/wanderlust/blob/main/controllers/reviewController.js"
click node_review_model "https://github.com/pavan9464/wanderlust/blob/main/models/review.js"
click node_review_pages "https://github.com/pavan9464/wanderlust/blob/main/views/listings/show.ejs"
click node_user_routes "https://github.com/pavan9464/wanderlust/blob/main/routes/user.js"
click node_user_controller "https://github.com/pavan9464/wanderlust/blob/main/controllers/userController.js"
click node_user_model "https://github.com/pavan9464/wanderlust/blob/main/models/user.js"
click node_access_middleware "https://github.com/pavan9464/wanderlust/blob/main/middelware.js"
click node_schemas "https://github.com/pavan9464/wanderlust/blob/main/schema.js"
click node_error_page "https://github.com/pavan9464/wanderlust/blob/main/views/error.ejs"
click node_search_script "https://github.com/pavan9464/wanderlust/blob/main/public/js/script.js"
click node_map_script "https://github.com/pavan9464/wanderlust/blob/main/public/js/map.js"
click node_cloud_config "https://github.com/pavan9464/wanderlust/blob/main/cloudConfig.js"
click node_seed_script "https://github.com/pavan9464/wanderlust/blob/main/init/index.js"
click node_seed_data "https://github.com/pavan9464/wanderlust/blob/main/init/data.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_error_page,node_search_script,node_map_script toneBlue
class node_listing_routes,node_listing_controller,node_listing_model,node_listing_pages toneAmber
class node_reviews_routes,node_review_controller,node_review_model,node_review_pages toneMint
class node_user_routes,node_user_controller,node_user_model,node_access_middleware,node_schemas toneRose
class node_mongodb,node_cloud_config,node_cloudinary,node_mapbox,node_mapbox_gl,node_visitor toneIndigo
class node_seed_script,node_seed_data toneTeal
```

## Components

### Web application

- [Express application](https://github.com/pavan9464/wanderlust/blob/main/app.js): `app.js`
- [Error page](https://github.com/pavan9464/wanderlust/blob/main/views/error.ejs): `views/error.ejs`
- [Search behavior](https://github.com/pavan9464/wanderlust/blob/main/public/js/script.js): `public/js/script.js`
- [Map display](https://github.com/pavan9464/wanderlust/blob/main/public/js/map.js): `public/js/map.js`

### Listings

- [Listing routes](https://github.com/pavan9464/wanderlust/blob/main/routes/listings.js): `routes/listings.js`
- [Listing handlers](https://github.com/pavan9464/wanderlust/blob/main/controllers/listingController.js): `controllers/listingController.js`
- [Listing model](https://github.com/pavan9464/wanderlust/blob/main/models/Listing.js): `models/Listing.js`
- [Listing pages](https://github.com/pavan9464/wanderlust/tree/main/views/listings): `views/listings`

### Reviews

- [Review routes](https://github.com/pavan9464/wanderlust/blob/main/routes/review.js): `routes/review.js`
- [Review handlers](https://github.com/pavan9464/wanderlust/blob/main/controllers/reviewController.js): `controllers/reviewController.js`
- [Review model](https://github.com/pavan9464/wanderlust/blob/main/models/review.js): `models/review.js`
- [Review views](https://github.com/pavan9464/wanderlust/blob/main/views/listings/show.ejs): `views/listings/show.ejs`

### Identity and access

- [User routes](https://github.com/pavan9464/wanderlust/blob/main/routes/user.js): `routes/user.js`
- [User handlers](https://github.com/pavan9464/wanderlust/blob/main/controllers/userController.js): `controllers/userController.js`
- [User model](https://github.com/pavan9464/wanderlust/blob/main/models/user.js): `models/user.js`
- [Access and validation](https://github.com/pavan9464/wanderlust/blob/main/middelware.js): `middelware.js`
- [Input schemas](https://github.com/pavan9464/wanderlust/blob/main/schema.js): `schema.js`

### Storage and integrations

- **MongoDB**
- [Image upload config](https://github.com/pavan9464/wanderlust/blob/main/cloudConfig.js): `cloudConfig.js`
- **Cloudinary**
- **Mapbox geocoding**
- **Mapbox GL JS**

### Sample data

- [Seed script](https://github.com/pavan9464/wanderlust/blob/main/init/index.js): `init/index.js`
- [Sample listings](https://github.com/pavan9464/wanderlust/blob/main/init/data.js): `init/data.js`

### Other components

- **Visitor**

## Connections

- Visitor → Express application: sends requests (evidence: `README.md`)
- Express application → Listing routes: mounts routes (evidence: `app.js`)
- Express application → Review routes: mounts routes (evidence: `app.js`)
- Express application → User routes: mounts routes (evidence: `app.js`)
- Listing routes → Listing handlers: dispatches to (evidence: `routes/listings.js`)
- Listing routes → Access and validation: checks access (evidence: `routes/listings.js`)
- Access and validation → Input schemas: validates with (evidence: `middelware.js`)
- Listing handlers → Listing model: reads and writes (evidence: `controllers/listingController.js`)
- Listing handlers → Listing pages: renders (evidence: `controllers/listingController.js`)
- Listing handlers → Image upload config: uses uploads (evidence: `controllers/listingController.js`)
- Image upload config → Cloudinary: stores images
- Listing handlers → Mapbox geocoding: forward geocodes (evidence: `controllers/listingController.js`)
- Listing pages → Map display: provides map page
- Map display → Mapbox GL JS: renders map
- Review routes → Review handlers: dispatches to (evidence: `routes/review.js`)
- Review routes → Access and validation: checks access (evidence: `routes/review.js`)
- Review handlers → Listing model: loads listing (evidence: `controllers/reviewController.js`)
- Review handlers → Review model: creates and deletes (evidence: `controllers/reviewController.js`)
- Review handlers → Review views: redirects to (evidence: `controllers/reviewController.js`)
- User routes → User handlers: dispatches to (evidence: `routes/user.js`)
- User routes → Access and validation: uses access checks (evidence: `routes/user.js`)
- User handlers → User model: registers users (evidence: `controllers/userController.js`)
- Express application → User model: configures authentication (evidence: `app.js`)
- Express application → Error page: renders errors (evidence: `app.js`)
- Search behavior → Listing pages: clears search
- Listing model → MongoDB: persists listings
- Review model → MongoDB: persists reviews
- User model → MongoDB: persists users
- Seed script → Sample listings: loads sample data (evidence: `README.md`)
- Seed script → Listing model: inserts listings (evidence: `README.md`)
- Seed script → Mapbox geocoding: geocodes samples (evidence: `README.md`)
