# ranjit-sharma/majorproject architecture

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

- Interactive diagram: https://gitdiagram.com/ranjit-sharma/majorproject
- Repository: https://github.com/ranjit-sharma/majorproject

## Overview

WonderLust is a server-rendered vacation-rental application. A browser request enters the Express app, is dispatched through listing, review, or user routes, and reaches controllers that work with MongoDB models; the response is rendered as EJS pages. The graph also shows authentication, validation, review/listing relationships, and documented seeding and UI capabilities. Some view and user-flow connections are based on the README; unsampled implementation details are not inferred.

Main entry points: [`app.js`](https://github.com/ranjit-sharma/majorproject/blob/main/app.js) (Express app), [`middleware.js`](https://github.com/ranjit-sharma/majorproject/blob/main/middleware.js) (Auth and checks), [`models/listing.js`](https://github.com/ranjit-sharma/majorproject/blob/main/models/listing.js) (Listing model), [`routes/listing.js`](https://github.com/ranjit-sharma/majorproject/blob/main/routes/listing.js) (Listing routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Express app<br/>[app.js]"]
  node_listing_routes["Listing routes<br/>[listing.js]"]
  node_review_routes["Review routes<br/>[review.js]"]
  node_user_routes["User routes<br/>[user.js]"]
  node_async_wrapper["Async wrapper<br/>[wrapAsync.js]"]
  node_http_error["HTTP errors<br/>[ExpressError.js]"]
end

subgraph group_domain["Listings and reviews"]
  node_listing_controller["Listing controller<br/>[listings.js]"]
  node_review_controller["Review controller<br/>[reviews.js]"]
  node_listing_model[("Listing model<br/>[listing.js]")]
  node_review_model[("Review model<br/>[review.js]")]
  node_seed_data["Sample listings<br/>[data.js]"]
  node_seed_runner["Seed initializer<br/>[index.js]"]
end

subgraph group_identity["Identity and validation"]
  node_user_controller["User controller<br/>[users.js]"]
  node_user_model[("User model<br/>[user.js]")]
  node_middleware["Auth and checks<br/>[middleware.js]"]
  node_schemas["Joi schemas<br/>[schema.js]"]
end

subgraph group_presentation["Pages and assets"]
  node_listing_pages["Listing pages"]
  node_user_pages["Account pages"]
  node_error_page["Error page<br/>[error.ejs]"]
  node_static_assets["Browser assets"]
end

node_browser(("Browser"))
node_mongo[("MongoDB")]

node_browser -->|"sends requests"| node_app
node_app -->|"mounts routes"| node_listing_routes
node_app -->|"mounts routes"| node_review_routes
node_app -->|"mounts routes"| node_user_routes
node_listing_routes -->|"dispatches to"| node_listing_controller
node_review_routes -->|"dispatches to"| node_review_controller
node_user_routes -->|"dispatches to"| node_user_controller
node_listing_controller -->|"queries"| node_listing_model
node_review_controller -->|"updates"| node_listing_model
node_review_controller -->|"creates and deletes"| node_review_model
node_user_controller -->|"uses"| node_user_model
node_app -->|"configures sessions"| node_user_model
node_middleware -->|"checks ownership"| node_listing_model
node_middleware -->|"checks authorship"| node_review_model
node_middleware -->|"validates with"| node_schemas
node_listing_routes -->|"guards and validates"| node_middleware
node_review_routes -->|"guards and validates"| node_middleware
node_listing_routes -->|"wraps handlers"| node_async_wrapper
node_review_routes -->|"wraps handlers"| node_async_wrapper
node_user_routes -->|"wraps handlers"| node_async_wrapper
node_app -->|"raises not-found"| node_http_error
node_listing_model -->|"deletes related reviews"| node_review_model
node_app -->|"connects to"| node_mongo
node_app -.->|"renders listing UI"| node_listing_pages
node_app -.->|"renders account UI"| node_user_pages
node_app -->|"renders errors"| node_error_page
node_app -->|"serves static files"| node_static_assets
node_seed_runner -->|"loads sample data"| node_seed_data
node_seed_runner -->|"initializes listings"| node_listing_model

click node_app "https://github.com/ranjit-sharma/majorproject/blob/main/app.js"
click node_listing_routes "https://github.com/ranjit-sharma/majorproject/blob/main/routes/listing.js"
click node_review_routes "https://github.com/ranjit-sharma/majorproject/blob/main/routes/review.js"
click node_user_routes "https://github.com/ranjit-sharma/majorproject/blob/main/routes/user.js"
click node_listing_controller "https://github.com/ranjit-sharma/majorproject/blob/main/controller/listings.js"
click node_review_controller "https://github.com/ranjit-sharma/majorproject/blob/main/controller/reviews.js"
click node_user_controller "https://github.com/ranjit-sharma/majorproject/blob/main/controller/users.js"
click node_listing_model "https://github.com/ranjit-sharma/majorproject/blob/main/models/listing.js"
click node_review_model "https://github.com/ranjit-sharma/majorproject/blob/main/models/review.js"
click node_user_model "https://github.com/ranjit-sharma/majorproject/blob/main/models/user.js"
click node_middleware "https://github.com/ranjit-sharma/majorproject/blob/main/middleware.js"
click node_schemas "https://github.com/ranjit-sharma/majorproject/blob/main/schema.js"
click node_async_wrapper "https://github.com/ranjit-sharma/majorproject/blob/main/utils/wrapAsync.js"
click node_http_error "https://github.com/ranjit-sharma/majorproject/blob/main/utils/ExpressError.js"
click node_listing_pages "https://github.com/ranjit-sharma/majorproject/tree/main/views/listings"
click node_user_pages "https://github.com/ranjit-sharma/majorproject/tree/main/views/users"
click node_error_page "https://github.com/ranjit-sharma/majorproject/blob/main/views/error.ejs"
click node_static_assets "https://github.com/ranjit-sharma/majorproject/tree/main/public"
click node_seed_data "https://github.com/ranjit-sharma/majorproject/blob/main/init/data.js"
click node_seed_runner "https://github.com/ranjit-sharma/majorproject/blob/main/init/index.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_listing_routes,node_review_routes,node_user_routes,node_async_wrapper,node_http_error,node_browser toneBlue
class node_listing_controller,node_review_controller,node_listing_model,node_review_model,node_seed_data,node_seed_runner,node_mongo toneAmber
class node_user_controller,node_user_model,node_middleware,node_schemas toneMint
class node_listing_pages,node_user_pages,node_error_page,node_static_assets toneRose
```

## Components

### Web application

- [Express app](https://github.com/ranjit-sharma/majorproject/blob/main/app.js): `app.js`
- [Listing routes](https://github.com/ranjit-sharma/majorproject/blob/main/routes/listing.js): `routes/listing.js`
- [Review routes](https://github.com/ranjit-sharma/majorproject/blob/main/routes/review.js): `routes/review.js`
- [User routes](https://github.com/ranjit-sharma/majorproject/blob/main/routes/user.js): `routes/user.js`
- [Async wrapper](https://github.com/ranjit-sharma/majorproject/blob/main/utils/wrapAsync.js): `utils/wrapAsync.js`
- [HTTP errors](https://github.com/ranjit-sharma/majorproject/blob/main/utils/ExpressError.js): `utils/ExpressError.js`

### Listings and reviews

- [Listing controller](https://github.com/ranjit-sharma/majorproject/blob/main/controller/listings.js): `controller/listings.js`
- [Review controller](https://github.com/ranjit-sharma/majorproject/blob/main/controller/reviews.js): `controller/reviews.js`
- [Listing model](https://github.com/ranjit-sharma/majorproject/blob/main/models/listing.js): `models/listing.js`
- [Review model](https://github.com/ranjit-sharma/majorproject/blob/main/models/review.js): `models/review.js`
- [Sample listings](https://github.com/ranjit-sharma/majorproject/blob/main/init/data.js): `init/data.js`
- [Seed initializer](https://github.com/ranjit-sharma/majorproject/blob/main/init/index.js): `init/index.js`

### Identity and validation

- [User controller](https://github.com/ranjit-sharma/majorproject/blob/main/controller/users.js): `controller/users.js`
- [User model](https://github.com/ranjit-sharma/majorproject/blob/main/models/user.js): `models/user.js`
- [Auth and checks](https://github.com/ranjit-sharma/majorproject/blob/main/middleware.js): `middleware.js`
- [Joi schemas](https://github.com/ranjit-sharma/majorproject/blob/main/schema.js): `schema.js`

### Pages and assets

- [Listing pages](https://github.com/ranjit-sharma/majorproject/tree/main/views/listings): `views/listings`
- [Account pages](https://github.com/ranjit-sharma/majorproject/tree/main/views/users): `views/users`
- [Error page](https://github.com/ranjit-sharma/majorproject/blob/main/views/error.ejs): `views/error.ejs`
- [Browser assets](https://github.com/ranjit-sharma/majorproject/tree/main/public): `public`

### Other components

- **Browser**
- **MongoDB**

## Connections

- Browser → Express app: sends requests (evidence: `README.md`)
- Express app → Listing routes: mounts routes (evidence: `app.js`)
- Express app → Review routes: mounts routes (evidence: `app.js`)
- Express app → User routes: mounts routes (evidence: `app.js`)
- Listing routes → Listing controller: dispatches to (evidence: `routes/listing.js`)
- Review routes → Review controller: dispatches to (evidence: `routes/review.js`)
- User routes → User controller: dispatches to (evidence: `routes/user.js`)
- Listing controller → Listing model: queries (evidence: `controller/listings.js`)
- Review controller → Listing model: updates (evidence: `controller/reviews.js`)
- Review controller → Review model: creates and deletes (evidence: `controller/reviews.js`)
- User controller → User model: uses (evidence: `controller/users.js`)
- Express app → User model: configures sessions (evidence: `app.js`)
- Auth and checks → Listing model: checks ownership (evidence: `middleware.js`)
- Auth and checks → Review model: checks authorship (evidence: `middleware.js`)
- Auth and checks → Joi schemas: validates with (evidence: `middleware.js`)
- Listing routes → Auth and checks: guards and validates (evidence: `routes/listing.js`)
- Review routes → Auth and checks: guards and validates (evidence: `routes/review.js`)
- Listing routes → Async wrapper: wraps handlers (evidence: `routes/listing.js`)
- Review routes → Async wrapper: wraps handlers (evidence: `routes/review.js`)
- User routes → Async wrapper: wraps handlers (evidence: `routes/user.js`)
- Express app → HTTP errors: raises not-found (evidence: `app.js`)
- Listing model → Review model: deletes related reviews (evidence: `models/listing.js`)
- Express app → MongoDB: connects to (evidence: `app.js`)
- Express app → Listing pages: renders listing UI (evidence: `README.md`)
- Express app → Account pages: renders account UI (evidence: `README.md`)
- Express app → Error page: renders errors (evidence: `app.js`)
- Express app → Browser assets: serves static files (evidence: `app.js`)
- Seed initializer → Sample listings: loads sample data (evidence: `init/index.js`)
- Seed initializer → Listing model: initializes listings (evidence: `init/index.js`)
